Skip to content

Instantly share code, notes, and snippets.

@TrickSumo
Created April 17, 2019 16:35
Show Gist options
  • Save TrickSumo/f1aecd17972aa3b6c0668750c3309714 to your computer and use it in GitHub Desktop.
Save TrickSumo/f1aecd17972aa3b6c0668750c3309714 to your computer and use it in GitHub Desktop.
Interface DHT11 temperature sensor with NodeMCU ESP8266
/* By TrickSumo.com
Libraries used:-
https://github.com/adafruit/DHT-sensor-library
https://github.com/adafruit/DHT-sensor-library
*/
#include <DHT.h>
#define DHTTYPE DHT11
#define dht_dpin D1
DHT dht(dht_dpin, DHTTYPE);
void setup() {
dht.begin();
Serial.begin(9600);
Serial.println("Serial Communication Started\n");
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Humidity = ");
Serial.print(h);
Serial.print("\n ");
Serial.print("Temperature = ");
Serial.print(t);
Serial.println("C \n \n \n ");
delay(2000 );
}
@yocki24
Copy link

yocki24 commented Mar 16, 2022

ok, i was search a scematic design and i found it use resistor in data pin. so should i doing this?

@TrickSumo
Copy link
Author

You can use it.

@yocki24
Copy link

yocki24 commented Mar 16, 2022

oke thank you so much

@TrickSumo
Copy link
Author

Welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment