-
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
Two SHT3X on I2C bus - feasible? #1949
Comments
As you have seen the implementation does not support this. It does support using multiplei2c sensors, but each must be of a different type. I have a few devices with BMP280 and HTU21 sensors to work around this issue. The standard firmware only supports a single DS18B20, but there is a special version that supports multiple. So, bottom line is that it is possible to support multiple sensors, look at the DS18x20 code for an example of how it can be done. |
OK, I modified the module to support two sensors before the last comment arrived, such that it works as previously with just one, but produces modified JSON and Web content for two. Because the processing model calls it in the expectation of it being a single sensor, for JSON and Web that's ok as it can just put the data from 2 devices into the same output. However, I'm not sure what would happen for Domoticz, which gets two temp/humidity calls - I don't use it so haven't tested that. Here's a JSON sample: tele/sonoff/0371/SENSOR = {"Time":"2018-02-19T13:08:50","SHT3X":[{"Address":"0x44","Temperature":19.8,"Humidity":49.3},{"Address":"0x45","Temperature":19.3,"Humidity":51.1}],"TempUnit":"C"} If this would be useful, I'm happy to set up a branch/pull request etc. for moderation etc. |
Currently domoticz support only allows one temp sensor. Considering the addition of the SHTC3 sensor I think the code needs to support up to three sensors at the same time. Will need a re-write with array filled with found sensor info like DHT driver. I, or someone else needs time to do it. |
That DHT code looks fairly similar to what I did, except it appears to set up multiple single-sensor JSON objects in mqtt_data, rather than my array-of-sensors JSON. I think it only calls Domoticz T/H once, for the first one. Using single JSON objects makes the code a lot simpler, I had checked for a valid read from each sensor and added an STH3X element for a sensor only when they were good. It wouldn't be too hard to make this work for all three, on the same basis. I'll have a go, and get back to you. Would we need to use the pre-tele-period call to pre-read the sensors, prior to the xxxShow call, as in the DHT code? They respond pretty quickly, unlike the DHTs, so there's no attempt to do so at the moment, but if there are 3 of them it could get a bit long. How long could a xxxShow call take before anything broke? |
Yes pls give it a go. Breaking is trial and error but I prefer to get the whole JSON string within 800mSec and that is with all sensors present. I normally test with Chrome Developer tools on the Ajax main page. |
With the way the addresses get tagged on the end(ie. "-0X44"), home assistant has json syntax errors with the way it reads the "-" is there another way to have the addresses show without it having the "-" |
Since the values are just JSON-encoded strings, I’d have thought it was a HA problem. I just used a separator value that I liked and seemed appropriate. IIRC, it started out as “_”, but that didn’t work for me! |
Ok that's good to know that " _ " didn't work for you because I just compiled it with using the "_". It compiled fine i just haven't flashed yet to test and see if was going to fix the problem. It does seem to be more of a HA bug than anything else, because HA does receive the mqtt statements just doenst like the way the addresses are tagged along. |
You might be just as well modifying the MQTT template, which means you wouldn't have to modify the code every time it gets released... |
I messed with modifying templates for hours and gave up on going that route. The only way I seem to make it work in HA is using " _ " as the divider between the addresses instead of the " - " |
I don't have/use HA, but was curious to see how to do this. Using JSFiddle to test extracting the value, I came up with this for the template: What did you try to make it work (that didn't)? |
I can extract and view the json value, but when using the .yaml HA uses and when adding the sensor in the configuration.yaml it gets upset and has syntax errors at the "-" when changing it to the underscore it no longer throws the syntax error in HA and all code works as usual, like multiple sensors with addresses. They just show up as SHT3X_0x44. Hope this is making sense. |
What is the yaml that you tried that is causing the issue? |
I have it posted up a couple previous post but here it is again:
What works when I have it change into the .ino also is
The value_template doesn't like having the - as the divider between name and address so it needs a different symbol as the divider. I used the template tool built into HA to see which symbols it doesn't throw errors and the underscore works. So then I tried to compile using arduino ide with the change to using the underscore. Compiled with no errors and flashed, with several days of testing everything works fine with it being the underscore. |
change it to this: this is the line I changed (from): To: |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem. |
5.12.0d * Add support for multiple SHT3X sensors (arendst#1949, arendst#2110)
I attached 2 pcs of SHT3X sensors with different addresses ({"I2CScan":"Device(s) found at 0x44 0x45"}) However on the web server and MQTT, I see only one of them (SHT3X-0x45 Temperature and SHT3X-0x45 Humidity) I use Tasmota, version 6.5.0 Do I need to change the settings and/or the code in order to be able to see both sensors? Best, Sava |
You shouldn't have to. I wanted it to detect 1-3 sensors on different I2C addresses, and AFAIK it does. I am still running 5.12 because it works and I didn't get around to doing anything else or different yet. There appear to have been various issues with multiple sensors of different types conflicting/not being picked up etc. in conjunction with SHT3X, but I haven't really studied it. |
It is interesting that I2CScan sees both devices but 2nd one is not visible on the web server and the MQTT. Any idea how I can debug the problem? |
Firstly, try each sensor separately - x44 and x45. Do you have other sensors of any sort connected? Try with/without. At least that gives you a clue... You should also be able to set the Log level to DEBUG, which should tell you if it found them in the initialisation phase. "The default logging for serial and weblog is 2 (syslog is disabled by default). It is set separately for each log destination. Log levels range from 0 to 4. The higher the log level, the more information is logged. When troubleshooting your device its recommended to set loglevel to 4." I agree it is curious that the I2CScan sees them, it might be worth checking out the code for that to see what it's doing that is different! Which I2CScan are you using? |
I want to connect 2 SHT3X temp/humidity sensors to a single ESP8266 on a single I2C bus, using separate I2C addresses (44 and 45). The devices with addresses set appropriately are detected and work fine individually. The SHT3X code currently only supports one device, but in principle I could modify it to support 2 on a single bus. Anyone aware of any a) existing efforts to do this b) potential gotchas, design/structural limitations beyond the SHT3X module itself? I was thinking of just looping against all the detected addresses and calling the appropriate MQTT/Web/Domoticz etc. routines, as it does now, adding a 0/1 indicator somewhere to each message for address 44/45.
Thanks for reading :-)
The text was updated successfully, but these errors were encountered: