SenseAir Miniature (Carbon Dioxide) CO2 Sensor are non-dispersive small package infrared (NDIR) sensor, a new optical design that enable a precise and accurately measures carbon dioxide level up to 5% that runs on 30mA design for long-term battery or solar powered application. In this demonstration we will going to wire these sensor using CC3200 Simple Link / WiFi IOT Solution with Microcontroller from Texas Instruments. The TI CC3200 LaunchPad XL is a WiFi chip on-board that allows you to operate independently. Follow the illustration below to wired-up the CC3200 IOT board. If you want to use other boards like ESP, STM32, SBC kindly refer to this link.
Required Components
- CC3200 SimpleLink Wi-Fi Microcontroller LaunchPad
- Note: (if your using CC3220SF / CC220S you required to use TI Code Composer) Refer to this link
- CC3220 Software Development Kit (SDK)
- If your using CC2300 with TI Code Composer please to this link
- LP8 / S8 Carbon Dioxide Sensor Module
Wiring Guide
Setup Guide
- Download Energia IDE <http://energia.nu/download/>
- Download the driver at <http://energia.nu/files/cc3200_drivers_win.zip>
- CRC Calculator
Source Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
byte readCO2[] = {0xFE, 0X44, 0X00, 0X08, 0X02, 0X9F, 0X25}; //Command 8 byte command to read RAM CRC = 0x259F /* To read EEPROM the following command works: byte readCO2[] = {0xFE, 0X46, 0X00, 0X08, 0X02, 0X9e, 0X9d}; //Command 8 byte command to read EEPROM The CRC bytes 0x9D9E were calculated using the link above. */ // 0xFE initiate a MODBUS command // 0x44 = S8 Read internal RAM command // 0x00 = RAM address H, 0x08 = RAM address L // 0x02 = Number of bytes to read // 0x9F = CRC LS byte, 0x25= CRC MS byte // Additional S8 commands: 0x41 = Write S8 RAM, 0x43 = Write S8 EEPROM, 0x46 = Read S8 EEPROM byte response[] = {0,0,0,0,0,0,0}; //create an array to store the 7 byte response //multiplier for value. default is 1. set to 3 for K- 30 3% and 10 for K- 33 ICB int valMultiplier = 1; //For 1% sensor P/N SE- 0119 marked 004- 0-0013 //int valMultiplier = 5; //For 5% sensor P/N SE- 0037 marked 004- 0-0017 //Serial1 is being used in place of the softwareSerial library. This is because the CC3200 has designated ports for tx and rx in more than one pin configuration void setup() { Serial.begin(9600); //Opens the main serial port to communicate with the computer Serial1.begin(9600); //Opens the virtual serial port with a baud of 9600 Serial.println(" Demo of AN- 167: S8 Sensor CC3200LAUNCHXL"); } void loop() { sendRequest(readCO2); unsigned long valCO2 = getValue(response); Serial.print("Co2 ppm = "); Serial.println(valCO2); delay(2000); } void sendRequest(byte packet[]) { while(!Serial1.available()) //keep sending request until we start to get a response { Serial1.write(readCO2,7); delay(50); } int timeout=0; //set a timeout counter while(Serial1.available() < 7 ) //Wait to get a 7 byte response { timeout++; if(timeout > 10) //if it takes to long there was probably an error { while(Serial1.available()) //flush whatever we have Serial1.read(); break; //exit and try again } delay(50); } for (int i=0; i < 7; i++) { response[i] = Serial1.read(); } } unsigned long getValue(byte packet[]) { int high = packet[3]; //high byte for value is 4th byte in packet in the packet int low = packet[4]; //low byte for value is 5th byte in the packet unsigned long val = high*256 + low; //Combine high byte and low byte with this formula to get value return val* valMultiplier; } |
Downloads
- Download CC3200 Datasheet / Manual | PDF
- Download CO2 Sensor LP8 Sensor Datasheet | PDF
- Download CO2 Sensor LP8 Sensor Manual | PDF
- Download CO2 Sensor S8 5% Sensor Datasheet | PDF
- Download CO2 Sensor S8 1% Sensor Datasheet |PDF
Wiring SenseAir LP8/S8 IR CO2 Sensor on TI CC3200 IOT-MCU