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

Improved sensor readings in htu21d component. #5839

Merged
merged 3 commits into from
Dec 22, 2023

Conversation

matzman666
Copy link
Contributor

@matzman666 matzman666 commented Nov 26, 2023

What does this implement/fix?

Made sensor readings asyncronous using set_timeout() and deleted any delay() call. This removes the warning that "Component htu21d took a long time for an operation".

Furthermore I increased the delay when reading the temperature from the sensor because the original delay was 50ms but according to datasheet the sht21 sensor can take up to 85 ms when reading the temperature.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other

Related issue or feature (if applicable):

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040
  • BK72xx
  • RTL87xx

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

@jesserockz jesserockz added this to the 2023.12.3 milestone Dec 22, 2023
@jesserockz jesserockz merged commit 676ae6b into esphome:dev Dec 22, 2023
44 checks passed
@jesserockz jesserockz mentioned this pull request Dec 22, 2023
@xxVDRxx
Copy link

xxVDRxx commented Dec 23, 2023

after update to 2023.12.3 my htu-21 doesn`t read humidity
image

@matzman666
Copy link
Contributor Author

Ok, this is strange. The code reading the humidity is exactly the same code as before with the only difference that its execution is now scheduled using set_timeout() instead of blocking the main loop.

Another change is that I increased the wait time between starting the temperature measurement and reading the result, but why should that affect the humidity measurement?

The new code has been tested using a sht21 sensor and everything was working as it should. I couldn't test with a htu21d sensor since I don't have one, but in theory it should behave the same as a sht21 (except of having different measurement delays).

What does esphome's log say?

@xxVDRxx
Copy link

xxVDRxx commented Dec 24, 2023

htu-21 working ok, I dont know what happened but I have a new entity for humidity. I use MQTT. Dont have time today to analize this but it`s look like that:
image

sensor.sypialnia_htu21d_sypialnia_wilgotnosc is new entity... strange... i didn`t change config etc, only upgrade esphome and upgrade a node via ota.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants