-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for SGP41 TVOC/NOx Sensor #18880
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR. It's unfortunate that the official lib does delay()
in the code which has very bad effect on the rest of Tasmota. If each sensor lib did the same, devices with multiple sensors could become unusable.
Hey @s-hadinger I've managed to split out most of the functions so far. I used the 50ms function to send the I ran a logic analyzer to trace what was happening, and it seems at some random point, the SGP41 seems to respond with a I'm still learning I2C, but wanted to check if this was behavior you've seen before. I'll keep troubleshooting, but it's very strange behavior. Thanks! |
Thanks, I'm not familiar enough with I2C but this doesn't seem familiar |
The SGP41 board I bought had a pull-up resistor for SDA and SCL, which I'm sure was causing the issue. The ESP8266 already has an internal I2C pull-up, so having 2 in parallel is not good. I cut the traces to it on my SGP41 board and so far it's been stable. Once I know it's stable, I'll update my PR with the new code :) |
fc0ef41
to
9428cc6
Compare
Alright, I got it @s-hadinger . I've had this driver running for a while and it's running nicely. I removed the I've also found a clever way of testing for an SGP40 vs SGP41, so I'm going to work on that next. The drivers are nearly identical, except for one function that SGP40 uses differently. This should allow for a universal SGP4x driver, without the need to manually handle drivers. This is the change I made to add the SGP40 detection in this driver, in case anyone wants to test it: precurse@f877b20 -- I'm confident it'll work, but need to be 100% sure before I PR it. |
Hey @s-hadinger , the SGP41 sensor has been running for quite a few days and working reliably. I just cleaned up some of the other Tasmota markdown files, JSON/web output to use i18n values, and confirmed the driver works on the ESP32 platform. I started to use SGP4X consistently throughout, which is the basis for the universal driver once I receive my SGP40 to confirm. Let me know if anything else needs to be fixed up! |
Thats weird. Since i2c is a bus it needs terminating. The internal pull up resistor of the esp8266 is so high that it is not enough to terminate the i2c bus correctly. AND it is no problem to have both active. |
@TD-er Do you have experience with the Sensirion SGP41? |
I thought the D1 Mini had an internal I2C pull-up, but may have been mistaken then. It's possible the SHT3X board I have soldered has an I2C pull-up as well, since I'm reading 10K ohms across VCC and SDA/SCL. |
Thats explains it. |
I don't, but @tonhuisman did adapt the code for the SGP4x/SGP41 sensor for ESPEasy quite recently.
|
Hi, |
Should simply be the standard |
I2C works fine on my ESP8266 devices, including NodeMCU dev boards. |
HI, I am using version "Program Version 13.1.0(sensors)" does it support sgp41 sensors? |
"No device found" start very bad |
I also suspect the hardware is faulty, I'm ordering another piece of hardware. Thank you |
Some tips for I2C:
|
As visible on the I2CDriver output, the driver number 82 is not included in the binary you're running, You need a custom build including |
Disable all other i2c drivers. See https://tasmota.github.io/docs/I2CDEVICES/#management |
Specifically the 69 driver (for the SGP40): I'm working at merging both SGP40 and SGP41 drivers together, so we can avoid having to do this. I just haven't got around to it quite yet :) |
Based on your suggestion I solved the problem, thank you very much |
I believe the driver is sending out the wrong value for Domoticz. I've configured the value of Sensor idx 9 AirQuality for Domoticz, but receive the raw sensor-value, which isn't of any use in Domoticz. Instead the "SGP40 Air quality" is needed. I believe the issue lines in the file xsns_109_sgp4x.ino lines 222 - 224, that state the wrong parameter for Domoticz. If I'm reading the source code correctly, the value needs to be the calculated voc_index_sgp4x. #ifdef USE_DOMOTICZ Could this me changed, or make all 3 values available for the SGP40 and 4 for the SGP41? |
* Initial support for SGP41 * Removing delay() use from SGP4x driver * Using i18n for TVOC/NOx raw values as well
Description:
This adds support for the SGP41 TVOC/NOx sensor and uses the official driver from Sensirion. I was hoping to merge this with the existing SGP40 driver, but it seems that this is non-trivial at this time.
Since this device uses the same I2C ID as the SGP40, it must be enabled with
i2cdriver 82
after disablingi2cdriver98 0
Related issue (if applicable): N/A
Checklist:
NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass