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

Similar documents
Application Note AN 157: Arduino UART Interface to TelAire T6613 CO2 Sensor

Application Note. Communication between arduino and IMU Software capturing the data

Welcome to Arduino Day 2016

For this exercise, you will need a partner, an Arduino kit (in the plastic tub), and a laptop with the Arduino programming environment.

EARTH PEOPLE TECHNOLOGY. EPT-200TMP-TS-U2 Temperature Sensor Docking Board User Manual

Arduino STEAM Academy Arduino STEM Academy Art without Engineering is dreaming. Engineering without Art is calculating. - Steven K.

Touch Potentiometer Hookup Guide

Training Schedule. Robotic System Design using Arduino Platform

Arduino Microcontroller Processing for Everyone!: Third Edition / Steven F. Barrett

MICROCONTROLLERS BASIC INPUTS and OUTPUTS (I/O)

Arduino Setup & Flexing the ExBow

J. La Favre Using Arduino with Raspberry Pi February 7, 2018

MICROCONTROLLERS BASIC INPUTS and OUTPUTS (I/O)

Community College of Allegheny County Unit 4 Page #1. Timers and PWM Motor Control

EE-110 Introduction to Engineering & Laboratory Experience Saeid Rahimi, Ph.D. Labs Introduction to Arduino

Arduino Lesson 1. Blink. Created by Simon Monk

Coding with Arduino to operate the prosthetic arm

Computational Crafting with Arduino. Christopher Michaud Marist School ECEP Programs, Georgia Tech

Lab 2: Blinkie Lab. Objectives. Materials. Theory

PLAN DE FORMACIÓN EN LENGUAS EXTRANJERAS IN-57 Technology for ESO: Contents and Strategies

Arduino An Introduction

Understanding the Arduino to LabVIEW Interface

APDS-9960 RGB and Gesture Sensor Hookup Guide

18 CHANNELS LED DRIVER EVALUATION BOARD GUIDE

Module: Arduino as Signal Generator

Objectives: Learn what an Arduino is and what it can do Learn what an LED is and how to use it Be able to wire and program an LED to blink

ZX Distance and Gesture Sensor Hookup Guide

CURIE Academy, Summer 2014 Lab 2: Computer Engineering Software Perspective Sign-Off Sheet

Lesson 3: Arduino. Goals

BEYOND TOYS. Wireless sensor extension pack. Tom Frissen s

DFRduino Romeo All in one Controller V1.1(SKU:DFR0004)

Debugging a Boundary-Scan I 2 C Script Test with the BusPro - I and I2C Exerciser Software: A Case Study

CPSC 226 Lab Four Spring 2018

INTRODUCTION TO THE ARDUINO MICROCONTROLLER

EGG 101L INTRODUCTION TO ENGINEERING EXPERIENCE

Arduino

You'll create a lamp that turns a light on and off when you touch a piece of conductive material

INA169 Breakout Board Hookup Guide

Sten-Bot Robot Kit Stensat Group LLC, Copyright 2013

Practical Assignment 1: Arduino interface with Simulink

MAE106 Laboratory Exercises Lab # 1 - Laboratory tools

Lecture 4: Basic Electronics. Lecture 4 Brief Introduction to Electronics and the Arduino

HC-SR501 Passive Infrared (PIR) Motion Sensor

The Motor sketch. One Direction ON-OFF DC Motor

24-RGB MATRIX LED DRIVER

Grove - I2C Color Sensor User Manual

FABO ACADEMY X ELECTRONIC DESIGN

Programming 2 Servos. Learn to connect and write code to control two servos.

1Getting Started SIK BINDER //3

Written by : Elizabeth Mabrey, Director of Storming Robots

Rodni What will yours be?

Lab 5: Arduino Uno Microcontroller Innovation Fellows Program Bootcamp Prof. Steven S. Saliterman

INTRODUCTION to MICRO-CONTROLLERS

smraza Getting Start Guide Contents Arduino IDE (Integrated Development Environment)... 1 Introduction... 1 Install the Arduino Software (IDE)...

