Atlas scientific CO2 sensor is not working properly

Hi everyone,
I have just rewired my setup because of some issues with a faulty breadboard and after a fresh reinstall of Mycodo v. 8.13.7 (on Raspberry pi 400, 64bit OS) my atlas scientific CO2 sensor is displaying quite a lot of errors and I am not sure if it is a hardware issue or not

The sensor is wired correctly in I2C mode and the measurment interval is set at 2.0 seconds.

The error log shows this:

2022-04-14 22:04:00,065 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 8: invalid start byte
2022-04-14 22:04:00,066 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 8: invalid start byte
2022-04-14 22:04:00,066 - ERROR - mycodo.controllers.controller_input_a63ffe4f - StopIteration raised 3 times. Possibly could not read input. Ensure it's connected properly and detected.
2022-04-14 22:04:10,013 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 6: invalid start byte
2022-04-14 22:04:10,013 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 6: invalid start byte
2022-04-14 22:04:12,023 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 7: invalid start byte
2022-04-14 22:04:12,023 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 7: invalid start byte
2022-04-14 22:04:16,076 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 48: invalid start byte
2022-04-14 22:04:16,076 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 48: invalid start byte
2022-04-14 22:04:22,028 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 6: invalid start byte
2022-04-14 22:04:22,028 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 6: invalid start byte
2022-04-14 22:04:24,036 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 8: invalid start byte
2022-04-14 22:04:24,037 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 8: invalid start byte
2022-04-14 22:04:26,046 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 35: invalid start byte
2022-04-14 22:04:26,047 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 35: invalid start byte
2022-04-14 22:04:26,048 - ERROR - mycodo.controllers.controller_input_a63ffe4f - StopIteration raised 3 times. Possibly could not read input. Ensure it's connected properly and detected.
2022-04-14 22:04:32,028 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 7: invalid start byte
2022-04-14 22:04:32,028 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 7: invalid start byte
2022-04-14 22:04:36,074 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 6: invalid start byte
2022-04-14 22:04:36,075 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 6: invalid start byte
2022-04-14 22:04:38,086 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 9: invalid start byte
2022-04-14 22:04:38,087 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 9: invalid start byte
2022-04-14 22:04:42,023 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 30: invalid start byte
2022-04-14 22:04:42,023 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 30: invalid start byte
2022-04-14 22:04:44,031 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 40: invalid start byte
2022-04-14 22:04:44,032 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 40: invalid start byte
2022-04-14 22:04:52,051 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 37: invalid start byte
2022-04-14 22:04:52,051 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 37: invalid start byte
2022-04-14 22:04:56,025 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 21: invalid start byte
2022-04-14 22:04:56,026 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 21: invalid start byte
2022-04-14 22:04:58,033 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 40: invalid start byte
2022-04-14 22:04:58,034 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 40: invalid start byte
2022-04-14 22:05:00,043 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 6: invalid start byte
2022-04-14 22:05:00,044 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 6: invalid start byte
2022-04-14 22:05:00,044 - ERROR - mycodo.controllers.controller_input_a63ffe4f - StopIteration raised 3 times. Possibly could not read input. Ensure it's connected properly and detected.

I have tried to increase the measurement period and that does help a little bit, but there is still quite a high error rate, only with a larger delay between errors.
Do you think that it might be a hardware issue and if so, what would be the best way forward?

I do have an oscilloscope but I am still learning about the I2C bus and I am not sure if I will be able to spot the issue.

Thank you very much!

Ensure your sensor has a unique I2C address on the Mycodo System Information Page under the Gear icon.

The “invalid start byte” sounds to me like you’re not talking to the correct sensor. The default is 105 (0x69), so it looks like everything is fine, but…

Double check the wiring, just to be sure. I once forgot that the blue wire is not connected (unlike the rest of the system if you followed Kyle’s example) and caused a huge headache until I figured it out.

Hi,
thanks for the suggestion. I have checked the wiring, but I am using Atlas scientific sensor bridge that has 4.7k resistors Atlas Scientific Sensor Bridge - Sensors & probes and it is connected properly, all of the other sensors/pumps connected to this bridge do work.

I have also checked the adress and even tried changing it and it did not appreciably change the error rate. The data do go through but there is an error rate of about 10 errors/minute when the measurement rate is 2 seconds.

What did help a bit was disconnecting all of the other I2C devices and left only the CO2 sensor, the error rate dropped to about 0.5-1 error/minute but that is still quite a lot.

There seems to be an issue with the presence of other I2C devices. I could try looking at the I2C signal with an oscilloscope and maybe changing the pullup resistor value specially for this sensor but I don’t want to mess with this until I am sure it is only a hardware issue.

I have found this type of an issue mentioned in a software context, but I am not sure if it is applicable to this problem: python - error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte - Stack Overflow

Thank you for any suggestions.

Are you using a sufficient power supply? NDIR CO2 sensors draw a significant amount of current and if you overload your circuit (with numerous and high-draw sensors), and do not provide adequate power, you will see issues. Also, without an I2C extender, you should be using very short wire lengths.

I am using an external 3.3V power source with about 3000mA of available amperage. The circuits are drawing about 220mA.

The I2C hubs I’m using for connecting the devices together are interconnected with about 30cm of wire and about 30cm of wire is further connected to raspberry pi. I am using atlas scientific sensor bridge with 4.7k resistors for this sensor.
The sensor itself is connected only with the cable length it came with, i have not extended it yet.

Do you thing that this is only a hardware issue? And if so, what would you reccomend I try next?

Thank you very much!

If it has ever acquired a valid measurement, the issue is likely not with Mycodo. It is likely either your circuit or the device itself. Additionally, NDIR sensors only periodically make the large current draw to energize and conduct a measurement, typically every 2 seconds, but can vary (when in the dark, you may be able to see it slightly illuminate), so current meters may be insufficient at correctly measuring current draw if it’s averaging.

I would first isolate the sensor by itself, on the shortest length of wire you can (Pi to breadboard, breadboard to sensor), without any additional resistors, to simply your circuit and remove as many additional variables as possible. I would also stop sampling at such a high rate (every 2 seconds). If the sensor only acquires a measurement every 2 seconds, you may be exhausting the measurement buffer. There’s really no need to sample so fast, the default 15 seconds is more than adequate for most applications.

OK thank you I’ll try that!

@purafi Is it possible to move it to the 5VDC bus of the Pi? You could connect I2C with jumpers, then power the sensor from 5VDC just for testing.

Also, is the case of the probe grounded to earth ground? While I’m not sure if this error could be caused by a ground loop, page 5 of the datasheet states that the sensor is sensitive to ground loops and that either the Ground of the Pi or the case of the sensor should be connected to earth.

It mentions that the readings could be high, but perhaps this could be caused by this as well.

I’m installing this sensor right now and have experienced the same error. After moving it to a static mat connected to ground, it seems to have reduced the error dramatically. I’m going to ground the case of the sensor directly to earth to see what difference that makes.

I’m having the same issue. The EZO-CO2 is running off the 5VDC bus and works intermittently. I have the sensor case grounded directly to an outlet via a wall plug. I’m going to try tying a Pi GND to earth ground as suggested in the datasheet, as well.

I may try powering it from a separate power supply. I’ve noticed the LCD displaying garbage when powering up the sensor occasionally.

The bold text makes it sound like it’s an issue with the library that’s reading the sensor.

2022-04-16 15:36:50,301 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: ‘utf-8’ codec can’t decode byte 0xff in position 2: invalid start byte
2022-04-16 15:36:50,302 - DEBUG - mycodo.inputs.atlas_co2_94510541 - Device Returned: error: ‘utf-8’ codec can’t decode byte 0xff in position 2: invalid start byte
2022-04-16 15:36:50,302 - ERROR - mycodo.inputs.atlas_co2_94510541 - Sensor read unsuccessful: ‘utf-8’ codec can’t decode byte 0xff in position 2: invalid start byte

@KyleGabriel

Running i2c.py from GitHub - AtlasScientific/Raspberry-Pi-sample-code shows that both my HUM and CO2 devices are connected correctly.

The Poll mode shows that both respond on almost every poll at 1.5 second intervals. (I suspect that when they don’t respond, Mycodo might be polling at the time.)

1 Like

Looks like you have multiple failed measurements in that short period, for both sensors. The same sensor cannot be queried at the same time. Why not deactivate the Mycodo Inputs to completely remove that variable?

I have also tried Atlas scientific I2C script as suggested by LaserGecko and the results are as follows:

