Skip to content
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 Sensirion SHT4x I²C Temperature and Humidity sensor #4590

Closed
iz8mbw opened this issue Apr 5, 2023 · 29 comments · Fixed by #4625
Closed

Add Sensirion SHT4x I²C Temperature and Humidity sensor #4590

iz8mbw opened this issue Apr 5, 2023 · 29 comments · Fixed by #4625
Labels
Category: Plugin Related to supported sensors Type: Feature Request Add a completely new feature (e.g. controller/plugin)

Comments

@iz8mbw
Copy link
Contributor

iz8mbw commented Apr 5, 2023

@TD-er
Copy link
Member

TD-er commented Apr 5, 2023

Have you already tried if it may -by accident- work with the SHT1x or SHT3x plugins?

@TD-er TD-er added Category: Plugin Related to supported sensors Type: Feature Request Add a completely new feature (e.g. controller/plugin) labels Apr 5, 2023
@iz8mbw
Copy link
Contributor Author

iz8mbw commented Apr 5, 2023

No, but the library/driver of SHT4x seems to be different from SHT3x.

@tonhuisman
Copy link
Contributor

The same request was already posted in the forum, and it is on my local TODO list (though I haven't reserved a plugin ID for it yet), so no ETA.

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Apr 6, 2023

Yes, I see the first request to add this family of sensors is dated December 2021.
SHT4x is the fourth generation of these very good quality sensors.
I read there is not an ETA and not yet a reserved Plugin ID anyway I hope you will cover SHT4x very soon.
Thanks!

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Apr 9, 2023

A SHT41 sensor board should arrive soon and so I can help for testing.

@tonhuisman
Copy link
Contributor

I have reserved PluginID P153 for this plugin.

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Apr 10, 2023

Great!!!

@tonhuisman
Copy link
Contributor

@iz8mbw I've created a PR for this sensor series (SHT40/SHT41/SHT43/SHT45), available from this Actions run, once that's finished.
Please test, and report your findings here or in the PR conversation.

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Apr 23, 2023

Hi @tonhuisman many thanks.
For now cannot test yet since still waiting for shipment delivery.
I'll let you know when I receive the sensor.

@iz8mbw
Copy link
Contributor Author

iz8mbw commented May 9, 2023

Hi @tonhuisman I'm still waiting for delivery, I'll write you when I receive the SHT41 sensor and I'll test it.
Stay tuned.
Ciao!

@iz8mbw
Copy link
Contributor Author

iz8mbw commented May 28, 2023

Hi @tonhuisman.
Finally the SHT41 sensor was delivered and here my feedback during the test.
Using the default configuration like this:
image

I can read the sensors without any issues.

But I notices some problems depending on the configuration.
I have noticed if/when the sensor is not connected or there is an I/O Error (read error) ESPEasy return 0 °C and 0 % instead to return "nan".

About the "Heater" setting in "Startup Configuration", when I select it (all Heater combinations) the sensor reports a high temperature value and a low humidity value (ok this make sense due to Heater) but after that no more values are returned, so it hangs at:
image
so, to synthesize, if/when "Heater" is enabled in the setting "Startup Configuration" after the "Heater" command non more reading cannot be done also if I switch back from "Heater" to "High Resolution" (so if I disable the "Heater").
On the log I see:
image

About Resolution, the sensor works well at High Resolution (default), but there are some combinations between "Startup Configuration" and "Normal Configuration" that make sensor unreadable and on the log I have;
image

Here the combinations between "Startup Configuration" and "Normal Configuration" that generates the read errors SHT4x: READ CRC Error, data: 0xffffffffffff:

Startup Configuration: High / Normal Configuration: Low
Startup Configuration: High / Normal Configuration: Medium
Startup Configuration: Medium / Normal Configuration: Low

image

image

image

Many thanks!

@TD-er
Copy link
Member

TD-er commented May 28, 2023

But I notices some problems depending on the configuration.
I have noticed if/when the sensor is not connected or there is an I/O Error (read error) ESPEasy return 0 °C and 0 % instead to return "nan".

That's never done on any plugin as far as I can remember.
Thing is, when the PLUGIN_INIT fails, it will never set the output as PLUGIN_READ is never called.
You could uncheck "Check I2C devices when enabled" on the Tools->Advanced page, as this will at least not disable the task if the sensor is not found.
But that might cause a really slow responding ESP device as it constantly will try to access a not connected sensor.

@iz8mbw
Copy link
Contributor Author

iz8mbw commented May 28, 2023

For SHT3x (Plugin 068) sensor it works returning "nan" if for example I disconnect VCC or I2C signals (between the sensor and the ESP32) and on the log there is:
image

So for SHT3x (Plugin 068) there is some that recognize "read error" and so stop to provide values (since it returns "nan") and stop to send values to MQTT.
(I have "Check I2C devices when enabled" unchecked on all my ESP32 boards).

@tonhuisman
Copy link
Contributor

@iz8mbw
I'll have a look in what I can do about these issues.

How long is the wiring between the sensor and the ESP?

@iz8mbw
Copy link
Contributor Author

iz8mbw commented May 31, 2023

@tonhuisman 20 centimeters

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Jun 6, 2023

Hi @tonhuisman did you have time to give a look at the issues when Heater is enabled and when some combinations between "Startup Configuration" and "Normal Configuration" generates read errors?
Thanks.

@tonhuisman
Copy link
Contributor

No, I've been busy with a different project, sorry. Will pick it up soon, though.

@tonhuisman
Copy link
Contributor

@iz8mbw I've added PR #4698 to fix the checksum error issue when using the heater as a Startup configuration. Can you please test that once this GH Actions run is completed?

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Jun 10, 2023

Hi @tonhuisman just tested and it works very well!
Many thanks for the fix.
@TD-er you can merge #4698 into master,

Thanks!

@tonhuisman
Copy link
Contributor

tonhuisman commented Jun 10, 2023

@iz8mbw I've also tried to implement reporting NaN when an error occurs, like checksum error, read errors or command-sending errors. Available in this GH Actions run (same PR, one commit later then previous Actions run 😛)
For this to be able to work, the Tools/Advanced setting Check I2C devices when enabled must be disabled.

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Jun 10, 2023

@tonhuisman YES!!!! It works as expected! Now it returns NaN if I disconnect VCC to the sensor and/or if I disconnect SDA and/or SCL signals to the sensor.
Is it possible implement NaN when an error occurs also for HDC10xx Plugin? (see #4643).

Thanks!

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Jun 10, 2023

In my opinion reporting NaN when an error occurs (like read errors or command-sending errors) should be included by default on every sensor/plugin.
What I mean is that reading errors can happens and them should be recognised and managed.

@TD-er
Copy link
Member

TD-er commented Jun 10, 2023

I do agree, but.....
You have to realize there are lots and lots of installs out there which may have been running for years now and never had to deal with NaN values.
So making the behavior equal (and more logical) for all plugins may not be the best option here as you also have to deal with legacy installs.

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Jun 10, 2023

Sorry but if I have a 25 C of temperature and for some reason the I2C cable is cutted and ESPEasy reports 125 C of temperature (instead of 25 C) do you think it makes sense? Better NaN that let's the user understand that there is a problem instead to report a wrong (and no sense) value

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Jun 10, 2023

Also in Documentation can be specified that ESPEasy reports NaN in case of Read errors instead to reports no sense values such ss 0 C or 125 C or other no sense values

@TD-er
Copy link
Member

TD-er commented Jun 10, 2023

Like I said, it for sure makes sense to allow for proper error signalling.
But when a user has a working system with JSON parsing, such a setup may crash when it expects numerical values and in JSON a "NaN" isn't a numerical value.

Just as an example of what may happen on installed setups.

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Jun 10, 2023

I get your point and I want to add if NaN is reported then no values are sent to MQTT and for sure this is an advantage

@TD-er
Copy link
Member

TD-er commented Jun 10, 2023

We are already working on some more generic solution, but there are some caveats in implementing it right away for all.

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Jun 10, 2023

Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Plugin Related to supported sensors Type: Feature Request Add a completely new feature (e.g. controller/plugin)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants