Forum >Gravity: UART Infrared CO2 Sensor (0-50000ppm) problem
Gravity: UART Infrared CO2 Sensor (0-50000ppm) problem

After about 3-4 minutes the sensor becomes unresponsive every time. im using esp NodeMCU and software serial. the sensor work great for a couple minutes then stops responding. the NodeMCU does not freeze. the only way the sensor ill work again is if i unplug the power from the co2 sensor to restart it? Please help!!
2020-07-25 13:43:23 its not the power supply. im using a programmable dc power supply at 5.2v.
kizzzane

2020-07-22 08:55:36 I have 3 of these sensors and all 3 of them do the same thing. moving the delay helps it work a lot longer but in the end it still crashes? Im using esp8266 and software serial. any help would be greatly appreciated. I have sunk $300 dollars in the and they wont work
kizzzane

2020-07-21 06:20:45 This code on your website is in error,
kizzzane
Code: Select all
it should be,
/*************************************************** * Infrared CO2 Sensor 0-50000ppm(Wide Range) * **************************************************** * The follow example is used to detect CO2 concentration. * @author lg.gang([email protected]) * @version V1.0 * @date 2016-6-6 * GNU Lesser General Public License. * See <http://www.gnu.org/licenses/> for details. * All above must be included in any redistribution * ****************************************************/ #include <SoftwareSerial.h> SoftwareSerial mySerial(10, 11); // RX, TX 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() { Serial.begin(9600); while (!Serial) { } mySerial.begin(9600); } void loop() { mySerial.write(hexdata,9); delay(500); for(int i=0,j=0;i<9;i++) { if (mySerial.available()>0) { long hi,lo,CO2; int ch=mySerial.read(); if(i==2){ hi=ch; } //High concentration if(i==3){ lo=ch; } //Low concentration if(i==8) { CO2=hi*256+lo; //CO2 concentration Serial.print("CO2 concentration: "); Serial.print(CO2); Serial.println("ppm"); } } } }
Code: Select all
/*************************************************** * Infrared CO2 Sensor 0-50000ppm(Wide Range) * **************************************************** * The follow example is used to detect CO2 concentration. * @author lg.gang([email protected]) * @version V1.0 * @date 2016-6-6 * GNU Lesser General Public License. * See <http://www.gnu.org/licenses/> for details. * All above must be included in any redistribution * ****************************************************/ #include <SoftwareSerial.h> SoftwareSerial mySerial(10, 11); // RX, TX 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() { Serial.begin(9600); while (!Serial) { } mySerial.begin(9600); } void loop() { mySerial.write(hexdata,9); for(int i=0,j=0;i<9;i++) { if (mySerial.available()>0) { long hi,lo,CO2; int ch=mySerial.read(); if(i==2){ hi=ch; } //High concentration if(i==3){ lo=ch; } //Low concentration if(i==8) { CO2=hi*256+lo; //CO2 concentration Serial.print("CO2 concentration: "); Serial.print(CO2); Serial.println("ppm"); } } } delay(500); }

2020-07-20 22:55:16 the problem might be in your sample code. i think the delay is in the wrong place?
kizzzane
