Comments (9)
Thanks for reporting this too 👍
Oh... I forgot to initialize the HTU21D pointers here 🤕. (I don't have this sensor yet so I can't really test it; that's also why it's marked as experimental in the docs)
from esphome-core.
Thanks again. I'll test htu21d for you :)
I have some esp32's around that I also can test.
from esphome-core.
After successfully connecting wifi (using alphanumeric psk) I got some progress on the htu21d.
I tested with Adafruit HTU21D library example first to verify, and it works.
I'm a little unsure what pins you are asking to define. Is it gpio-number (e.g 5 and 4 for NodeMCU) or pin-number (e.g D2 and D1 for NodeMCU). Must this be specified? What about defaulting to boards i2c-pins.
Here's serial log output. I can see the htu21d is connected, first temperature reading is always 128,9C. After that NaN on both temperature and humidity.
[C][sensor::htu21d:setup:55]: Setting up HTU21D...
[C][component:setup_:126]: Update interval: 15000ms
[C][sensor::mqtt:setup:30]: Setting up MQTT Sensor 'HTU21D Temperature'
[C][sensor::mqtt:setup:32]: Expire After: 450s
[C][sensor::mqtt:setup:33]: Unit of Measurement: '°C'
[C][sensor::mqtt:setup:34]: Accuracy Decimals: 0
[C][sensor::mqtt:setup:35]: Icon: ''
[C][sensor::mqtt:setup:36]: # Filters: 1
[C][sensor::mqtt:setup:30]: Setting up MQTT Sensor 'HTU21D Humidity'
[C][sensor::mqtt:setup:32]: Expire After: 450s
[C][sensor::mqtt:setup:33]: Unit of Measurement: '%'
[C][sensor::mqtt:setup:34]: Accuracy Decimals: 0
[C][sensor::mqtt:setup:35]: Icon: 'mdi:water-percent'
[C][sensor::mqtt:setup:36]: # Filters: 1
[I][application:loop:50]: Running through first loop()
[I][application:loop:59]: First loop finished successfully!
[D][sensor::htu21d:update:68]: Got Temperature=128.9°C Humidity=nan%
[W][sensor::htu21d:update:78]: Invalid Humidity: nan%
[D][sensor::htu21d:update:68]: Got Temperature=nan°C Humidity=nan%
[W][sensor::htu21d:update:73]: Invalid Temperature: nan!C
[W][sensor::htu21d:update:78]: Invalid Humidity: nan%
from esphome-core.
Also tested on the ESP32. I defined pins 21 SDA and 22 SCL which is the boards default.
Code is identical to what I used for the 8266, except sda/scl pins.
Failed the connection to htu21d. See output.
[C][ota:setup:22]: Setting up OTA...
[C][ota:setup:23]: port: 3232
[C][ota:setup:28]: hostname: 'testhtu21d'
[C][sensor::htu21d:setup:55]: Setting up HTU21D...
[E][esp32-hal-i2c.c:161] i2cWrite(): Busy Timeout! Addr: 40
[E][esp32-hal-i2c.c:161] i2cWrite(): Busy Timeout! Addr: 40
[E][esp32-hal-i2c.c:161] i2cWrite(): Busy Timeout! Addr: 40
[E][sensor::htu21d:setup:60]: Connection to HTU21D failed.
[C][component:setup_:126]: Update interval: 15000ms
[C][sensor::mqtt:setup:30]: Setting up MQTT Sensor 'HTU21D Temperature'
[C][sensor::mqtt:setup:32]: Expire After: 450s
[C][sensor::mqtt:setup:33]: Unit of Measurement: '°C'
[C][sensor::mqtt:setup:34]: Accuracy Decimals: 0
[C][sensor::mqtt:setup:35]: Icon: ''
[C][sensor::mqtt:setup:36]: # Filters: 1
[C][sensor::mqtt:setup:30]: Setting up MQTT Sensor 'HTU21D Humidity'
[C][sensor::mqtt:setup:32]: Expire After: 450s
[C][sensor::mqtt:setup:33]: Unit of Measurement: '%'
[C][sensor::mqtt:setup:34]: Accuracy Decimals: 0
[C][sensor::mqtt:setup:35]: Icon: 'mdi:water-percent'
[C][sensor::mqtt:setup:36]: # Filters: 1
[I][application:loop:50]: Running through first loop()
[I][application:loop:59]: First loop finished successfully!
[E][esp32-hal-i2c.c:161] i2cWrite(): Busy Timeout! Addr: 40
[E][esp32-hal-i2c.c:161] i2cWrite(): Busy Timeout! Addr: 40
[E][esp32-hal-i2c.c:161] i2cWrite(): Busy Timeout! Addr: 40
[E][esp32-hal-i2c.c:161] i2cWrite(): Busy Timeout! Addr: 40
[D][sensor::htu21d:update:68]: Got Temperature=nan°C Humidity=nan%
[W][sensor::htu21d:update:73]: Invalid Temperature: nan!C
[W][sensor::htu21d:update:78]: Invalid Humidity: nan%
from esphome-core.
I'm a little unsure what pins you are asking to define. Is it gpio-number (e.g 5 and 4 for NodeMCU) or pin-number (e.g D2 and D1 for NodeMCU). Must this be specified? What about defaulting to boards i2c-pins.
esphomelib uses the GPIO pin numbers (i.e. 5 & 4) everywhere. Because of the magic of esphomelib (or to be more precise the arduino framework), you can type the following 🤓
App.init_i2c(D2, D1);
# equivalent to:
App.init_i2c(4, 5);
I'm not a huge user of the ESP8266 myself, but are D2 and D1 really always the default i2c pins on all boards? If not, I'd rather have users type out the full pin numbers instead of some users needing to debug the code because their board uses different default i2c pins...
Re HTU21D "Connection to HTU21D failed.": Hmmm, I don't know what could be going wrong here. I mean I'm just using an existing library (i2cdevlib) for getting the sensor values here and I'd hope that that library works...
Anyway, I think there might have been another issue in my own code (but I kind of doubt it). Otherwise I think I'll just re-write the library myself as I just did with the DS18b20 sensors (ended up making those sensors much more stable). The quality of the 3rd party libraries I've been using apparently seems to not be too good :/
from esphome-core.
The htu21d says connected on esp8266, but fails to connect on the esp32.
As for default pins, all pinout diagrams etc and papers i have read says that esp12-chip uses gpio 4 and 5 (d1 and d2 on nodemcu/wemos etc). for i2c, and 21 and 22 on the esp32-chip. This can be changed, but unless defined somewhere, it will use these default pins. That's my understanding, don't take my word for it 😆
from esphome-core.
Well, at least some progress 😺
That's really weird that it would only work on one board... I'll try my BMP180 (also i2c-based) on the ESP32 again too to maybe gain some more insight. And looking at the pin definitions, you're right that the SDA and SCL pins are well defined, I will put it in the code; thanks very much 👍
from esphome-core.
Oh well, I just found the esp8266 thing board uses different SDA/SCL pins :/
With some C++/C macro magic that shouldn't be a problem though 😀
from esphome-core.
Ok, I think the issue should now be fixed with the sensor rewrite/refactor in 1.3.0. Closing this issue...
from esphome-core.
Related Issues (20)
- Auto-load esphome component upon discovery by Home Assistant HOT 10
- esp32_ble_tracker scan_interval not used correctly HOT 1
- Firmware seems to have watchdog issues for esp32_ble_tracker HOT 1
- PMSx003 does not work
- MQ-2 Sensor. HOT 5
- [RGB Light Platform] Remember brightness and color after restart HOT 5
- Error in HA since 0.86 HOT 1
- DO NOT POST ISSUES HERE
- ESP32 goes to boot loops with option exrire_after HOT 1
- Error OTA update ESP8266 12e HOT 2
- MIC sensor, status fast change HOT 1
- esphomeyaml showing terminated process HOT 1
- esp32 access point not enabled HOT 1
- Update Failed: ERROR[8]: Flash config wrong real: 4194304 IDE: 16777216 HOT 1
- Returning NAN when using id.value HOT 1
- esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header HOT 1
- Ok, now I understand, so you want to have all three units show up as sensor at the same time. HOT 2
- witty cloud with LDR and RGB HOT 2
- Cannot connect to hidden SSID HOT 1
- ERROR Error binary size: Error: ESP has been flashed with wrong flash size. Please choose the correct 'board' option (esp01_1m always works) and then flash over USB. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esphome-core.