Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "U8glib.h"
- #include "DHT.h"
- #define DHTPIN 5
- #define DHTTYPE DHT22
- DHT dht(DHTPIN, DHTTYPE);
- U8GLIB_SH1106_128X64 u8g (12, 11, 8, 9, 10); // (D0, D1, CS, DC, RST)
- U8GLIB_SH1106_128X64 u8g2 (12, 11, 7, 9, 10); // (D0, D1, CS, DC, RST)
- void setup() {
- dht.begin();
- }
- void drawLocal() {
- int tempLocal = dht.readTemperature();
- int humiLocal = dht.readHumidity();
- u8g.setFont (u8g_font_unifont);
- u8g.drawFrame (1, 1, 126, 62);
- u8g.drawStr (10, 20, "LOCAL");
- u8g.drawStr (10, 40, "TEMP:");
- u8g.setPrintPos (90, 40);
- u8g.print(tempLocal);
- u8g.drawStr (109, 40, "C");
- u8g.drawStr (10, 53, "HUMI:");
- u8g.setPrintPos (90, 53);
- u8g.print(humiLocal);
- u8g.drawStr (109, 53, "%");
- }
- void drawAPI() {
- int tempAPI = 99;
- int humiAPI = 66;
- u8g2.setFont (u8g_font_unifont);
- u8g2.drawFrame (1, 1, 126, 62);
- u8g2.drawStr (10, 20, "FORECAST.io");
- u8g2.drawStr (10, 40, "TEMP:");
- u8g2.setPrintPos (90, 40);
- u8g2.print(tempAPI);
- u8g2.drawStr (109, 40, "C");
- u8g2.drawStr (10, 53, "HUMI:");
- u8g2.setPrintPos (90, 53);
- u8g2.print(humiAPI);
- u8g2.drawStr (109, 53, "%");
- }
- void loop() {
- u8g.firstPage();
- do {
- drawLocal();
- } while (u8g.nextPage() );
- u8g2.firstPage();
- do {
- drawAPI();
- } while (u8g2.nextPage() );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement