aneuk aneuk - 1 year ago 203
C Question

Connecting two sensors dht11 and dht22 the same nodemcu module esp-12e

I have a project where I'need connect two sensors the DHT11 and DHT22 to module nodemcu esp-12e.
Is there any way to use the two sensors in the same module at the same time?

Answer Source

If you want an implementation example use steps below:

  • Get DHT library from

  • Use the code snippet below, but do not forget to set your pins :

    #include "DHT.h"
    #define DHT11PIN 2
    #define DHT22PIN 3
    DHT dht11(DHT11PIN, DHT11 );
    DHT dht22(DHT22PIN, DHT22 );
    void setup() {
      Serial.println("DHTxx test!");
    void loop() {
      float h11 = dht11.readHumidity();
      float t11 = dht11.readTemperature();
      float f11 = dht11.readTemperature(true);
      float h22 = dht22.readHumidity();
      float t22 = dht22.readTemperature();
      float f22 = dht22.readTemperature(true);
      //do print them..
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download