Skip to content

Commit 099ca1c

Browse files
authored
Merge pull request #6 from pxsty0/patch-6
Create OledSonDeprem.ino
2 parents ca272db + 31db0f0 commit 099ca1c

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*OledSonDeprem
2+
3+
Mustafa "pxsty" kök tarafından eklendi --> github.com/pxsty0
4+
Bu projede Deneyap OLED Ekran kullanılarak son deprem ekrana yazdırılmıştır.
5+
6+
Bu uygulama örneği için "Deneyap_OLED" kütüphanesi indirilmelidir. -> https://github.com/deneyapkart/deneyap-oled-ekran-arduino-library <-
7+
Bu uygulama örneği için "ArduinoJson" Versiyon 6.9.0 kütüphanesi indirilmelidir. -> https://github.com/bblanchon/ArduinoJson <-
8+
9+
*/
10+
#include <WiFi.h>
11+
#include <HTTPClient.h>
12+
#include <ArduinoJson.h>
13+
#include <Deneyap_OLED.h>
14+
15+
16+
#define WLAN_SSID "" // Wifi SSID
17+
#define WLAN_PASS "" // Wifi Şifresi
18+
19+
HTTPClient http;
20+
OLED oled;
21+
22+
String lastId = "0";
23+
24+
void connectionErr() {
25+
oled.clearDisplay();
26+
oled.setTextXY(2, 0);
27+
oled.setFont(font8x8);
28+
oled.putString(" Internete ");
29+
oled.setTextXY(4, 0);
30+
oled.putString(" Baglaniliyor ");
31+
}
32+
33+
void setup() {
34+
Serial.begin(115200);
35+
oled.begin(0x7A);
36+
connectionErr();
37+
WiFi.begin(WLAN_SSID, WLAN_PASS);
38+
Serial.print("Wi-Fi Baglanıyor...");
39+
while (WiFi.status() != WL_CONNECTED) {
40+
Serial.print(".");
41+
delay(300);
42+
}
43+
Serial.println();
44+
Serial.print("Baglandı. IP: ");
45+
Serial.println(WiFi.localIP());
46+
Serial.println();
47+
}
48+
49+
void loop() {
50+
51+
http.begin("http://pxstyearthquakes.glitch.me/");
52+
53+
int httpCode = http.GET();
54+
55+
if (httpCode > 0) {
56+
String response = http.getString();
57+
Serial.println(response);
58+
DynamicJsonDocument doc(2048);
59+
deserializeJson(doc, response);
60+
Serial.println(response);
61+
int code = doc["code"];
62+
if (code == 200) {
63+
String id = doc["afadDepremID"];
64+
String place = doc["data"]["en"]["place"];
65+
String size = doc["data"]["en"]["size"];
66+
if (id != lastId) {
67+
oled.clearDisplay();
68+
oled.setTextXY(0, 0);
69+
oled.setFont(font8x8);
70+
oled.putString(" Son Deprem ");
71+
oled.setTextXY(2, 0);
72+
oled.putString("Yer : " + place);
73+
oled.setTextXY(7, 0);
74+
oled.putString("Buyukluk : " + size);
75+
}
76+
lastId = id;
77+
78+
}
79+
80+
} else {
81+
connectionErr();
82+
}
83+
84+
http.end();
85+
86+
delay(1000);
87+
}
104 KB
Loading

0 commit comments

Comments
 (0)