There are other binary sensors and switches connected to MCP23017 and they work fine. What am I doing wrong? i get these error messages.
[15:52:45][W][dht:156]: Waiting for DHT communication to clear failed!
[15:52:45][W][dht:060]: Invalid readings! Please check your wiring (pull-up resistor, pin number).
It looks like you’ve entered the wrong address. Are you sure this is correct?
Besides, I’m not sure if you can connect any sensor via MCP23xxx. MCP is probably too slow for that.
The address is correct cos I got it from the i2c scan. If the code is correct then you may be right about the MCP not being able to handle it.
I do have other binary sensors (door and windows) and switches (relays) and they work perfectly fine.
Although I do have another binary sensor (doorbell button) and that stays high all the time when using the MCP, but it works perfectly fine when connected to ESP8266 pins. Not sure what is going on here either.
Why would you want to connect DHT via MCP ? (just wondering)? I think that MCP is too slow for it, too. And, while code may be “officially” correct, it’s a question whether program really search on MCP pins for DHT. I’d say that code for DHT is written in a way that automatically looks at I2C pins…
Connect it parallel to I2C, together with MCP. I have connected in parallel:
MCP23017
BME280
SHT31 (all I2C)
DS1820 on separate pin
All work perfectly. Just make sure that addresses on I2C are different, that’s all.
no real reason, just wanted to consolidate all the sensors to the MCP. anyways i moved over the DHT and doorbell button to ESP pins and it all works good. i guess the MCP is good just for your basic door/windows sensors and running some relays.
one more thing i noticed is that if i power the MCP with 3.3V, the piezo buzzer doesn’t work since the output voltage is arnd 2.64V. so you have to power the MCP with 5V.
How about friend, could you help me with a diagram and explain to me what it means to connect it parallel to I2C together with MCP. Thank you very much in advance for the response
There’s nothing much in it: just connect all sensors in parallel: all SDA lines to one pin of esp, all SCL lines to another pin of esp. ESP itself will recognize sensors via it’s address - just make sure that addresses of sensors are not the same - you can find I2C address in sensor’s datasheet.
Usually, different sensors have different i2c addresses, and most of them allow (at least) two addresses to be set, usually via solder pads. In case you want to use two same kind of sensors (say, two BME280, or two SHT31…) you must change address of second sensor (again: read sensor’s datasheet)