AirGradient Forum

S8 CO2 reading of -1

I just installed the version you have on github. Its been running about 20 minutes with no data at all from the sensors.

# HELP particle_count Count of Particulate Matter in µg/m3
# TYPE particle_count gauge
particle_count{id="",mac="A4:E5:7C:B3:XX:XX",type="PM2.5"}0
# HELP particle_count Count of Particulate Matter in µg/m3
# TYPE particle_count gauge
particle_count{id="",mac="A4:E5:7C:B3:XX:XX",type="PM1.0"}0
# HELP particle_count Count of Particulate Matter in µg/m3
# TYPE particle_count gauge
particle_count{id="",mac="A4:E5:7C:B3:XX:XX",type="PM10.0"}0
# HELP rco2 CO2 value, in ppm
# TYPE rco2 gauge
rco2{id="",mac="A4:E5:7C:XX:XX"}0
# HELP atmp Temperature, in degrees Celsius
# TYPE atmp gauge
atmp{id="",mac="A4:E5:7C:B3:XX:XX"}0.00
# HELP rhum Relative humidity, in percent
# TYPE rhum gauge
rhum{id="",mac="A4:E5:7C:B3:XX:XX"}0.00
# HELP sensors_boot_time AirGradient_Internal boot time, in unixtime.
# TYPE sensors_boot_time gauge
sensors_boot_time{id="",mac="A4:E5:7C:B3:XX:XX"}0

I uploaded Jeffs original sketch and it works, however, still have the issue with the -1 on the CO

I only encountered this issue once.
Can you simply restart the board if it happens again ?

I have reset, pulled the USB several times, still getting no data on either the display or the prometheus end point.

just zeros.

It seems that if I hold open the serial port on the ESP, by keeping serial monitor on in Arduino IDE, it displays data, as soon as I close serial monitor, I lose data display

Do you see anything weird in the Serial Monitoring ?

This could be a symptom that one of the sensor couldn’t initialize correctly

Not really…

>>> SenseAir S8 NDIR CO2 sensor <<<
Firmware version: 1.92
Sensor type: 0x00010E
ABC period: 180
Transmit NTP Request
pool.ntp.org: 72.30.35.88
Epoch: 1645670157
HTTP server started at ip
Record PM2.5 (1) for AVG: (1.000000
)Record PM2.5 (0) for AVG: (0.500000)
Record PM2.5 (0) for AVG: (0.333333)
Couldn't get proper CO2 reading
Couldn't get proper CO2 reading
Couldn't get proper CO2 reading
Couldn't get proper CO2 reading
Couldn't get proper CO2 reading

Display shows AQI - NA and PM2 - 0, so I believe it may be having issues with the PM sensor…

Something else of note, it doesn’t seem bothered by which serial port the monitor is connected to to.

Currently I have the airgradient on /dev/ttyUSB7 and another esp32 on /dev/ttyUSB10 (doing a temp comparison test) and the airgradient board is happily spitting out CO2 data… if I shut down that esp32 it stops…

I wonder if it’s a Power issue.

The board don’t like when there is fluctuation of power. In my case, it’s currently plugged into a USB powerhub to avoid any issue.

I have an adjustable buck converter I am going to try… I’ll let you know what I see with that.

I think you are on to something…

I’m pretty confident that our issues with this sensor are not power, but ground plane issues.

I took a look at the board on EasyEDA and it’s designed as a 2 layer board and both layers have traces going everywhere and no ground pours.

There’s nothing there to reduce EMF. I’m redesigning the board in Kicad to try to move as many traces to the front and create a solid ground pour on the back side. I just need to add the graphics and it’s good to go.

I did quite some analysis of this issue. What I see happening is a serial communication problem. Various sources in other projects are mentioning that the Softserial library has some (timing) issue. I did not have the time to try them yet but it confirms softserial as potential source for errors.

I have been running my sensor connected to my development pc for a long time. It shows the output of the 8 values of CO2Response[i] . In case of a correct reading CO2Response[0] should contain 0xFE. I observed that this value is sometimes shifted to CO2Response[1] and leads to an incorrect value. I have adopted the function AirGradient::getCO2_Raw() in airgradient.cpp and work around this problem. Maybe not the most structural solution but it works.

I am running 3 sensors since 19/02 and did not see any false reading until today.

int AirGradient::getCO2_Raw(){
	const byte CO2Command[] = {0xFE, 0X44, 0X00, 0X08, 0X02, 0X9F, 0X25};
	byte CO2Response[] = {0,0,0,0,0,0,0};
	int datapos = -1;
	
	while (datapos == -1) {
		_SoftSerial_CO2->write(CO2Command, 7);
		delay(100);
		int bytesinbuffer = _SoftSerial_CO2->available();
		
		for (int i=0; i < bytesinbuffer; i++) {
			delay(25);
			CO2Response[i] = _SoftSerial_CO2->read();
			// yield();
			if ((CO2Response[i] == 0xFE) && (datapos == -1)){
				datapos = i;
			}
			Serial.print (CO2Response[i],HEX);
			Serial.print (":");
		}
  }	
  
  unsigned long val = CO2Response[datapos + 3]*256 + CO2Response[datapos + 4];  
  Serial.println (val);
  return val;	
}
1 Like

I have 5 of these on the way, if anyone is interested in one, I’ll have 3 extra. PM me and I’ll send you one when they arrive.

Hey @Indymx , any success with the new board layout ?
Do you mind sharing it?

I have really weird issues on my 2nd Board CO2 sensor and I’m checking what I can improve as I want to build 3 more.

Sometimes one really does escalate

yeah, I have had 2 of them in use for 3 weeks with no issues. I very firmly believe that the issues being seen with these sensors is not a power issue at all, but a noise issue. I have run the sensor down as far as 3.73 volts with no issues at the CO2 sensor, on my revised board.

My board has almost all traces on the front. I think there are a couple very short traces on the back, but they are in a position that they don’t hurt the signal paths.

You can download the gerber files from github. I had JLCPCB make mine, I think it was about 6 bucks for 5 boards.

1 Like

Does it make sense to add a capacitor to cover the temporary power drain of the co2 sensor when measuring? it seems to have overall a pretty low power consumption and then spiking to up to 1A or probably more. I changed my usb power supply for the affected airgradient and the issue seem to be gone.

But question is, is it possible to use a cap, so you are less reliant on an “high power” usb supply ?
So you can stick with older 1A than 1.2A or 1.5A just for the spikes?

Experienced the same issue with the latest Pro kit.

We tested this recently but did not find any difference with/without cap.

I have created my own version of the PCB and added the cap. I still think its super helpful because now its easily running on an 1A power supply without issues. Not related to the -1 issue tho.

Yes, that’a a good point. I will keep that in mind for a future update of the board.

We most likely found the reason for the “-1” issue. It seems to be related to the software serial.

There is a D1 mini with an ESP32. The ESP32 has several hardware serial ports and we used the same code as for the normal D1 mini (ESP8266) and just changed from software serial to hardware serial. Everything unchanged (same PCB, sensors etc) and the “-1” completely disappeared.

The next step is that we will make our Arduino library ESP32 compatible and then we might switch from the ESP8266 to an ESP32.