0

I've got a CJMCU-8128 board with CCS811 + HDC1080 + BMP280 sensors.

enter image description here

There is an explanation how to wire it here: https://www.strawdogs.co/2018/07/Using-the-CJMCU-8128-Breakout-Environment-Sensor-Board/

And a repo with different python modules here: https://github.com/OdinsHat/cjmcu-8128-sensor-breakout

My problem is, that only the HDC1000 sensor works for me.

i2cdetect detects devices at 40, 5a and 76 just like in the blog post. Running testHDC1000.py gives me (probably correct) temperature and humidity values.

But when I run ccs811.py I get on the first run:

Traceback (most recent call last):
  File "ccs811.py", line 40, in <module>
    ccs811example()
  File "ccs811.py", line 13, in ccs811example
    c02, tvoc, temp = getdata()
  File "ccs811.py", line 20, in getdata
    temp = ccs.calculateTemperature()
  File "/home/pi/.local/lib/python2.7/site-packages/Adafruit_CCS811/Adafruit_CCS811.py", line 185, in calculateTemperature
    rntc = (float(vrntc) * float(CCS811_REF_RESISTOR) / float(vref) )
ZeroDivisionError: float division by zero

and on any further run:

Traceback (most recent call last):
  File "ccs811.py", line 40, in <module>
    ccs811example()
  File "ccs811.py", line 13, in ccs811example
    c02, tvoc, temp = getdata()
  File "ccs811.py", line 19, in getdata
    ccs = Adafruit_CCS811()
  File "/home/pi/.local/lib/python2.7/site-packages/Adafruit_CCS811/Adafruit_CCS811.py", line 92, in __init__
    raise Exception("Device returned an Error! Try removing and reapplying power to the device and running the code again.")
Exception: Device returned an Error! Try removing and reapplying power to the device and running the code again.

until I disconnect and reconnect the sensor. Then I get the division by zero error on the first run again.

Running bme280.py I get this error:

Traceback (most recent call last):
  File "bme280.py", line 44, in <module>
    bme280example()
  File "bme280.py", line 11, in bme280example
    (temp, pressure, humidity) = getdata()
  File "bme280.py", line 27, in getdata
    degrees = sensor.read_temperature()
  File "/home/pi/.local/lib/python2.7/site-packages/Adafruit_BME280.py", line 215, in read_temperature
    UT = float(self.read_raw_temp())
  File "/home/pi/.local/lib/python2.7/site-packages/Adafruit_BME280.py", line 194, in read_raw_temp
    self.BME280Data = self._device.readList(BME280_REGISTER_DATA, 8)
  File "/home/pi/.local/lib/python2.7/site-packages/Adafruit_GPIO/I2C.py", line 136, in readList
    results = self._bus.read_i2c_block_data(self._address, register, length)
  File "/home/pi/.local/lib/python2.7/site-packages/Adafruit_PureIO/smbus.py", line 216, in read_i2c_block_data
    cmdstring[i] = val
TypeError: one character string expected

I've read some (german) blogpost that says I should replace the line with cmdstring[i] = str(val), but this does not help either.

12
  • 1
    Your I2C communication might not be reliable, especially if you from time to time gets the "I/O Error #121". So Both CCS811 and BME280 are making trouble. You might like to lower I2C speed (only if you are using Rpi4B) to 50kHz for a more reliable performance. There are other tricks such as removing all other I2C devices, AND removing all pull up resistors of every I2C modules. You might like to read App A of my answer to the following more troubleshooting suggestions: "Rpi BMP180 problem": stackoverflow.com/questions/60274562/…. Cheers. – tlfong01 May 19 '20 at 1:31
  • 1
    I already lowered the speed to 10000 baud according to this Adafruit howto for the CCS811. I am using a Pi 3B and this combined module is the only sensor that is connected to the pi. Things I could try: 1) lower the baud rate even more (I am not sure if this should work) 2) Use 5V power instead of 3,3. – allo May 19 '20 at 11:02
  • 1
    thank you for your clarification. Your 3 in 1 module is a bit completed. Let me read the datasheet and user guide to get a better, and then come back you. It might take me a couple of days. But first some quick comments. (1) If i2cdetect -y 1 can detect all 3 devices's addresses, then it is 90% sure that I2C hardware wiring and software setup are more or less OK. It is 90% unlikely that the problem will disappear even if you improve I/O performance by lowering speed, shift 3V3 signal to 5V, shorter wiring, removing other devices, removing module pull ups. – tlfong01 May 19 '20 at 13:15
  • 1
    (2) I think the problem is in software: (a) AdaFruit software might be out of date and not compatible for newer Rpi hardware and/or software (not an uncommon thing), (b) especially you are using their Ciccuit Python, which I know if not very Rpi compatible. – tlfong01 May 19 '20 at 13:16
  • 1
    The three devices in the 3 in 1 module are common things. Perhaps we can try NOT to use AdaFruit software, but other open hardware vendor's tutorials and see there is any luck. Let me draft something as the research part of a tentative answers. As I said, might take a couple of days. – tlfong01 May 19 '20 at 13:19
1

I can't comment as I haven't got the reputation points yet. But I noticed you're running Python 2.7 and most of the Adafruit libraries require Python 3.

check with

sudo python --version

then

sudo apt-get install -y python3 git python3-pip
sudo update-alternatives --install /usr/bin/python python $(which python2) 1
sudo update-alternatives --install /usr/bin/python python $(which python3) 2

and then

sudo update-alternatives --config python

just to confirm that py3 is now your default, and you can check again with..

sudo python --version 

with that said...I did this and I'm not even getting as far as you and haven't been able to find a datasheet like the CCS811 which I feel comfortable enough reverse engineering to suit my needs but I'm nearly tempted to just put this down as a learning expense and go buy the CCS811 (which is what I wanted in the first place).

0

Regarding the problem with the BME280...don’t replace

cmdstring[i] = val

with

cmdstring[i] = str(val)

but with

cmdstring[i] = chr(val)

That worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.