#include <LiquidCrystal.h>
#include <WiFi.h>
#include <HTTPClient.h>
#define RS 23
#define RW 22
#define E 21
#define D4 19
#define D5 18
#define D6 5
#define D7 17
unsigned const long timing = 5000;
unsigned long current_time = 0;
LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
HTTPClient http;
void setup() {
lcd.begin(16, 2);
Serial.begin(115200);
WiFi.begin("Wokwi-GUEST", "", 6);
while (WiFi.status() != WL_CONNECTED) {
delay(250);
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
lcd.clear();
lcd.print("TEM\x87");
lcd.print("EPAT\x88PA B"); //" "
lcd.setCursor(0,1);
lcd.print("\x83");
lcd.print("E\x86");
lcd.print("EHO\x92");
lcd.print("OPCK: ");
}
void loop() {
// put your main code here, to run repeatedly:
if((millis() - current_time) > timing){
http.begin("https://wttr.in/Zelenogorsk?format=%t");
int httpResponseCode = http.GET();
Serial.println(httpResponseCode);
if(httpResponseCode == 200) {
String payload = http.getString();
Serial.println(payload);
lcd.setCursor(10,1);
lcd.print(payload);
lcd.rightToLeft();
lcd.print(" ");
lcd.leftToRight();
lcd.print(" \xB0\x43");
}
else {
Serial.print("error, response code: ");
Serial.println(httpResponseCode);
}
current_time = millis();
}
delay(10); // this speeds up the simulation
}