How do I use more than one DHT sensor with Blynk?

These sensors are slow… and both are pulling from the same library, so I recommend staggering them much more, as well as giving each at least 2-3 seconds between reads… I am fairly certain that your temperature is NOT going to change at Hollywood disaster movie speeds :wink:

timer.setInterval(3000L, sendsensor1);
timer.setInterval(3500L, sendsensor2);

i tried different values on the timers. no difference. I am thinking of another idea. not sure how the code would work though.

Simply run the sensors and store values to SD card in separate process, then read the values from the SD card perhaps once every 15min and virtual write to “blynk”. i really do not need “realtime” sensor data to be pushed to blynk.

the original code i made definitely does not work with more than one sensor, perhaps a sensor issue, perhaps a blynk library issue, perhaps my code is not good… but i dont seem to find a solution and it seems no one else have made code like this before (strange, since i would see many applications to read from multiple DHT type sensors)

Well, since Blynk has no control over these sensors or their library, it is one of the remaining options :stuck_out_tongue:

Not that strange… these are not that great of a sensor anymore… for multiple sensors at a time, the OneWire DS18B20 seems to be a better way to go.

What have you ended up with for latest code so far?

@newbee112 OK, I took your originally posted code for the Blynk version… modded only as necessary for my Mega, as I am using an ESP-01 instead of Ethernet…

And it works just fine… no disconnections. Some occasional NAN issues, but that is just timing… these sensors don’t like to be pushed to fast.

So I don’t know… perhaps a conflict with the Ethernet shield or something? Those are well known to be flaky.

1st row is Humidity, 2nd is the Temp.

happy to see that my code is OK :slight_smile: and yes i think you are on to something… its probably something with the ethernet in combo of dth and blynk library… in the end perhaps due to timing… i am unable to locate my cc3000 wifi shield to test so for now i am stuck with the ethernet shield i got available.

great to know that the code is OK… today i abandoned the DTH sensors and went with onewire and some analog termistors and it works just like a charm.

tanks all for your support!

1 Like

Hi @Gunner , i´m having same issues as described with my nodemcu v2 on blynk.
Unable to read temp and humidity fron two identical dht22 sensors on blynk over wifi. Same code from original post. nan result for 1 sensor and stuck vale for the other.
thanks in advance

The original code was for an Arduino with an Ethernet shield. This won’t work with a NodeMCU.

I’d suggest that you create a new “need help with my project” topic and provide all the requested information, plus your actual code and details of how your sensors are wired.