Closed jptrsn closed 6 years ago
Change(in HTU21D.h file) line 125: bool begin(uint8_t sda = SDA, uint8_t scl = SCL);
->bool begin(uint8_t sda = 2, uint8_t scl = 14);
Define SDA as D4 and SCL ad D5. And leave myHTU21D.begin();
in .ino file.
Hi, jptrsn you got 255 value because of collisions on I2C bus. If master can't get the value from sensor it throws the code 255. Don't use D6 for I2C. D6 is for SPI bus. Default I2C pins are D2 & D1. Also arduino esp8266 I2C driver is very glitchy. Try my - https://github.com/enjoyneering/ESP8266-I2C-Driver It works better with none standard I2C pins.
bfaliszek, hardcoded variables is bad practice. Plus you are breaking compatibility - official/default I2C pins are D2 & D1.
I'm using this library on ESP8266 processors. It was previously working properly, but it is now reporting temperature and humidity at 255. I've verified the sensor works using an Arduino Nano, and the same demo example. The only difference between the two is the pins used (I'm using D4 and D5 for SDA and SCL on a Wemos D1 mini).
Here's what I've changed in the example:
(myHTU21D.begin(D4,D5) != true)