Closed michalszymura closed 4 years ago
Same problem. ESP32 D1 R32
Tested at 2 board and 3 sensor 2 different port set. Add to the test a TSL2561 at same port.
[14:06:32][C][i2c:028]: I2C Bus: [14:06:32][C][i2c:029]: SDA Pin: GPIO25 [14:06:32][C][i2c:030]: SCL Pin: GPIO17 [14:06:32][C][i2c:031]: Frequency: 50000 Hz [14:06:32][I][i2c:033]: Scanning i2c bus for active devices... [14:06:32][I][i2c:040]: Found i2c device at address 0x39 [14:06:32][I][i2c:040]: Found i2c device at address 0x40 ...
[14:06:32][C][tsl2561:040]: Unit of Measurement: 'lx' [14:06:32][C][tsl2561:040]: Accuracy Decimals: 1
[14:06:32][C][tsl2561:041]: Address: 0x39 [14:06:32][C][tsl2561:048]: Gain: 1x [14:06:32][C][tsl2561:049]: Integration Time: 402.0 ms [14:06:32][C][tsl2561:051]: Update Interval: 10.0s
[14:06:32][C][hdc1080:029]: Address: 0x40 [14:06:32][E][hdc1080:031]: Communication with HDC1080 failed! [14:06:32][C][hdc1080:033]: Update Interval: 5.0s
[14:06:32][C][hdc1080:034]: Unit of Measurement: '°C' [14:06:32][C][hdc1080:034]: Accuracy Decimals: 1
[14:06:32][C][hdc1080:035]: Unit of Measurement: '%' [14:06:32][C][hdc1080:035]: Accuracy Decimals: 0
TSL2561 working:
[14:06:36][D][sensor:092]: 'TSL2561 Ambient Light': Sending state 17.97440 lx with 1 decimals of accuracy [14:06:46][D][tsl2561:126]: Got illuminance=18.0lx
During the compile, there is a warning, when VERY_VERBOSE loggin is set.
Compiling .pioenvs/dolgozo/FrameworkArduino/esp32-hal-i2c.c.o /home/t/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-i2c.c: In function 'i2cDumpFifo': /home/t/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-i2c.c:415:35: warning: ' ' flag used with '%X' gnu_printf format [-Wformat=] } else k += sprintf(&buf[k],"% 4X ",fifoBuffer[i]); ^ /home/t/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-i2c.c:415:35: warning: ' ' flag used with '%X' gnu_printf format [-Wformat=]
Similar error message here: https://github.com/esphome/issues/issues/217
Therefore it can not debug.
After upgrading to bleeding edge version. https://beta.esphome.io/guides/faq.html?highlight=beta#how-do-i-use-the-latest-bleeding-edge-version
Now I can debug.
[I][app:028]: Running through setup()... [V][app:029]: Sorting components by setup priority... [V][esp32-hal-i2c.c:1483] i2cInit(): num=0 sda=25 scl=17 freq=0 [V][esp32-hal-i2c.c:1677] i2cSetFrequency(): freq=100000Hz [V][esp32-hal-i2c.c:1692] i2cSetFrequency(): cpu Freq=240Mhz, i2c Freq=100000Hz [V][esp32-hal-i2c.c:1698] i2cSetFrequency(): Fifo delta=1 [V][esp32-hal-i2c.c:1677] i2cSetFrequency(): freq=50000Hz [V][esp32-hal-i2c.c:1692] i2cSetFrequency(): cpu Freq=240Mhz, i2c Freq=50000Hz [V][esp32-hal-i2c.c:1698] i2cSetFrequency(): Fifo delta=1 [C][hdc1080:015]: Setting up HDC1080... [VV][i2c:056]: Beginning Transmission to 0x40: [VV][i2c:093]: Writing 0b00000010 (0x02) [VV][i2c:093]: Writing 0b00000000 (0x00) [VV][i2c:093]: Writing 0b00000000 (0x00) [VV][i2c:061]: Transmission ended. Status code: 0x00 [E][component:092]: Component was marked as failed.
http://www.ti.com/lit/ds/symlink/hdc1080.pdf According the datasheet commands is ok, but still not working.
Solution: /usr/lib/python2.7/site-packages/esphome/components/hdc1080/hdc1080.cpp
There is an HDC1080Component::setup function.
if (this->write_bytes(HDC1080_CMD_CONFIGURATION, data, 2)) { this->mark_failed(); return; }
I suppose this->write_bytes (i2c memory write) return 1 if OK and return 0 at ERROR. If you negate this statement, the result will be ok.
Changed code:
void HDC1080Component::setup() { ESP_LOGCONFIG(TAG, "Setting up HDC1080...");
const uint8_t data[2] = { 0b00000000, // resolution 14bit for both humidity and temperature 0b00000000 // reserved };
if (!this->write_bytes(HDC1080_CMD_CONFIGURATION, data, 2)) { this->mark_failed(); return; } }
Result in my environment: [VV][i2c:056]: Beginning Transmission to 0x40: [VV][i2c:093]: Writing 0b00000001 (0x01) [VV][i2c:061]: Transmission ended. Status code: 0x00 [VV][i2c:083]: Requesting 2 bytes from 0x40: [VV][i2c:126]: Received 0b1000000110110000 (0x81B0) [V][sensor:013]: 'Living Room Pressure': Received new state 50.659184 [D][sensor:092]: 'Living Room Pressure': Sending state 50.65918 % with 0 decimals of accuracy [D][hdc1080:054]: Got temperature=27.8°C humidity=50.7%
There is some other i2c sensor esphome. For example TSL2561.
Is checked tsl2561.cpp.
if (!this->tsl2561_read_byte(TSL2561_REGISTER_TIMING, &timing)) { this->mark_failed(); return; }
As I see here, need to be an negation (!). :)
To solve the problem you doesn't need bleeding edge version. I used it only for debugging.
Hello Hsxsky, Is there a way to apply fix this for those of us who use the hassio plugin? Thanks
Hello Hsxsky, Is there a way to apply fix this for those of us who use the hassio plugin? Thanks
@Hsxsky @xppx99 Did you find a way to make the code changes when running hassio?
Hello @larsenglund and @xppx99,
As I see the modification is merged to the development (bleeding edge) version. You can change to that version in the Hass.io add-on repository.
Manual is here for developer version: https://next.esphome.io/
@Hsxsky Awesome, it's working now, thanks!
Has been fixed in 1.14, closing.
Operating environment/Installation (Hass.io/Docker/pip/etc.):
Hass.io ESP (ESP32/ESP8266, Board/Sonoff):
ESP8266 Affected component:
https://esphome.io/components/sensor/hdc1080.html https://esphome.io/components/sensor/htu21d.html Description of problem: Sensors are seen by the I2C scan, but communication with sensors fail. (tested one at a time since they have the same address). I2C display works without any problems.
Problem-relevant YAML-configuration entries:
Logs (if applicable):
Additional information and things you've tried: Tried on 3 ESP8266 boards. Tried sensors one at a time. I2C display works fine. Tried different I2C speeds and pins. Sensors work fine on the same ESP with arduino sketch.