Setup:
-10 I2C devices connected together on 4 I2C “hubs” (picture 1)

  1. hub 1 (Atlas Sensor Bridge 4.7k resistor): 2x Atlas Ezo pumps, 1x Atlas humidity
  2. hub 2 (Atlas Sensor Bridge 4.7k resistor): 2x Atlas Ezo pumps, 1x Atlas CO2
  3. hub 3 (Groove I2C hub, no pullup resistor): hub 1+hub 2, Atlas EC+iso board 4.7k resistor, DS3502 digital potentiometer+10k resistor
  4. hub 4-connected to Raspberry pi (picture 2) (Groove I2C hub, no pullup resistor): hub 3 + 2x Atlas temperature sensors

The whole setup is grounded (the yellow wire on the far left) by connecting Raspberry pi to Earth ground plug of my external PSU 3.3V 3000mA.

Firstly I ran the test using Atlas scientific script for 10 minutes at a sampling rate of 1.5s (default):

  • 2 errors that looked like this:
  • 0 errors with CO2 sensor:
Success PMP 50 : 5.00
Success PMP 52 : 5.00
Success PMP 53 : 5.00
Success PMP 54 : 5.00
Success EC 100 : 490.6,265,0.24,1.000
Success RTD 102 : 16.011
Success RTD 103 : 16.603
Success CO2 105 : 495
**Error HUM 111 : 129**

Then I ran the same test using Mycodo, sampling rate was:

  • RTD 1 (1 seconds)
  • RTD 2 (2 seconds)
  • CO2 (3 seconds)
  • Humidity (4 seconds)
  • EC (5 seconds)

And the error rate was very high (I could not post the whole log):

  • almost all errors were with CO2 sensor
  • 2 errors with humidity (same as in the Atlas script)
2022-04-17 10:41:06,224 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 34: invalid start byte
2022-04-17 10:41:06,225 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 34: invalid start byte
2022-04-17 10:41:09,240 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 5: invalid start byte
2022-04-17 10:41:09,240 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 5: invalid start byte
2022-04-17 10:41:09,240 - ERROR - mycodo.controllers.controller_input_a63ffe4f - StopIteration raised 3 times. Possibly could not read input. Ensure it's connected properly and detected.
2022-04-17 10:41:12,256 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 21: invalid start byte
2022-04-17 10:41:12,257 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 21: invalid start byte
2022-04-17 10:41:21,238 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 12: invalid start byte
2022-04-17 10:41:21,238 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 12: invalid start byte
2022-04-17 10:41:33,238 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 5: invalid start byte
2022-04-17 10:41:33,239 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 5: invalid start byte
2022-04-17 10:41:36,252 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 6: invalid start byte
2022-04-17 10:41:36,252 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 6: invalid start byte
2022-04-17 10:41:39,262 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 34: invalid start byte
2022-04-17 10:41:39,262 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 34: invalid start byte
2022-04-17 10:41:39,263 - ERROR - mycodo.controllers.controller_input_a63ffe4f - StopIteration raised 3 times. Possibly could not read input. Ensure it's connected properly and detected.
2022-04-17 10:41:42,254 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 38: invalid start byte
2022-04-17 10:41:42,254 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 38: invalid start byte
2022-04-17 10:41:45,267 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 33: invalid start byte
2022-04-17 10:41:45,267 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 33: invalid start byte
2022-04-17 10:41:51,306 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 19: invalid start byte
2022-04-17 10:41:51,306 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 19: invalid start byte
2022-04-17 10:42:00,321 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 6: invalid start byte
2022-04-17 10:42:00,322 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 6: invalid start byte
2022-04-17 10:42:12,318 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 6: invalid start byte
2022-04-17 10:42:12,318 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 6: invalid start byte
2022-04-17 10:42:15,227 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 5: invalid start byte
2022-04-17 10:42:15,227 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 5: invalid start byte
2022-04-17 10:42:18,237 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 6: invalid start byte
2022-04-17 10:42:18,238 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 6: invalid start byte
2022-04-17 10:42:18,238 - ERROR - mycodo.controllers.controller_input_a63ffe4f - StopIteration raised 3 times. Possibly could not read input. Ensure it's connected properly and detected.
2022-04-17 10:42:21,247 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 22: invalid start byte
2022-04-17 10:42:21,248 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 22: invalid start byte
2022-04-17 10:42:27,288 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 6: invalid start byte
2022-04-17 10:42:27,288 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 6: invalid start byte
2022-04-17 10:42:30,302 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 7: invalid start byte
2022-04-17 10:42:30,303 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 7: invalid start byte
2022-04-17 10:42:36,239 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 24: invalid start byte
2022-04-17 10:42:36,239 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 24: invalid start byte
2022-04-17 10:42:51,269 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 14: invalid start byte
2022-04-17 10:42:51,269 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 14: invalid start byte
2022-04-17 10:42:54,283 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 19: invalid start byte
2022-04-17 10:42:54,284 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 19: invalid start byte
2022-04-17 10:43:00,329 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 8: invalid start byte
2022-04-17 10:43:00,329 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 8: invalid start byte
2022-04-17 10:43:03,238 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 44: invalid start byte
2022-04-17 10:43:03,239 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 44: invalid start byte
2022-04-17 10:43:06,248 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 7: invalid start byte
2022-04-17 10:43:06,249 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 7: invalid start byte
2022-04-17 10:43:06,249 - ERROR - mycodo.controllers.controller_input_a63ffe4f - StopIteration raised 3 times. Possibly could not read input. Ensure it's connected properly and detected.
2022-04-17 10:43:18,223 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 49: invalid start byte
2022-04-17 10:43:18,224 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 49: invalid start byte
2022-04-17 10:43:24,290 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 34: invalid start byte
2022-04-17 10:43:24,290 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 34: invalid start byte
2022-04-17 10:43:30,224 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 28: invalid start byte
2022-04-17 10:43:30,225 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 28: invalid start byte
2022-04-17 10:43:36,257 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 25: invalid start byte
2022-04-17 10:43:36,258 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 25: invalid start byte
2022-04-17 10:43:39,272 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 18: invalid start byte
2022-04-17 10:43:39,272 - ERROR - mycodo.inputs.atlas_co2_a63ffe4f - Sensor read unsuccessful: 'utf-8' codec can't decode byte 0xff in position 18: invalid start byte
2022-04-17 10:43:54,236 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 17: invalid start byte

