Skip to content
Snippets Groups Projects
Commit e88ae542 authored by Karol Hennessy's avatar Karol Hennessy
Browse files

co2 sensor working

parent 550b0690
Branches
No related merge requests found
#include <Arduino.h>
#include <HardwareSerial.h>
//#include <HardwareSerial.h>
HardwareSerial co2_serial(2); // RX2 = pin IO16, TX2 = pin IO17
// #define RXD2 16
// #define TXD2 17
unsigned char hexdata[9] = {0xFF, 0x01, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79}; //Read the gas density command /Don't change the order
void setup()
{
......@@ -11,18 +13,30 @@ void setup()
{
delay(1);
}
Serial.println("setup Serial1 ok");
co2_serial.begin(9600);
// Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
// while (!Serial2)
while (!co2_serial)
{
delay(1);
}
Serial.println("setup Serial2 ok");
}
void loop()
{
co2_serial.write(hexdata, 9);
// delay(500);
// Serial2.write(hexdata, 9);
delay(500);
for (int i = 0, j = 0; i < 9; i++) {
if (co2_serial.available() > 0) {
// if (Serial2.available() > 0) {
long hi, lo, CO2;
int ch = co2_serial.read();
// int ch = Serial2.read();
if (i == 2) {
hi = ch;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment