Home › Forums › The libraries hosted on the site › DHT12 complete library (Adafruit DHT clone) › Using DHT12 with alternate IO pins on ESP8266
Tagged: i2c, multiple device
- This topic has 6 replies, 1 voice, and was last updated 4 years, 6 months ago by
Dave C..
-
AuthorPosts
-
-
31 October 2020 at 07:28 #7474
Dave C.
I’m probably being really stupid here, I’ve got the I2C example working fine on my NodeMcu, perfect.
I need to use an alternative pair of IO pins (IO-0 and IO-2) with an ESP01, I’ve already got an I2C display working on those pins so I just want the DHT to run in parallel.
I just can’t work out how to persuade the DHT to work on the alternate pins, nothing clever.
I’ve looked at the examples and the .pdf file but I’m missing something as my attempts either won’t compile or simply fail to communicate with the DHT.
Thoughts please, multiple attemps with Mr Google haven’t really revealed the mystery.
-
31 October 2020 at 09:26 #7476
Hi Dave,
I think you don’t need to use alternate pins, you can connect more than one device to the same 2 pins, you must only put the a different address.
Usually there is one master and one or multiple slaves on the line, although there can be multiple masters, but we’ll talk about that later.
Both masters and slaves can transmit or receive data, therefore, a device can be in one of these four states: master transmit, master receive, slave transmit, slave receive.
You must pay attention only if you manage i2c with interrupt.
Tell me if this can be a solution.
Bye Renzo
-
31 October 2020 at 09:38 #7477
Dave C.
Hi Renzo. Yeah, I think I can run in parallel, my problem is that I need to use non-default IO pins.
The LCD is already running just fine on these pins but I can’t get the DHT to talk.
Like I said, I’m being stupid somewhere.
-
31 October 2020 at 10:04 #7479
Dave C.
It’s working fine using your example sketch and the default pins.
What do I need to do to the example to use other pins (IO-0 and IO-2)?
I’m really pretty new to this software game, still finding my way around stuff.
-
31 October 2020 at 10:09 #7480
Hehehhe,
no no, sorry, I did not understand, and I have not included examples that use pins different from the standard.
Instead of use this constructor
DHT12 dht12;
you can use this
DHT12 dht12(D1, D2);
and you can specify the alternati pins you want.
I think It’s what you need.
Bye Renzo
-
31 October 2020 at 10:31 #7481
Dave C.
Thanks I’ll try that and get back to you.
It’s 4.30 PM here in Thailand and it’s a celebration called Loy Kratong, got to take my good lady out to dinner.
-
31 October 2020 at 10:41 #7483
Dave C.
Perfect!!
I’m using this:
uint8_t sda = 0;
uint8_t scl = 2;
// Set dht12 i2c comunication on default Wire pin
DHT12 dht12(sda, scl);
Thanks very much for being kind to a noob.
-
-
AuthorPosts
- You must be logged in to reply to this topic.