What would you recommend trying next? I am now thinking it is a software issue, because I have been using this sensor for the last 3 months and there were sometimes errors like this one, but not as many. But since my previous wiring was quite poor and I had faulty readings because of that, I can’t be sure.

Thank you for any suggestions!


I don’t see timestamps on the return measurements, so I can only assume (I see the code, so I’m not assuming) it’s running in a loop, sequentially one device after another (instead of threaded like Mycodo) and there is a significantly longer period between measurements than 1.5 seconds.

For any device issue, you need to isolate that device, meaning physically removing every other component from the system so you are running that device and only that device. Make the wires as short as possible (I2C was not meant to be run on wires, hence why I2C extenders like the LTC4311 was created). Only then can you gain any real understanding of what the issue is. Having 10 devices connected introduces too many variables to ever know what is happening. Only after having isolated the device, should you begin to start adding one variable back at a time.

Furthermore, I see many breadboards in your setup. Atlas Scientific recommends to not use breadboards for their products because they introduce faulty connections. Breadboard connections also degrade over time, so it tracks that you would start to see more issues occur over time. The software hasn’t changed in 3 months, but your connections likely have.

I have an idea that may or may not improve reliability. We can lock the use of each bus to only allow one Atlas device to be measured at any given time on that bus. If you wan to test this, change these lines:

To this:

        self.lock_file = f'/var/lock/atlas_{__name__.replace(".", "_")}_{i2c_bus}.lock'

Save, reboot.

This will exclude the threading variable, since now all devices on any bus will be read sequentially, even though they are running in separate threads.

@KyleGabriel

I ran the test again after disabling Mycodo’s polling of the Humidity and CO2 sensors on the Inputs page. Polling was at five second intervals for ten minutes and change, so it was roughly 120 readings. There were some errors with the EZO-HUM, but none with the EZO-CO2. I just re-ran the script at the default polling of 1.5 seconds for a couple of minutes and had no reported errors.

My sensors are connected via terminal blocks the only other I2C device on the bus is the display. I haven’t changed anything since the original errors.

The errors are fewer, but still happening.

2022-04-19 10:21:23,133 - DEBUG - mycodo.devices.atlas_scientific_i2c_105_1 - AtlasScientificI2C raised an exception when taking a reading: 'utf-8' codec can't decode byte 0xff in position 27: invalid start byte

There aren’t a whole lot of Google hits (in fact, this thread is one of the top ones). It just feels like it’s an error in AtlasScientificI2C and not actually in Mycodo. Is there a way to see what’s actually being sent to AtlasScientificI2C? Perhaps it’s an issue with that data being mangled when Mycodo tries to access both sensors at the same time (which your updated code might fix).

Does that code require separate I2C busses?