/* // Version 4.0 13-2-2018 Bareometr WiFi ePaper 2.9inch tři barvy Tato WiFi meteostanice stahuje data s webu: tmep.cz Aktualizace se provádí jednou za 30 minut (volitelné) Tento kód je inspirován od autora: http://wiki.tmep.cz/doku.php?id=ruzne:esp8266 Přepracoval: Josef Zvolánek https://plus.google.com/u/0/+JosefZvolanek https://twitter.com/JosefZvolanek - přidané čidlo DHT22 pro měření vnitřní teploty - zobrazení naměřeních údajů na ePaper Waveshare 2.9inch tři barvy - Měření napětí baterie + grafické zobrazení-ikona - Měření signálu WiFi + grafické zobrazeni-ikona Ps: Děkuji za kotrolu a revizi kódu Davidem Birdem https:www.youtube.com/user/G6EJD/videos */ #include // WiFi library #include // JSON library #include "DHT.h" // DHT sensor library #include // Core graphics library for OLED #include #include // 2.9" b/w/r //Senzor DHT22 #define DHTPIN 12 #define DHTTYPE DHT22 // DHT 22 DHT dht(DHTPIN, DHTTYPE); //Font #include #include #include #include #include // EPD 2.9inch e-Paper #include #include // mapping suggestion from Waveshare 2.9inch e-Paper to Wemos D1 mini // BUSY -> 4, RST -> 2, DC -> 0, CS -> 15, CLK -> 14, DIN -> 13, GND -> GND , 3.3V -> 3.3V GxIO_Class io(SPI, 15, 0, 2); GxEPD_Class display(io, 2, 4); //Obrázky bmp ikony const unsigned char Venku [] PROGMEM = { // 'VENKU2' 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x80, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x0e, 0x83, 0x60, 0x00, 0x00, 0x0e, 0x83, 0x60, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x01, 0x00, 0x80, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x80, 0x10, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x11, 0x10, 0x00, 0x00, 0x00, 0x1b, 0xf0, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x05, 0x8c, 0x00, 0x00, 0x00, 0x07, 0x0c, 0x00, 0x00, 0x00, 0x03, 0x08, 0x80, 0x00, 0x00, 0x03, 0x08, 0x80, 0x00, 0x00, 0x01, 0x09, 0xb8, 0x00, 0x00, 0x03, 0x8b, 0xc0, 0x00, 0x00, 0x0f, 0xde, 0x00, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x03, 0xff, 0x80, 0x00, 0x00 }; const unsigned char Teplota [] PROGMEM = { // 'TEPLOTA' 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0x00, 0x99, 0x3c, 0x00, 0x00, 0x00, 0xa5, 0xb8, 0x00, 0x00, 0x01, 0xa5, 0x80, 0x00, 0x00, 0x01, 0xa5, 0xb0, 0x00, 0x00, 0x01, 0xa5, 0x80, 0x00, 0x00, 0x01, 0xa5, 0xb8, 0x00, 0x00, 0x01, 0xa5, 0xbc, 0x00, 0x00, 0x01, 0xa5, 0x80, 0x00, 0x00, 0x01, 0xa5, 0xb0, 0x00, 0x00, 0x01, 0xa5, 0x80, 0x00, 0x00, 0x01, 0xa5, 0x80, 0x00, 0x00, 0x01, 0xa5, 0xbc, 0x00, 0x00, 0x01, 0xa5, 0x80, 0x00, 0x00, 0x01, 0xa5, 0xb0, 0x00, 0x00, 0x01, 0xa5, 0xb0, 0x00, 0x00, 0x01, 0xa5, 0x80, 0x00, 0x00, 0x01, 0xa5, 0x80, 0x00, 0x00, 0x03, 0x24, 0xe0, 0x00, 0x00, 0x0c, 0x24, 0x30, 0x00, 0x00, 0x18, 0x24, 0x18, 0x00, 0x00, 0x10, 0xe7, 0x08, 0x00, 0x00, 0x31, 0x81, 0x8c, 0x00, 0x00, 0x23, 0x00, 0xc4, 0x00, 0x00, 0x62, 0x00, 0x46, 0x00, 0x00, 0x64, 0x00, 0x26, 0x00, 0x00, 0x44, 0x00, 0x22, 0x00, 0x00, 0x44, 0x00, 0x22, 0x00, 0x00, 0x44, 0x00, 0x22, 0x00, 0x00, 0x66, 0x00, 0x66, 0x00, 0x00, 0x62, 0x00, 0x46, 0x00, 0x00, 0x23, 0x00, 0xc4, 0x00, 0x00, 0x31, 0x81, 0x8c, 0x00, 0x00, 0x10, 0x7f, 0x08, 0x00, 0x00, 0x08, 0x00, 0x10, 0x00, 0x00, 0x06, 0x00, 0x60, 0x00, 0x00, 0x03, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00 }; const unsigned char DOMA [] PROGMEM = { // 'DOMA' 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x01, 0xff, 0x80, 0x00, 0x00, 0x03, 0xc1, 0xc0, 0x00, 0x00, 0x1e, 0x00, 0x78, 0x00, 0x00, 0x3c, 0x18, 0x3c, 0x00, 0x00, 0xe0, 0xff, 0x07, 0x00, 0x07, 0xc3, 0xc3, 0xc3, 0xe0, 0x0f, 0x07, 0x00, 0xf0, 0x70, 0x78, 0x3c, 0x00, 0x3c, 0x1e, 0xf0, 0x70, 0x00, 0x0e, 0x0f, 0xc3, 0xc0, 0x00, 0x03, 0xc3, 0xcf, 0x00, 0xff, 0x00, 0xf3, 0xfc, 0x00, 0xff, 0x00, 0x3f, 0xf0, 0x00, 0xc1, 0x00, 0x0f, 0x70, 0x00, 0xc1, 0x00, 0x0e, 0x30, 0x00, 0xc1, 0x00, 0x0c, 0x30, 0x00, 0xc1, 0x00, 0x0c, 0x30, 0x00, 0xd9, 0x00, 0x0c, 0x30, 0x00, 0xd9, 0x00, 0x0c, 0x30, 0x00, 0xd9, 0x00, 0x0c, 0x30, 0x00, 0xd9, 0x00, 0x0c, 0x30, 0x00, 0xd9, 0x00, 0x0c, 0x30, 0x00, 0xd9, 0x00, 0x0c, 0x30, 0x01, 0x99, 0xc0, 0x0c, 0x30, 0x03, 0x18, 0xc0, 0x0c, 0x30, 0x06, 0x7e, 0x60, 0x0c, 0x30, 0x06, 0x7e, 0x60, 0x0c, 0x30, 0x06, 0x7e, 0x60, 0x0c, 0x30, 0x06, 0x7e, 0x60, 0x0c, 0x30, 0x06, 0x7e, 0x60, 0x0c, 0x30, 0x03, 0x18, 0xc0, 0x0c, 0x30, 0x01, 0x81, 0x80, 0x0c, 0x30, 0x00, 0xe7, 0x00, 0x0c, 0x30, 0x00, 0x7e, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x00, 0x0c, 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x1f, 0xff, 0xff, 0xff, 0xfc }; const unsigned char P [] PROGMEM = { // 'POCASI, 32x32px 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x43, 0xf0, 0x00, 0x00, 0x48, 0x08, 0x00, 0x00, 0x50, 0x03, 0x00, 0x00, 0x40, 0x00, 0x80, 0x00, 0x20, 0x00, 0x40, 0x00, 0xc0, 0x00, 0x40, 0x01, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x78, 0x04, 0x00, 0x00, 0x06, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; const unsigned char P1 [] PROGMEM = { // 'POCASI1, 32x32px 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x03, 0x90, 0x00, 0x00, 0x08, 0x7c, 0x00, 0x00, 0x08, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x01, 0xfe, 0x00, 0x00, 0x08, 0xfe, 0x00, 0x00, 0x08, 0xfe, 0x00, 0x00, 0x03, 0xfc, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; const unsigned char Slunicko [] PROGMEM = { // 'Slunicko, 32x32px 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x80, 0x01, 0x80, 0x03, 0x00, 0x00, 0xc3, 0x86, 0x00, 0x00, 0x5f, 0xf4, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x20, 0x0c, 0x00, 0x00, 0x60, 0x0c, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x40, 0x06, 0x00, 0x1e, 0xc0, 0x06, 0xf0, 0x00, 0x40, 0x04, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x60, 0x0c, 0x00, 0x00, 0x30, 0x18, 0x00, 0x00, 0x1c, 0x30, 0x00, 0x00, 0xcf, 0xe6, 0x00, 0x01, 0x80, 0x03, 0x00, 0x03, 0x00, 0x01, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; const unsigned char P2 [] PROGMEM = { // 'Zatazeno, 32x32px 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x0c, 0x00, 0x60, 0x00, 0x06, 0x38, 0xc0, 0x00, 0x00, 0xc6, 0x00, 0x00, 0x01, 0x83, 0x00, 0x00, 0x03, 0x01, 0x80, 0x01, 0xf2, 0x00, 0x80, 0x03, 0x1a, 0x00, 0xb8, 0x06, 0x0f, 0x00, 0x80, 0x04, 0x01, 0x81, 0x80, 0x1c, 0x00, 0x41, 0x00, 0x10, 0x00, 0x43, 0x00, 0x20, 0x00, 0x5c, 0x80, 0x20, 0x00, 0x40, 0xc0, 0x30, 0x00, 0xd0, 0x60, 0x1f, 0xff, 0x90, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; const unsigned char Teplota2 [] PROGMEM = { // 'Teplota2, 40x40px 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0xc7, 0x00, 0x00, 0x00, 0x01, 0x81, 0x80, 0x00, 0x00, 0x01, 0xbd, 0x80, 0x00, 0x00, 0x01, 0x3d, 0x80, 0x00, 0x00, 0x01, 0x3c, 0xf0, 0x00, 0x00, 0x01, 0x3c, 0xf0, 0x00, 0x00, 0x01, 0x3c, 0x80, 0x00, 0x00, 0x01, 0x3c, 0x80, 0x00, 0x00, 0x01, 0x3c, 0xf0, 0x00, 0x00, 0x01, 0x3c, 0xf0, 0x00, 0x00, 0x01, 0x3c, 0x80, 0x00, 0x00, 0x01, 0x3c, 0x80, 0x00, 0x00, 0x01, 0x3c, 0x80, 0x00, 0x00, 0x01, 0x3c, 0xf0, 0x00, 0x00, 0x01, 0x3c, 0x80, 0x00, 0x00, 0x01, 0x3c, 0x80, 0x00, 0x00, 0x03, 0x3c, 0xc0, 0x00, 0x00, 0x06, 0x3c, 0xe0, 0x00, 0x00, 0x06, 0xff, 0x60, 0x00, 0x00, 0x0c, 0xff, 0x30, 0x00, 0x00, 0x0d, 0xff, 0xb0, 0x00, 0x00, 0x0d, 0xff, 0xb0, 0x00, 0x00, 0x0d, 0xff, 0xb0, 0x00, 0x00, 0x0d, 0xff, 0xb0, 0x00, 0x00, 0x0c, 0xff, 0x30, 0x00, 0x00, 0x06, 0xfe, 0x60, 0x00, 0x00, 0x07, 0x3c, 0xe0, 0x00, 0x00, 0x03, 0x81, 0xc0, 0x00, 0x00, 0x01, 0xff, 0x80, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; const unsigned char Slunicko2 [] PROGMEM = { // 'Slunicko2, 32x32px 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x01, 0x01, 0x80, 0xc0, 0x01, 0x81, 0x81, 0xc0, 0x01, 0xc0, 0x03, 0x80, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x63, 0xc2, 0x00, 0x00, 0x07, 0xf0, 0x00, 0x00, 0x0f, 0xf8, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00, 0x1f, 0xfc, 0x00, 0x1f, 0x1f, 0xfc, 0xf8, 0x1f, 0x1f, 0xfc, 0xf8, 0x00, 0x1f, 0xfc, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00, 0x0f, 0xf8, 0x00, 0x00, 0x07, 0xf0, 0x00, 0x00, 0x60, 0x82, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x01, 0xc0, 0x03, 0xc0, 0x01, 0x81, 0x81, 0xc0, 0x01, 0x01, 0x80, 0x80, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; const unsigned char Zatazeno2 [] PROGMEM = { // 'Zatazeno2, 32x32px 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x04, 0x0c, 0x08, 0x00, 0x06, 0x0c, 0x18, 0x00, 0x03, 0x00, 0x30, 0x00, 0x01, 0x00, 0x60, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x79, 0xf0, 0x00, 0x00, 0x77, 0xfc, 0x00, 0x18, 0xee, 0x0e, 0x00, 0x3c, 0xd8, 0x07, 0xe0, 0x00, 0xd8, 0x03, 0xf0, 0x00, 0x30, 0x00, 0x38, 0x00, 0xf0, 0x00, 0x18, 0x01, 0xc0, 0x00, 0x0c, 0x01, 0x80, 0x00, 0x0c, 0x01, 0x80, 0x00, 0x0c, 0x05, 0x80, 0x00, 0x08, 0x05, 0x80, 0x40, 0x18, 0x01, 0xe1, 0xc0, 0x70, 0x00, 0xf3, 0xdf, 0xe0, 0x00, 0x07, 0x80, 0x00, 0x00, 0x4f, 0x82, 0x00, 0x00, 0xc7, 0x86, 0x00, 0x01, 0xc7, 0x0c, 0x00, 0x01, 0x80, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; // Define settings-nastavení const char* ssid = "......."; // WiFi SSID const char* pass = "......."; // WiFi password const char* host = "tmep.cz"; const int httpPort = 80; boolean host_status; const char* jsonurl = ".........."; // JSON's URL (ex. https://tmep.cz/vystup-json.php?id=xxx&export_key=xxxxxxxxxx const long sleep = 100000; // How often read data from the server. Default is 600000ms = 10 minute WiFiClient client; // Use WiFiClient class to create TCP connections void setup() { Initialise_system(); Start_WiFi(); } void loop() { RSSI(60,120,WiFi.RSSI());// WiFi ikona long rssi = WiFi.RSSI(); Serial.print("RSSI:"); Serial.println(rssi); display.setCursor(150 / 2, 240 / 2); display.print(rssi); display.print(" db"); Serial.print("Connecting to "); Serial.println(host); if (!client.connect(host, httpPort)) { // If you didn't get a connection to the server Serial.println("Connection failed"); host_status = false; } else host_status = true; if (host_status = true) { Serial.println("Client connected"); // Make an url char url[50]; // Make new array, 50 bytes long strncpy(url, &jsonurl[15], strlen(jsonurl) - 14); // Remove "https://tmep.cz" and leave rest // Serial.print("Requesting URL: "); Serial.println(url); // Make HTTP GET request client.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n"); // Workaroud for timeout unsigned long timeout = millis(); while (client.available() == 0) { if (millis() - timeout > 5000) { Serial.println(">>> Client Timeout !"); client.stop(); } } // Read JSON String data; bool capture = false; String json; while (client.available()) { data = client.readStringUntil('\n'); // Loop over rows. "\r" not work. "\0" returns all at one //Serial.println(data); // First few rows is header, it ends with empty line. // This is unique ultrasimple, but working solution. // Start capture when { occurs and end capturing with }. if (data.startsWith("{", 0)) { // JSON starts with {. Start capturing. capture = true; } if (data.startsWith("}", 0)) { // JSON ends with }. Stop capturing. capture = false; } if (capture) { json = json + data; // Joining row by row together in one nice JSON part. } } json = json + "}"; // WTF, last bracket is missing :/ add it here - ugly! Serial.println(json); // Lets throw our json on ArduinoJson library and get results! StaticJsonBuffer<300> jsonBuffer; // možná dynamicBuffer JsonObject& root = jsonBuffer.parseObject(json); if (!root.success()) Serial.print("ParseObject() failed"); // This is how our JSON looks. You can read any value of parameters // { // "teplota": 24.87, // "vlhkost": null, // "rosny": null, // "cas": "2016-06-02 18:29:45", // "umisteni": "Karlovy Vary" // } //ČAS-Update String cas = root["cas"]; // Get value of "cas" Serial.print("cas: "); Serial.println(cas); display.setTextSize(1); const GFXfont* f = &FreeSansBoldOblique9pt7b; display.setFont(f); display.setTextColor(GxEPD_RED); display.setCursor(30, 13); display.print("Update:"); display.setTextColor(GxEPD_BLACK); display.setCursor(105, 13); display.print(cas); //display.drawBitmap(5, 1, U, 12, 12, GxEPD_BLACK);//ikona U display.drawLine(0, 35 / 2, 600 / 2, 35 / 2, GxEPD_BLACK); display.setTextColor(GxEPD_RED); display.setCursor(40, 36); display.print("VENKU"); //display.drawBitmap(160, 15, P1, 32, 32, GxEPD_BLACK); display.drawBitmap(5, 15, Zatazeno2, 32, 32, GxEPD_BLACK);//Venku ikona display.setCursor(200, 36); display.print("DOMA"); display.drawBitmap(160, 15, Slunicko2, 32, 32, GxEPD_BLACK);//Doma ikona display.drawLine(0, 90 / 2, 600 / 2, 90 / 2, GxEPD_BLACK); display.drawLine(300 / 2, 35 / 2, 300 / 2, 270 / 2, GxEPD_BLACK); //vertikál //Teplota-WEB tmep.cz ePaper float teplota = root["teplota"]; // Get value of "teplota" display.setTextColor(GxEPD_BLACK); display.setFont(f); display.setTextSize(1); display.setCursor(40,70); if (teplota == -127.00) { // If you have connected it wrong, Dallas read this temperature! :) Serial.println("teplota: chyba!"); display.print("ERR"); } else { Serial.print("teplota: "); Serial.println(teplota); display.print(teplota, 1); // Round temp to one decimal point display.setTextSize(1); display.print(" C "); DisplayDegree(75,57); display.drawBitmap(100, 50, Venku, 40, 40, GxEPD_BLACK); //display.drawBitmap(0, 55, Teplota, 40, 40, GxEPD_BLACK); display.drawBitmap(0, 55, Teplota2, 40, 40, GxEPD_BLACK); //Vlkost-WEB tmep.cz float vlhkost = root["vlhkost"]; // Get value of "vlhkost" Serial.print("vlhkost: "); Serial.println(vlhkost); display.setTextColor(GxEPD_BLACK); const GFXfont* f = &FreeSansBoldOblique9pt7b; display.setFont(f); display.setTextSize(1); display.setCursor(40, 95); display.print(vlhkost, 1); display.print(" % "); //DHT22-DOMA float h = dht.readHumidity(); // Read temperature as Celsius (the default) float t = dht.readTemperature(); Serial.print("Humidity: " + String(h) + " Temperature: " + String(t) + " *C "); //Teplota display.setTextColor(GxEPD_BLACK); display.setCursor(420 / 2, 143 / 2); display.print(String(t, 1) + " C"); DisplayDegree(505/2,115/2); //Vlhkost display.setCursor(420 / 2, 190 / 2); display.print(String(h, 1) + " %"); display.drawBitmap(160, 55, DOMA, 40, 40, GxEPD_BLACK); //Baterie uint8_t percentage = 100; float adcVoltage = analogRead(A0) / 1024.0; // This values where empirically collected float batteryVoltage = adcVoltage * 4.945945946 - 0.3957657658; if (batteryVoltage > 4.2) percentage = 100; else if (batteryVoltage < 3.3) percentage = 0; else percentage = (batteryVoltage - 3.3) * 100 / (4.2 - 3.3); Battery(155, 105, 3, percentage); display.setCursor(380/2,240/2); display.print(String(batteryVoltage,2)+"v"); display.setCursor(480/2,240/2); display.print(String(percentage)+"%"); display.drawLine(300 / 2, 35 / 2, 300 / 2, 270 / 2, GxEPD_BLACK); //vertikál } display.update(); Serial.println(); delay(200); } else { // display.setCursor(420 / 2, 190 / 2); //display.print("Network error with host..."); display.update(); } Serial.println("Going to sleep...for 30minut"); ESP.deepSleep(30 * 60 * 1e6); delay(500); } void Initialise_system() { Serial.begin(115200); // Start serial dht.begin(); //DHT22 Serial.println(); // ePaper display display.init(); display.fillScreen(GxEPD_WHITE); display.setRotation(1); } void Start_WiFi() { // Connect to the WiFi // int rssi = getRSSI(SSID); Serial.print("Connecting to "); Serial.println(ssid); display.print("Connecting to "); display.println(ssid); WiFi.begin(ssid, pass); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(); //display.println(); Serial.println("WiFi connected"); //display.println("WiFi connected"); Serial.print("IP address: "); Serial.println(WiFi.localIP()); display.setTextColor(GxEPD_RED); const GFXfont* f = &FreeSansBoldOblique9pt7b; display.setFont(f); display.setTextSize(0); //display.setCursor(10 / 2, 248 / 2); display.print("IP:" + WiFi.localIP().toString()); display.setCursor(10 / 2, 240 / 2); display.print("WiFi"); display.drawLine(0, 203 / 2, 600 / 2, 203/ 2, GxEPD_BLACK); Serial.println(); delay(1000); display.setTextColor(GxEPD_BLACK); } //ikona baterie void Battery(int x, int y, int scale, int percent) { int linesize = 2; //display.print("Hello"); display.fillRect(x, y, scale*9, linesize+5*scale, GxEPD_BLACK); display.fillRect(x + linesize, y + linesize, scale*7.8,linesize+3.8*scale, GxEPD_WHITE); display.fillRect(x + 9*scale, y + linesize*scale/1.3, scale * 1, linesize+scale*2, GxEPD_BLACK); // if (percent >= 12.5) display.fillRect(x+linesize+scale*0.8,y+linesize*scale/1.3,scale*1,linesize*scale*1.7, GxEPD_BLACK); if (percent >= 12.5) display.fillRect(x+linesize+scale*0.8,y+linesize*scale/1.3,scale*1,linesize*scale*1.7, (percent<25?GxEPD_RED:GxEPD_BLACK)); if (percent >= 25) display.fillRect(x+linesize+scale*2.5,y+linesize*scale/1.3,scale*1,linesize*scale*1.7, GxEPD_BLACK); if (percent >= 50) display.fillRect(x+linesize+scale*4.3,y+linesize*scale/1.3,scale*1,linesize*scale*1.7, GxEPD_BLACK); if (percent >= 75) display.fillRect(x+linesize+scale*5.8,y+linesize*scale/1.3,scale*1,linesize*scale*1.7, GxEPD_BLACK); } void DisplayDegree(int x, int y){ display.drawCircle(x,y,3,GxEPD_BLACK); display.drawCircle(x,y,2,GxEPD_BLACK); } //ikona WiFi void RSSI(int x, int y, int rssi){ int WIFIsignal = 0; for (int _rssi = -100; _rssi <= rssi; _rssi = _rssi + 20) { if (_rssi <= -20) WIFIsignal = 12; // -0dbm displays 5-bars if (_rssi <= -40) WIFIsignal = 10; // -40dbm to -21dbm displays 4-bars if (_rssi <= -60) WIFIsignal = 8; // -60dbm to -41dbm displays 3-bars if (_rssi <= -80) WIFIsignal = 6; // -80dbm to -61dbm displays 2-bars if (_rssi <= -100) WIFIsignal = 4; // -100dbm to -81dbm displays 1-bar int start_angle = -40; // Arc size left int end_angle = 40; // Arc size right for (int i = start_angle; i < end_angle; i = i +1) { display.drawPixel(x + cos((i-90)*3.14/180) * WIFIsignal*1.6, y + sin((i-90)*3.14/180) * WIFIsignal*1.6, GxEPD_BLACK); display.drawPixel(x + cos((i-90)*3.14/180) * WIFIsignal*1.6, y+1 + sin((i-90)*3.14/180) * WIFIsignal*1.6, GxEPD_BLACK); } } display.fillCircle(x,y,2,GxEPD_BLACK); }