INA3221 Breakout Board

HAW-Arduino. Sensors and Arduino F. Schubert HAW - Arduino 1

Community College of Allegheny County Unit 7 Page #1. Analog to Digital

Written by Hans Summers Wednesday, 15 November :53 - Last Updated Wednesday, 15 November :07

Arduino Digital Out_QUICK RECAP

Pulse Width Modulation and

Light Emitting Diode IV Characterization

TWEAK THE ARDUINO LOGO

Adafruit 16-Channel Servo Driver with Arduino

Arduino Platform Capabilities in Multitasking. environment.

Microcontrollers and Interfacing

Attribution Thank you to Arduino and SparkFun for open source access to reference materials.

Calibration Instruction Manual Emerson 475 Field Communicator. Manual Revision FC.2

Touch Potentiometer User Manual

Setup Download the Arduino library (link) for Processing and the Lab 12 sketches (link).

Experiment 1: Robot Moves in 3ft squared makes sound and

Internet of Things with Arduino and the CC3000

36 CHANNELS LED DRIVER EVALUATION BOARD GUIDE

INTRODUCTION to MICRO-CONTROLLERS

Monitoring Temperature using LM35 and Arduino UNO

Blink. EE 285 Arduino 1

DATASHEET. Amicrosystems AMI-AD1224 HIGH PRECISION CURRENT-TO-DIGITAL CONVERSION MODULE PRODUCT DESCRIPTION FEATURES

RB-Dev-03 Devantech CMPS03 Magnetic Compass Module

Montgomery Village Arduino Meetup Dec 10, 2016

Touch Potentiometer User Manual

SPI, Talking to Chips, and Minimizing Noise

SCHOOL OF TECHNOLOGY AND PUBLIC MANAGEMENT ENGINEERING TECHNOLOGY DEPARTMENT

Experiment 1 Identification of Components and Breadboard Realization

SV613 USB Interface Wireless Module SV613

URM37 V3.2 Ultrasonic Sensor (SKU:SEN0001)

18 11 DOTS MATRIX LED DRIVER

Intelligent Systems Design in a Non Engineering Curriculum. Embedded Systems Without Major Hardware Engineering

MICROCONTROLLERS Stepper motor control with Sequential Logic Circuits

AC Overload Tester for Magnet Wire

Total Hours Registration through Website or for further details please visit (Refer Upcoming Events Section)

ARDUINO / GENUINO. start as professional. short course in a book. faculty of engineering technology

ZIO Python API. Tutorial. 1.1, May 2009

Exam Practice Problems (3 Point Questions)

DHT11 Electronic Brick of Digital Temperature & Humidity Sensor

ISSN: [Singh* et al., 6(6): June, 2017] Impact Factor: 4.116

LED + Servo 2 devices, 1 Arduino

Programming the Dallas/Maxim DS MHz I2C Oscillator. Jeremy Clark

Gravity: 12-Bit I2C DAC Module SKU: DFR0552

AS726X NIR/VIS Spectral Sensor Hookup Guide

Lab 5: Inverted Pendulum PID Control

Catalog

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. 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. 21 March 2017 CO2Meter, Inc. All Rights Reserved 1

In addition, two 4.7K ohm ¼ watt 5% pull up resistors are required. Pull up resistors connect between a signal and a positive voltage to eliminate floating and insure pins are either in a high or low state. These can be found for only a few pennies apiece at any major electronics store. K 30 sensor I2C connection to Arduino UNO K 30 sensor uses same pin connections to Arduino Mega 2560 or 1280 21 March 2017 CO2Meter, Inc. All Rights Reserved 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: 21 March 2017 CO2Meter, Inc. All Rights Reserved 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); 21 March 2017 CO2Meter, Inc. All Rights Reserved 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 /////////////////////// 21 March 2017 CO2Meter, Inc. All Rights Reserved 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); 21 March 2017 CO2Meter, Inc. All Rights Reserved 6