Gravity NO2 Sensor not working on Raspberry Pi
Hello,
I am trying to use an Gravity NO2 sensor on my Raspberry Pi Zero W. I followed the instructions here:
https://github.com/DFRobot/DFRobot_MultiGasSensor/tree/main/python/raspberrypi
to no avail. The sensor is connected correctly to the 5V, GND, SDA and SCL pins of the Raspberry Pis GPIO. I can see that it is correct because it is recognized by i2cdetect -y 1 with the i2c address 74. This is also set on the board (SEL = 0, A0 = 0 and A1 = 0) as well as in the example script initiativereport.py (I2C_ADDRESS = 0x74 and I2C_1 = 0x01).
For debugging purposes I also added some print commands to see where the code is while running. I can see that it runs through the setup() section successfully. The problem arises when the script tries to read data. In the “loop()” function, it is not entering the if-statement so no data is plotted into the console. I can leave this running for hours with no change.
Because the sensor is recognized by the RasPi and the Setup of setting the acquire_mode seems to work I wonder where the problem is. Using any Arduino and the recommended library plus one of the example script it works fine. So the sensor is working, the RasPi is working. I suspect a software error somewhere within the functions.
On a side note: When starting the script the first time right after downloading/cloning the github repo, python tells me that it can't find “logging”. It is not imported within DFRobot_MultiGasSensor.py. When I add import logging this error goes away. Might this have something to do with the problem? That pythons own logging library is not working in this case and instead a different one is supposed to be used?
Hi,
I just tested it on a Raspberry Pi 3 and a complete fresh install on a Raspberry Pi 4, but have always the same outcome. The setup (gas.change_acquire_mode) works and then I don't get any data cause it is not entering the if-statement. There has to be some flaw with the code, I can't find another explanation.
Kjell.zum BergeHi! We have modified the library so you can use the latest Raspberry Pi code. It is recommended to install the logging library. (The library used in the picture is python3)
Hi! We only tested on RaspberryPi4 and it works. Sorry, we have not tested with other versions of Raspberry Pi.
jenna