#include <WiFi.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "Org_01.h"
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
const char* ssid = "Wokwi-GUEST";
const char* password = "";
int waterLitter = 500;
int waterDistance = 100;
// 'bell', 16x16px
const unsigned char icon_bell [] PROGMEM = {
0x00, 0x00, 0x07, 0xe0, 0x0c, 0x30, 0x08, 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x10, 0x08, 0x10, 0x08, 0x30, 0x0c, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00
};
// 'bell-off', 16x16px
const unsigned char icon_bell_off [] PROGMEM = {
0x80, 0x00, 0xc7, 0xc0, 0x60, 0x70, 0x38, 0x10, 0x18, 0x10, 0x1c, 0x18, 0x1e, 0x18, 0x1b, 0x08,
0x11, 0xc8, 0x10, 0x60, 0x30, 0x70, 0x7f, 0xf8, 0x00, 0x0c, 0x00, 0x06, 0x01, 0x83, 0x00, 0x01
};
// 'database', 16x16px
const unsigned char icon_database [] PROGMEM = {
0x00, 0x00, 0x1f, 0xf8, 0x20, 0x0c, 0x60, 0x06, 0x7c, 0x3e, 0x6f, 0xf6, 0x60, 0x06, 0x60, 0x06,
0x60, 0x06, 0x7f, 0xfe, 0x67, 0xe6, 0x60, 0x06, 0x60, 0x06, 0x20, 0x0c, 0x1f, 0xf8, 0x00, 0x00
};
// 'download', 16x16px
const unsigned char icon_download [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x09, 0x90, 0x0d, 0xb0,
0x07, 0xe0, 0x03, 0x80, 0x61, 0x86, 0x60, 0x06, 0x60, 0x06, 0x3f, 0xfc, 0x1f, 0xf8, 0x00, 0x00
};
// 'upload', 16x16px
const unsigned char icon_upload [] PROGMEM = {
0x00, 0x00, 0x01, 0x80, 0x03, 0x80, 0x07, 0xe0, 0x0d, 0xb0, 0x09, 0x90, 0x01, 0x80, 0x01, 0x80,
0x01, 0x80, 0x01, 0x80, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x3f, 0xfc, 0x1f, 0xf8, 0x00, 0x00
};
// 'wifi', 16x16px
const unsigned char icon_wifi [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xf0, 0x3c, 0x3c, 0x60, 0x06, 0x07, 0xe0, 0x1c, 0x38,
0x10, 0x08, 0x01, 0x80, 0x07, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00
};
// 'wifi-off', 16x16px
const unsigned char icon_wifi_off [] PROGMEM = {
0x80, 0x00, 0xc0, 0x00, 0x60, 0x00, 0x39, 0xf0, 0x38, 0x3c, 0x6c, 0x06, 0x07, 0x00, 0x1f, 0x18,
0x11, 0xc8, 0x01, 0xe0, 0x07, 0xf0, 0x00, 0x38, 0x00, 0x0c, 0x01, 0x86, 0x00, 0x03, 0x00, 0x01
};
// 'mode', 16x16px
const unsigned char icon_mode [] PROGMEM = {
0x00, 0x00, 0x00, 0x80, 0x01, 0x80, 0x03, 0x80, 0x06, 0x80, 0x0d, 0x80, 0x09, 0xfc, 0x10, 0x0c,
0x30, 0x08, 0x7f, 0x90, 0x01, 0xb0, 0x01, 0x60, 0x01, 0xc0, 0x01, 0x80, 0x01, 0x00, 0x00, 0x00
};
// 'mode-off', 16x16px
const unsigned char icon_mode_off [] PROGMEM = {
0x80, 0x00, 0x40, 0x80, 0x21, 0x80, 0x11, 0x80, 0x0c, 0x80, 0x0c, 0x00, 0x0e, 0x3c, 0x11, 0x0c,
0x31, 0x88, 0x7f, 0xc0, 0x01, 0xf0, 0x01, 0x70, 0x01, 0xc8, 0x01, 0x84, 0x01, 0x02, 0x00, 0x01
};
void setup()
{
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // here the 0x3c is the I2C address, check your i2c address if u have multiple devices.
display.clearDisplay();
delay(20);
welcomeMessage();
delay(3000);
connectMessage();
delay(3000);
WiFi.begin(ssid, password, 6);
}
void loop()
{
textInfo();
iconInfo();
}
void welcomeMessage(){
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
display.setFont(&Org_01);
display.setCursor(30, 10);
display.print("Welcome to");
display.setCursor(15, 22);
display.print("MS Home Automation");
display.display();
}
void connectMessage(){
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
display.setFont(&Org_01);
display.setCursor(30, 10);
display.print("Connecting to...");
display.setCursor(20, 22);
display.print("MS Smart Home");
display.display();
}
void textInfo() {
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(2);
display.setFont(&Org_01);
display.setCursor(1, 15);
display.print("Wtr: ");
display.print(waterLitter);
display.print(" ");
display.print("L");
display.setCursor(1, 35);
display.print("Dist: ");
display.print(waterDistance);
display.print(" ");
display.print("%");
}
void iconInfo(){
display.drawBitmap(0, 48, WiFi.status() == WL_CONNECTED ? icon_wifi : icon_wifi_off, 16, 16, WHITE);
display.drawBitmap(25, 48, icon_bell, 16, 16, WHITE);
display.drawBitmap(50, 48, icon_download, 16, 16, WHITE);
display.drawBitmap(75, 48, icon_mode, 16, 16, WHITE);
display.drawBitmap(100, 48, icon_database, 16, 16, WHITE);
display.display();
}
esp:0
esp:2
esp:4
esp:5
esp:12
esp:13
esp:14
esp:15
esp:16
esp:17
esp:18
esp:19
esp:21
esp:22
esp:23
esp:25
esp:26
esp:27
esp:32
esp:33
esp:34
esp:35
esp:3V3
esp:EN
esp:VP
esp:VN
esp:GND.1
esp:D2
esp:D3
esp:CMD
esp:5V
esp:GND.2
esp:TX
esp:RX
esp:GND.3
esp:D1
esp:D0
esp:CLK
oled1:GND
oled1:VCC
oled1:SCL
oled1:SDA