Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // E-INK
- #include <GxEPD.h>
- #include <GxIO/GxIO_SPI/GxIO_SPI.h>
- #include <GxIO/GxIO.h>
- #include <GxGDEH0154D67/GxGDEH0154D67.h>
- #include "bitmap.h"
- #include <Fonts/FreeSansBold18pt7b.h> //FONT SANS BOL 18P
- #include <Fonts/FreeSansBold24pt7b.h> //FONT SANS BOL 24P
- GxIO_Class io(SPI, 10, 9, 8); // CREO SERIALE PER E-INK -- CS DC RST
- GxEPD_Class display(io, 8, 7); // CREO DISPLAY PER E-INK -- Seriale RST BUSY
- // WIFI E TELEGRAM
- #include <WiFi.h>
- #include <WiFiClientSecure.h>
- #include <UniversalTelegramBot.h>
- const char* ssid = "arduinooo";
- const char* password = "arduinami";
- #define BOTToken "xxxxx"
- #define CHAT_ID "xxxxx"
- WiFiClientSecure client;
- UniversalTelegramBot bot(BOTToken, client);
- // SENSORI
- #include "DHT.h"
- #include "MQ135.h"
- MQ135 mq135_sensor(A1);
- DHT dht(2, DHT11);
- float t, h, PPM;
- void setup() {
- Serial.begin(115200);
- display.init();
- display.setRotation(2);
- dht.begin();
- WiFi.mode(WIFI_STA);
- splash();
- }
- void loop() {
- lettura_sensori();
- stampa_valori();
- messaggio();
- delay(3600000);
- }
- void splash() {
- display.eraseDisplay(); //SVUOTO DISPLAY
- display.drawExampleBitmap(logo, 0, 0, 200, 200, GxEPD_BLACK); //SETTO IL LOGO
- display.update(); //STAMPO
- delay(3000); //ASPETTO 3 SEC
- display.drawExampleBitmap(gui, 0, 0, 200, 200, GxEPD_BLACK);
- display.update(); //STAMPO
- }
- void lettura_sensori() {
- t = dht.readTemperature();
- h = dht.readHumidity();
- PPM = mq135_sensor.getCorrectedPPM(t, h);
- }
- void stampa_valori() {
- display.setRotation(3);
- display.fillRect(65,0,135,200, GxEPD_WHITE);
- display.setFont(&FreeSansBold24pt7b);
- display.setTextColor(GxEPD_BLACK);
- display.setCursor(65,50);
- display.print(String(t,1));
- display.setCursor(65,115);
- display.print(String(h,0) + "%");
- display.setCursor(65,180);
- if (PPM > 100000) display.setFont(&FreeSansBold18pt7b);
- display.print(String(PPM,0));
- display.update();
- }
- void messaggio() {
- WiFi.begin(ssid, password);
- client.setCACert(TELEGRAM_CERTIFICATE_ROOT);
- while (WiFi.status() != WL_CONNECTED) {
- delay(500);
- Serial.print(".");
- }
- Serial.println("");
- Serial.println("WiFi connesso");
- bot.sendMessage(CHAT_ID, "\xf0\x9f\x8c\xa1 " + String(t,1) + "°C \n \xf0\x9f\x92\xa7 " + String(h,0) + "% \n \xf0\x9f\x92\xa8 " + String(PPM,0) + " PPM"); //invia il messaggio
- WiFi.disconnect(true);
- WiFi.mode(WIFI_OFF);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement