Last active
March 24, 2020 11:56
-
-
Save ahmetus/7d72bad077a682c4e0bab00ed2b731fd to your computer and use it in GitHub Desktop.
Esp32 devkit ve dht11 Sensör ile Hava Durumu okuyup PCD8544 Nokia 5110 LCD Ekranda Gösterme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********************************************************************* | |
This is an example sketch for our Monochrome Nokia 5110 LCD Displays | |
Pick one up today in the adafruit shop! | |
------> http://www.adafruit.com/products/338 | |
These displays use SPI to communicate | |
Adafruit invests time and resources providing this open source code, | |
please support Adafruit and open-source hardware by purchasing | |
products from Adafruit! | |
Written by Limor Fried/Ladyada for Adafruit Industries. | |
BSD license, check license.txt for more information | |
All text above, and the splash screen must be included in any redistribution | |
*********************************************************************/ | |
/* | |
* Not: Adafruit GFX ve PCD8544 kitapliklari | |
kullanildigindan copyright bilgileri eklidir. | |
NOKIA 5110 LCD PIN HARITASI : | |
SCK 18 | |
MOSI 23 | |
DC 19 | |
RST 14 | |
CS 5 | |
*/ | |
#include <SPI.h> | |
#include <Adafruit_GFX.h> | |
#include <Adafruit_PCD8544.h> | |
#include <Adafruit_Sensor.h> | |
#include <DHT.h> | |
#define DHTPIN 26 // DHT Sensor Pini | |
#define DHTTYPE DHT11 // DHT 11 | |
#define BL 27 | |
#define SCK 18 | |
#define MOSI 23 | |
#define DC 19 | |
#define RST 14 | |
#define CS 5 | |
Adafruit_PCD8544 display = Adafruit_PCD8544(DC, CS, RST); | |
DHT dht(DHTPIN, DHTTYPE); | |
String sicaklikOku() { | |
float t = dht.readTemperature(); | |
if (isnan(t)) { | |
Serial.println("DHT sensorden sicaklik bilgisi alinamadi!"); | |
return "--"; | |
} | |
else { | |
Serial.print("Sicaklik : "); | |
Serial.print(t); | |
Serial.print(" Derece "); | |
return String(t); | |
} | |
} | |
String nemOku() { | |
float h = dht.readHumidity(); | |
if (isnan(h)) { | |
Serial.println("DHT sensorden nem bilgisi alinamadi!!"); | |
return "--"; | |
} | |
else { | |
Serial.print(" - Nem Oranı : "); | |
Serial.print(h); | |
Serial.println(" %"); | |
return String(h); | |
} | |
} | |
void hdGoster() { | |
dht.begin(); | |
display.setRotation(1); | |
display.setTextSize(1); | |
display.setTextColor(BLACK); | |
display.setCursor(0, 0); | |
display.println(" "); | |
display.println("SICAKLIK"); | |
display.println("--------"); | |
display.println(" "); | |
display.print(sicaklikOku()); | |
display.print(" "); | |
display.write(247); | |
display.print("C"); | |
display.println(" "); | |
display.println("NEM"); | |
display.println("--------"); | |
display.println(" "); | |
display.print(nemOku()); | |
display.print(" "); | |
display.write(37); | |
display.println(" "); | |
display.display(); | |
delay(2000); | |
} | |
void setup() { | |
Serial.begin(115200); | |
pinMode(BL, OUTPUT); | |
digitalWrite(BL, HIGH); | |
display.begin(); | |
display.setContrast(60); | |
display.clearDisplay(); | |
hdGoster(); | |
} | |
void loop() { | |
delay(2000); | |
setup(); | |
delay(2000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment