#include <WiFi.h>
#include <ArduinoJson.h>
#include <HTTPClient.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 display1(-1);
Adafruit_SSD1306 display2(-1);
// this is the default address of the display(0x78) on back of display
#define OLED1 0x3C
// this is after switching over the jumper.
#define OLED2 0x3D
int i, j;
/*#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels*/
#define NUMFLAKES 10 // Number of snowflakes in the animation example
#define LOGO_HEIGHT 16
#define LOGO_WIDTH 16
static const uint8_t image_data_Saraarray[1024] = {
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, 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, 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, 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, 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, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xff, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0xff, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x01, 0xff, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x01, 0xfe, 0x06, 0x00, 0x07, 0xf8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0xff, 0x00, 0x01, 0xfe, 0x06, 0x00, 0x07, 0xfe, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0f, 0xff, 0x00, 0x03, 0xfc, 0x07, 0x00, 0x07, 0xff, 0x80, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3f, 0xff, 0x00, 0x03, 0xfc, 0x07, 0x00, 0x07, 0xff, 0xf0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x03, 0xfc, 0x0f, 0x00, 0x07, 0xff, 0xfc, 0x00, 0x00, 0x00,
0x00, 0x00, 0x07, 0xff, 0xfe, 0x00, 0x07, 0xf8, 0x0f, 0x80, 0x03, 0xff, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1f, 0xff, 0xf8, 0x00, 0x07, 0xf8, 0x1f, 0x80, 0x00, 0x7f, 0xff, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x3f, 0xff, 0xe0, 0x00, 0x07, 0xf8, 0x1f, 0x80, 0x00, 0x1f, 0xff, 0xf0, 0x00, 0x00,
0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x0f, 0xf0, 0x1f, 0xc0, 0x00, 0x07, 0xff, 0xf0, 0x00, 0x00,
0x00, 0x00, 0x7f, 0xfc, 0x00, 0x00, 0x0f, 0xf0, 0x3f, 0xc0, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x00,
0x00, 0x00, 0x7f, 0xf0, 0x00, 0x00, 0x0f, 0xf0, 0x3f, 0xc0, 0x00, 0x00, 0x3f, 0xf0, 0x00, 0x00,
0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00, 0x1f, 0xe0, 0x1f, 0xe0, 0x00, 0x00, 0x7f, 0xf0, 0x00, 0x00,
0x00, 0x00, 0x7f, 0xfe, 0x00, 0x00, 0x1f, 0xe0, 0x1f, 0xe0, 0x00, 0x03, 0xff, 0xf0, 0x00, 0x00,
0x00, 0x00, 0x7f, 0xff, 0x80, 0x00, 0x1f, 0xe0, 0x1f, 0xf0, 0x00, 0x0f, 0xff, 0xf0, 0x00, 0x00,
0x00, 0x00, 0x3f, 0xff, 0xf0, 0x00, 0x3f, 0xc0, 0x0f, 0xf0, 0x00, 0x3f, 0xff, 0xe0, 0x00, 0x00,
0x00, 0x00, 0x07, 0xff, 0xfc, 0x00, 0x3f, 0xc0, 0x0f, 0xf0, 0x00, 0xff, 0xff, 0x80, 0x00, 0x00,
0x00, 0x00, 0x01, 0xff, 0xff, 0x00, 0x3f, 0xc0, 0xff, 0xf8, 0x07, 0xff, 0xfe, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x7f, 0x80, 0xff, 0xf8, 0x07, 0xff, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x1f, 0xff, 0x00, 0x7f, 0x81, 0xff, 0xf8, 0x07, 0xff, 0xc0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x07, 0xff, 0x00, 0xff, 0x81, 0xff, 0xfc, 0x07, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0xff, 0x00, 0xff, 0x01, 0xff, 0xfc, 0x07, 0xfc, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0xff, 0x03, 0xff, 0xfc, 0x07, 0xf0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0f, 0x01, 0xff, 0x03, 0xff, 0xfe, 0x07, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x81, 0xfe, 0x00, 0x01, 0xfe, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xfe, 0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfe, 0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfc, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfc, 0x00, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xfc, 0x00, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xf8, 0x00, 0x00, 0x7f, 0x80, 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, 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, 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, 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, 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 char* ssid = "Wokwi-GUEST";
const char* password = "";
void setup(){
display1.begin(SSD1306_SWITCHCAPVCC, OLED1);
display1.clearDisplay();
display1.display();
display2.begin(SSD1306_SWITCHCAPVCC, OLED2);
display2.clearDisplay();
display2.display();
display1.setTextSize(1);
display1.setTextColor(WHITE);
display1.setCursor(0, 0 );
display1.println("Display 1");
display1.display();
display1.clearDisplay();
display2.setTextSize(1);
display2.setTextColor(WHITE);
display2.setCursor(0, 0);
display2.println("Display 2");
display2.display();
display2.clearDisplay();
// Draw bitmap on the screen
//display1.drawBitmap(0, 0, image_data_Saraarray, 128, 64, 1);
//display1.display();
Serial.begin(115200);
delay(2000);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
Serial.println("Connecting to WiFi..");
}
Serial.println("Connected to the WiFi network");
delay(8000);
display1.ssd1306_command(SSD1306_DISPLAYOFF);
}
void loop(){
/*StaticJsonDocument<1000> dedoc;
if ((WiFi.status() == WL_CONNECTED)) { //Check the current connection status
HTTPClient http;
http.begin("https://journal.dashwww.it/ss_arduino/binance.php"); //Specify the URL
int httpCode = http.GET(); //Make the request
if (httpCode > 0) { //Check for the returning code
String payload = http.getString();
//Serial.println(payload);
deserializeJson(dedoc, payload); //JSON PARSE
JsonObject obj = dedoc.as<JsonObject>();
/*String asset = obj[String("asset")];
String symbol = obj[String("asset")][String("symbol")];
String asset_total = obj[String("asset")][String("asset_total")];
String asset_in_usd = obj[String("asset")][String("asset_in_usd")];*/
/*String asset = obj["asset"];
String symbol = obj["asset"]["symbol"];
Serial.println(asset);
Serial.println(symbol);
//if(asset == "USDT"){
/*if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
delay(2000);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 10);
display.println(symbol);
display.setCursor(0, 20);
display.println(asset_total);
display.setCursor(0, 40);
display.println(asset_in_usd);
display.display();*/
//}
/*}else{
Serial.println("Error on HTTP request");
}
http.end(); //Free the resources
}
delay(10000);*/
}