Application Note AN 102: Arduino I2C Interface to K 30 Sensor

Similar documents
Arduino Lesson 1. Blink

Your Multimeter. The Arduino Uno 10/1/2012. Using Your Arduino, Breadboard and Multimeter. EAS 199A Fall Work in teams of two!

Eric Mitchell April 2, 2012 Application Note: Control of a 180 Servo Motor with Arduino UNO Development Board

RB-See-211. Seeedstudio Grove 6-15V, 2A Dual I2C Motor Driver. Grove - I2C Motor Driver. Introduction

ZX-NUNCHUK (# )

Yun Shield Quick Start Guide VERSION: 1.0 Version Description Date 1.0 Release 2014-Jul-08 Yun Shield Quick Start Guide 1 / 14

Board also Supports MicroBridge

Arduino Due Back. Warning: Unlike other Arduino boards, the Arduino Due board runs at 3.3V. The maximum. Overview

Arduino ADK Back. For information on using the board with the Android OS, see Google's ADK documentation.

EARTH PEOPLE TECHNOLOGY SERIAL GRAPH TOOL FOR THE ARDUINO UNO USER MANUAL

Basic Pulse Width Modulation

Arduino Lesson 16. Stepper Motors

Arduino Lesson 5. The Serial Monitor

User s Manual of Board Microcontroller ET-MEGA2560-ADK ET-MEGA2560-ADK

The I2C Bus. NXP Semiconductors: UM10204 I2C-bus specification and user manual HAW - Arduino 1

Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide

Arduino Lesson 13. DC Motors. Created by Simon Monk

2.0 Command and Data Handling Subsystem

Intro to Intel Galileo - IoT Apps GERARDO CARMONA

Adafruit BME280 Humidity + Barometric Pressure + Temperature Sensor Breakout

MeshBee Open Source ZigBee RF Module CookBook

1602 LCD adopts standard 14 pins(no backlight) or 16pins(with backlight) interface, Instruction of each pin interface is as follows:

Workshop 7 PC Software - Tracker

1 of 5 12/31/ :51 AM

Arduino Lesson 14. Servo Motors

GM862 Arduino Shield

Microcontroller Programming Beginning with Arduino. Charlie Mooney

Lab 6 Introduction to Serial and Wireless Communication

User Manual. AS-Interface Programmer

Example Connection between USB Host and Android

DS1307 Real Time Clock Breakout Board Kit

Adafruit MCP9808 Precision I2C Temperature Sensor Guide

Definitions and Documents

Yun Shield User Manual VERSION: 1.0. Yun Shield User Manual 1 / 22.

2013 G Miller. 3 Axis Brushless Gimbal Controller Manual

Work with Arduino Hardware

Bluetooth + USB 16 Servo Controller [RKI-1005 & RKI-1205]

Arduino Shield Manual

Using a Laptop Computer with a USB or Serial Port Adapter to Communicate With the Eagle System

Surveillance System Using Wireless Sensor Networks

IR Communication a learn.sparkfun.com tutorial

LCD I 2 C/Serial RX Backpack. Data Sheet. LCD to I2C/Serial RX Backpack I2C or Serial RX communication with Standard 16 Pin LCD modules

Configuring Allen-Brandly ControlLogix PLC with Moxa MGate 5105-MB-EIP. 1 Application Description Objective Goals...

PLC training panel (Twido version)

The BSN Hardware and Software Platform: Enabling Easy Development of Body Sensor Network Applications

CanSat Program. Stensat Group LLC

Arduino DUE + DAC MCP4922 (SPI)

DEPARTMENT OF ELECTRONICS ENGINEERING

AN601 I2C 2.8 Communication Protocol. SM130 SM130 - Mini APPLICATION NOTE

Connecting Arduino to Processing a

Arduino project. Arduino board. Serial transmission

#include <Gamer.h> Gamer gamer; void setup() { gamer.begin(); } void loop() {

Ultrasonic Distance Measurement Module

PHYS 2P32 Project: MIDI for Arduino/ 8 Note Keyboard

Wireless Temperature

A REST API for Arduino & the CC3000 WiFi Chip

Introduction to Dynamixel Motor Control Using the ArbotiX-M Robocontroller

Arduino Wifi shield And reciever. 5V adapter. Connecting wifi module on shield: Make sure the wifi unit is connected the following way on the shield:

Sending Data from a computer to a microcontroller using a UART (Universal Asynchronous Receiver/Transmitter)

Application Note IMU Visualization Software

MCP4725 Digital to Analog Converter Hookup Guide

NB3H5150 I2C Programming Guide. I2C/SMBus Custom Configuration Application Note

Programming PIC Microcontrollers in PicBasic Pro Lesson 1 Cornerstone Electronics Technology and Robotics II

Adafruit SHT31-D Temperature & Humidity Sensor Breakout

Embedded Systems Design Course Applying the mbed microcontroller

Arduino Microcontroller Guide W. Durfee, University of Minnesota ver. oct-2011 Available on-line at

MicroMag3 3-Axis Magnetic Sensor Module

KTA-223 Arduino Compatible Relay Controller

INTRODUCTION TO SERIAL ARM

TSL2561 Luminosity Sensor

How to setup a serial Bluetooth adapter Master Guide

RS-485 Protocol Manual

PN532 NFC RFID Module User Guide

Fingerprint Based Biometric Attendance System

PL-1, Pocket Logger B

Designed & Developed By: Ms. Nidhi Agarwal. Under the Guidance of: Dr. SRN Reddy, Associate Professor, CSE. Computer Science & Engineering Department

Technical Manual. FAN COIL CONTROLLER COOLING or HEATING ANALOG or PWM Art A

1 Application Description Objective Goals... 3

Web Site: Forums: forums.parallax.com Sales: Technical:

TUTORIAL FOR INITIALIZING BLUETOOTH COMMUNICATION BETWEEN ANDROID AND ARDUINO

HANDLING SUSPEND MODE ON A USB MOUSE

Omron I/O Driver (Series 2) Programmable Serial Interface Card

Microcontroller Systems. ELET 3232 Topic 8: Slot Machine Example

WUA Mbps Wireless USB Network Adapter

Arduino Shield Manual

Designing VM2 Application Boards

ANDROID BASED FARM AUTOMATION USING GR-SAKURA

Working with microcontroller-generated audio frequencies (adapted from the Machine Science tutorial)

STIM202 Evaluation Kit

- 35mA Standby, mA Speaking pre-defined phrases with up to 1925 total characters.

Programming the VEX Robot

PRODUCTIVITY THROUGH INNOVATION 600 CONTROL DIRECT DRIVE TECHNICAL/OPERATION MANUAL

MS830 / MS833 Barcode Reader v1.0 9-December-2014

Fiery E100 Color Server. Welcome

Freescale Semiconductor, I

Nemo 96HD/HD+ MODBUS

Sending an SMS with Temboo

E-Blocks Easy Internet Bundle

MODULE BOUSSOLE ÉLECTRONIQUE CMPS03 Référence :

Lab 2.0 Thermal Camera Interface

Transcription:

Application Note AN 102: Arduino I2C Interface to K 30 Sensor Introduction The Arduino UNO, MEGA 1280 or MEGA 2560 are ideal microcontrollers for operating SenseAir s K 30 CO2 sensor. The connection to the K 30 is referred to I2C or TWI (Two Wire Interface). We recommend using the Arduino software Graphical User Interface (GUI). If you are new to Arduino these low cost development boards are available from many sources. We recommend you start with genuine Arduino products for dependable results. Run the Blink Example The best way to become familiar with the GIU or to verify your Arduino board is operating properly is to create an Arduino project and run the example Blink. This simple test program confirms that a number of connection details and the GUI are working properly. Caution: Do not connect the Arduino board to the USB port until the Arduino software is installed. Otherwise Windows will install a generic driver and the Arduino will not operate. Step 1: Install Arduino software on your computer. From this page select the Windows Installer. https://www.arduino.cc/en/main/software Step 2: To run the Blink example follow these instructions: https://www.arduino.cc/en/tutorial/blink Connect the K30 Sensor Refer to the wiring diagrams below for the Arduino UNO or MEGA. The connections for Arduino MEGA 1280 are identical to the Mega 2560. Important: A 6 9 VDC, 500 ma or greater, external power supply is required. The K 30 sensor draws 300+ ma when sampling. Using the voltage off the Arduino board from USB will give erratic results. Connect the power supply as shown. 1

K 30 sensor I2C connection to Arduino UNO K 30 sensor uses same pin connections to Arduino Mega 2560 or 1280 2

Creating an Arduino Project 1. Check that your Arduino is connected to your USB port and on board LED indicates power is on. 2. Click on or copy/paste this link to the zip file that contains the Arduino AN 102.ino file. http://www.co2meters.com/documentation/appnotes/an102-k30-sensor-arduino-i2c.zip 3. The Arduino GUI will start and ask the following; 4. Click on OK. Observe the Arduino project code is displayed. 5. Click on Sketch >> Verify/Compile. The project should compile without errors. 6. Verify that your Arduino board is recognized correctly: a. Click on Tools. Set Board to Arduino UNO or MEGA. b. Confirm that Processor matches your Arduino: UNO or MEGA or MEGA 2560. 7. Click on Upload. When done uploading, your project is now running in the Arduino board. 8. To view program operation, click on Tools >> Serial Monitor. Observe the following: 3

Appendix A: The source code for the.ino and.txt files are below: // CO2 Meter K-series Example Interface // Revised by Marv Kausch, 7/2016 at CO2 Meter <co2meter.com> // Talks via I2C to K30/K33 Sensors and displays CO2 values #include <Wire.h> // We will be using the I2C hardware interface on the Arduino in // combination with the built-in Wire library to interface. // Arduino analog input 5 - I2C SCL // Arduino analog input 4 - I2C SDA In this example we will do a basic read of the CO2 value and checksum verification. For more advanced applications see the I2C Comm guide. int co2addr = 0x68; // This is the default address of the CO2 sensor, 7bits shifted left. void setup() Serial.begin(9600); Wire.begin (); pinmode(13, OUTPUT); // address of the Arduino LED indicator Serial.println("Application Note AN-102: Interface Arduino to K-30"); ///////////////// // Function : int readco2() // Returns : CO2 Value upon success, 0 upon checksum failure // Assumes : - Wire library has been imported successfully. // - LED is connected to IO pin 13 // - CO2 sensor address is defined in co2_addr ///////////////// int readco2() int co2_value = 0; // Store the CO2 value inside this variable. digitalwrite(13, HIGH); // turn on LED // On most Arduino platforms this pin is used as an indicator light. / Begin Write Sequence / Wire.beginTransmission(co2Addr); Wire.write(0x22); Wire.write(0x00); 4

Wire.write(0x08); Wire.write(0x2A); Wire.endTransmission(); End Write Sequence. Wait 10ms for the sensor to process our command. The sensors's primary duties are to accurately measure CO2 values. Waiting 10ms ensures the data is properly written to RAM delay(10); Begin Read Sequence Since we requested 2 bytes from the sensor we must read in 4 bytes. This includes the payload, checksum, and command status byte. Wire.requestFrom(co2Addr, 4); byte i = 0; byte buffer[4] = 0, 0, 0, 0; Wire.available() is not necessary. Implementation is obscure but we leave it in here for portability and to future proof our code while (Wire.available()) buffer[i] = Wire.read(); i++; /////////////////////// End Read Sequence /////////////////////// 5

Using some bitwise manipulation we will shift our buffer into an integer for general consumption co2_value = 0; co2_value = buffer[1] & 0xFF; co2_value = co2_value << 8; co2_value = buffer[2] & 0xFF; byte sum = 0; //Checksum Byte sum = buffer[0] + buffer[1] + buffer[2]; //Byte addition utilizes overflow if (sum == buffer[3]) // Success! digitalwrite(13, LOW); return co2_value; else // Failure! Checksum failure can be due to a number of factors, fuzzy electrons, sensor busy, etc. digitalwrite(13, LOW); return 0; void loop() int co2value = readco2(); if (co2value > 0) Serial.print("CO2 Value: "); Serial.println(co2Value); else Serial.println("Checksum failed / Communication failure"); delay(2000); 6