NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

#include <Adafruit_SSD1306.h>
#include <ArduinoJson.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

const int SCREEN_WIDTH = 128;
const int SCREEN_HEIGHT = 64;
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT);

const String SSID = "newtom";
const String PASSWORD = "xxx";

const String URL = "https://www.metaweather.com/api/location/2487956/";
const char* FINGERPRINT = "4ea18f92b18bbba8849b3b6eba82a7aa6ae9b4f8";

// 'c', 32x32px
const unsigned char bmp_c [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00,
0x00, 0x01, 0x80, 0x00, 0x01, 0xc3, 0xc3, 0x80, 0x01, 0xe3, 0xc7, 0x80, 0x00, 0xff, 0xff, 0x00,
0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x3f, 0xfc, 0x3f, 0xfc,
0x3f, 0xf0, 0x0f, 0xfc, 0x0f, 0xf0, 0x0f, 0xf0, 0x07, 0xe0, 0x07, 0xe0, 0x03, 0xe0, 0x07, 0xc0,
0x03, 0xe0, 0x07, 0xc0, 0x07, 0xe0, 0x07, 0xe0, 0x0f, 0xf0, 0x0f, 0xf0, 0x3f, 0xf0, 0x0f, 0xfc,
0x3f, 0xfc, 0x3f, 0xfc, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00,
0x00, 0xff, 0xff, 0x00, 0x01, 0xe3, 0xc7, 0x80, 0x01, 0xc3, 0xc3, 0x80, 0x00, 0x01, 0x80, 0x00,
0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'h', 32x32px
const unsigned char bmp_h [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x00, 0x03, 0xf8, 0x00,
0x00, 0x07, 0xfc, 0x00, 0x03, 0xcf, 0xfe, 0x00, 0x0f, 0xcf, 0xff, 0x00, 0x1f, 0xdf, 0xff, 0xe0,
0x1f, 0xdf, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xfc,
0x3f, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xfc, 0x1f, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0xff, 0xf8,
0x07, 0xff, 0xff, 0xf0, 0x01, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x90, 0x00,
0x00, 0x09, 0x90, 0x00, 0x00, 0x09, 0x90, 0x00, 0x0e, 0x09, 0x90, 0x70, 0x0e, 0xc9, 0x93, 0x70,
0x0e, 0x39, 0x9c, 0x70, 0x00, 0x18, 0x18, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x0b, 0xd0, 0x00,
0x00, 0x0b, 0xd0, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'hr', 32x32px
const unsigned char bmp_hr [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x00, 0x03, 0xf8, 0x00,
0x00, 0x07, 0xfc, 0x00, 0x03, 0xcf, 0xfe, 0x00, 0x0f, 0xcf, 0xff, 0x00, 0x1f, 0xdf, 0xff, 0xe0,
0x1f, 0xdf, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xfc,
0x3f, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xfc, 0x1f, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0xff, 0xf8,
0x07, 0xff, 0xff, 0xf0, 0x01, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x40,
0x03, 0x0c, 0x30, 0xc0, 0x03, 0x0c, 0x30, 0xc0, 0x07, 0x1c, 0x38, 0xe0, 0x07, 0x9e, 0x79, 0xe0,
0x07, 0x6d, 0xb6, 0xe0, 0x00, 0x61, 0x86, 0x00, 0x00, 0x61, 0x86, 0x00, 0x00, 0xf3, 0xcf, 0x00,
0x00, 0xe3, 0xc7, 0x00, 0x00, 0x61, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'hc', 32x32px
const unsigned char bmp_hc [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3f, 0x00, 0x00, 0x00, 0x7f, 0x80, 0x00, 0x00, 0xff, 0xc0, 0x00, 0x0f, 0xff, 0xfc, 0x00,
0x1f, 0xff, 0xfe, 0x00, 0x1f, 0xff, 0xfe, 0x00, 0x3f, 0xff, 0xff, 0x00, 0x3f, 0xff, 0xff, 0x00,
0x3f, 0xff, 0xff, 0x00, 0x1f, 0xff, 0xc2, 0x00, 0x1f, 0xff, 0x38, 0x00, 0x0f, 0xfe, 0xfe, 0x00,
0x00, 0x01, 0xff, 0x00, 0x00, 0x19, 0xff, 0x80, 0x00, 0x7b, 0xff, 0x80, 0x00, 0xfb, 0xff, 0xf0,
0x01, 0xff, 0xff, 0xf8, 0x01, 0xff, 0xff, 0xf8, 0x01, 0xff, 0xff, 0xfc, 0x01, 0xff, 0xff, 0xfc,
0x01, 0xff, 0xff, 0xfc, 0x01, 0xff, 0xff, 0xfc, 0x00, 0xff, 0xff, 0xf8, 0x00, 0x7f, 0xff, 0xf0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'lc', 32x32px
const unsigned char bmp_lc [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x04, 0x18, 0x00,
0x00, 0x06, 0x38, 0x00, 0x00, 0x07, 0xb8, 0x60, 0x00, 0x07, 0xff, 0xc0, 0x00, 0x07, 0xff, 0xc0,
0x00, 0x7f, 0xff, 0x80, 0x00, 0x7f, 0x03, 0x80, 0x00, 0x1e, 0x03, 0xf8, 0x00, 0x1e, 0x01, 0xfc,
0x00, 0x1c, 0x01, 0xf0, 0x00, 0x7c, 0x01, 0xc0, 0x00, 0xf8, 0xe1, 0xc0, 0x00, 0x33, 0xf9, 0xe0,
0x00, 0x07, 0xfc, 0xf0, 0x01, 0xcf, 0xfe, 0x78, 0x07, 0xcf, 0xfe, 0x00, 0x0f, 0xdf, 0xff, 0xe0,
0x1f, 0xdf, 0xff, 0xf0, 0x1f, 0xff, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xfc,
0x3f, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xfc, 0x1f, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xf8,
0x0f, 0xff, 0xff, 0xf0, 0x03, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'lr', 32x32px
const unsigned char bmp_lr [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0xf8, 0x00, 0x00, 0x07, 0xfc, 0x00, 0x00, 0x0f, 0xfe, 0x00, 0x07, 0xcf, 0xfe, 0x00,
0x0f, 0xdf, 0xff, 0xc0, 0x1f, 0xdf, 0xff, 0xf0, 0x1f, 0xff, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xf8,
0x3f, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xfc, 0x1f, 0xff, 0xff, 0xfc,
0x1f, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x61, 0x86, 0x00,
0x00, 0x61, 0x86, 0x00, 0x00, 0xe3, 0xc7, 0x00, 0x00, 0xf3, 0xcf, 0x00, 0x00, 0xe1, 0x87, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 's', 32x32px
const unsigned char bmp_s [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0c, 0x00,
0x00, 0x01, 0x8c, 0x60, 0x00, 0x00, 0xff, 0xe0, 0x00, 0x00, 0xff, 0xc0, 0x00, 0x00, 0x37, 0xc0,
0x00, 0x03, 0x81, 0xfc, 0x00, 0x0f, 0xe0, 0xf8, 0x00, 0x1f, 0xf0, 0xf0, 0x03, 0xbf, 0xf0, 0xe0,
0x0f, 0xbf, 0xf8, 0xf0, 0x1f, 0xbf, 0xfe, 0x78, 0x1f, 0xff, 0xff, 0x38, 0x3f, 0xff, 0xff, 0x80,
0x3f, 0xff, 0xff, 0x80, 0x3f, 0xff, 0xff, 0x80, 0x3f, 0xff, 0xff, 0x80, 0x1f, 0xff, 0xff, 0x80,
0x0f, 0xff, 0xff, 0x00, 0x07, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x04, 0x10, 0x00, 0x01, 0x86, 0x18, 0x00, 0x03, 0x8e, 0x38, 0x00, 0x03, 0x8e, 0x38, 0x00,
0x03, 0x8e, 0x38, 0x00, 0x01, 0x86, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'sl', 32x32px
const unsigned char bmp_sl [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0xf8, 0x00, 0x00, 0x07, 0xfc, 0x00, 0x00, 0x0f, 0xfe, 0x00, 0x07, 0xcf, 0xfe, 0x00,
0x0f, 0xdf, 0xff, 0xc0, 0x1f, 0xdf, 0xff, 0xf0, 0x1f, 0xff, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xf8,
0x3f, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xfc, 0x1f, 0xff, 0xff, 0xfc,
0x1f, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x40, 0x02, 0x00, 0x00, 0xe3, 0xc7, 0x00, 0x00, 0xf3, 0xcf, 0x00, 0x00, 0x61, 0x86, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x1e, 0x78, 0x00, 0x00, 0x1c, 0x38, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 't', 32x32px
const unsigned char bmp_t [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x00, 0x03, 0xf8, 0x00,
0x00, 0x07, 0xfc, 0x00, 0x03, 0xcf, 0xfe, 0x00, 0x0f, 0xcf, 0xff, 0x00, 0x1f, 0xdf, 0xff, 0xe0,
0x1f, 0xdf, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xfc,
0x3f, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xfc, 0x1f, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0xff, 0xf8,
0x07, 0xff, 0xff, 0xf0, 0x01, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xe0, 0x00,
0x00, 0x0f, 0xc0, 0x00, 0x00, 0x1f, 0xc0, 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0x3f, 0xf0, 0x00,
0x00, 0x07, 0xc0, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00,
0x00, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'sn', 32x32px
const unsigned char bmp_sn [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0xf8, 0x00, 0x00, 0x07, 0xfc, 0x00, 0x00, 0x0f, 0xfe, 0x00, 0x07, 0xcf, 0xfe, 0x00,
0x0f, 0xdf, 0xff, 0xc0, 0x1f, 0xdf, 0xff, 0xf0, 0x1f, 0xff, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xf8,
0x3f, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xfc, 0x1f, 0xff, 0xff, 0xfc,
0x1f, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x03, 0xe3, 0xc7, 0xc0,
0x03, 0xe3, 0xc7, 0xc0, 0x07, 0xe7, 0xe7, 0xe0, 0x03, 0xe3, 0xc7, 0xc0, 0x02, 0x81, 0x81, 0x40,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

void setup() {
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.setTextColor(WHITE);

display.clearDisplay();
display.setCursor(0, 0);
display.print("Connect " + SSID + "...");
display.display();

WiFi.begin(SSID, PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(10);
}
}

void loop() {
WiFiClientSecure client;
client.setFingerprint(FINGERPRINT);
HTTPClient http;
http.begin(client, URL);
int code = http.GET();

display.clearDisplay();
if (code == HTTP_CODE_OK) {
String payload = http.getString();
DynamicJsonDocument doc(10000);
deserializeJson(doc, payload);

display.fillRect(0, 0, 128, 12, WHITE);
display.setTextColor(BLACK);
display.setCursor(2, 2);
String title = doc["title"];
display.print(title);

display.setCursor(97, 2);
String time = doc["time"];
display.print(time.substring(11, 16));

for (int i = 0; i < 3; i++) {
display.setTextColor(WHITE);
display.setCursor(i * 48, 16);
String date = doc["consolidated_weather"][i]["applicable_date"];
display.print(date.substring(5, 7) + "/" + date.substring(8, 10));

String state = doc["consolidated_weather"][i]["weather_state_abbr"];
const unsigned char* bmp = NULL;
if (state == "c") {
bmp = bmp_c;
} else if (state == "h") {
bmp = bmp_h;
} else if (state == "hc") {
bmp = bmp_hc;
} else if (state == "hr") {
bmp = bmp_hr;
} else if (state == "lc") {
bmp = bmp_lc;
} else if (state == "lr") {
bmp = bmp_lr;
} else if (state == "s") {
bmp = bmp_s;
} else if (state == "sl") {
bmp = bmp_sl;
} else if (state == "sn") {
bmp = bmp_sn;
} else if (state == "t") {
bmp = bmp_t;
}
if (bmp != NULL)
display.drawBitmap(i * 48, 23, bmp, 32, 32, WHITE);

display.setCursor(i * 48, 56);
float low = doc["consolidated_weather"][i]["min_temp"];
display.print(low, 0);
display.print("~");
float high = doc["consolidated_weather"][i]["max_temp"];
display.print(high, 0);
}
}
display.display();

delay(5000);
}

     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.