Home
About Us
Achievement
Home
Raspberry-Pi Projects
_Raspberry Pi 4 Complete Guide
Arduino Project
_All Projects
Esp8266 Project
_All Projects
Esp32 Project
_Automation-with-feedback
DHT11 Temperature and Humidity Readings in OLED Display
Just Do Electronics
January 07, 2021
Circuit Diagram :-
Code :-
//Prateek //www.prateeks.in #include
#include
#include
#include
#include
#define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); #define DHTPIN D3 // Digital pin connected to the DHT sensor // Uncomment the type of sensor in use: #define DHTTYPE DHT11 // DHT 11 //#define DHTTYPE DHT22 // DHT 22 (AM2302) //#define DHTTYPE DHT21 // DHT 21 (AM2301) DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(115200); dht.begin(); if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); for(;;); } delay(2000); display.clearDisplay(); display.setTextColor(WHITE); } void loop() { delay(5000); //read temperature and humidity float t = dht.readTemperature(); float h = dht.readHumidity(); if (isnan(h) || isnan(t)) { Serial.println("Failed to read from DHT sensor!"); } // clear display display.clearDisplay(); // display temperature display.setTextSize(1); display.setCursor(0,0); display.print("Temperature: "); display.setTextSize(2); display.setCursor(0,10); display.print(t); display.print(" "); display.setTextSize(1); display.cp437(true); display.write(167); display.setTextSize(2); display.print("C"); // display humidity display.setTextSize(1); display.setCursor(0, 35); display.print("Humidity: "); display.setTextSize(2); display.setCursor(0, 45); display.print(h); display.print(" %"); display.display(); }
1 Comments
Anonymous
6 February 2023 at 04:20
Hello does this work on esp32?
Reply
Delete
Replies
Reply
Add comment
Load more...
Newer
Older
Build Your Own Gps Tracking System using Arduino
How To Make RFID & Keypad Based Door Lock
IoT Based Fingerprint Biometric Attendance System Using NodeMCU (Esp8266)
Ultrasonic Sensor as a Counter with Arduino
OTP Based Door Lock Using Arduino And SIM800L
IoT Based Patient Health Monitoring System Using Blynk App
ESP32 Interfacing With LDR Sensor
MLX90614 Non-Contact Infrared Thermometer With Arduino
Nodemcu Interfacing With Em-18
ESP32 Led Blink With Push Button
YouTube
Like on Facebook
Follow on Twitter
Follow on Google+
Follow on Instagram
Subscribe on Youtube
Hi WelCome To My Website If you have a creative mind and want to learn Electronics even without studying it then FRIENDS this Website And Youtube Channel is for you, I am crazy creators who love making Electronics things. I have a bunch of more than 130 Tutorial Videos on My YouTube Channel and I upload a new Tutorial every Sunday.
Tags
Arduino Project
Esp32 Project
Esp8266 Project
1 Comments
Hello does this work on esp32?
ReplyDelete