7.5-inch E-Paper WiFi Weather Station — Esp32 Devkit C V4 simulation

An interactive Esp32 Devkit C V4 circuit simulation you can run free in your browser on Velxio, by tareq-neoaz.

Components

Sketch code

#include <WiFi.h>
#include <Wire.h>
#include <SPI.h>
#include <GxEPD2_BW.h>
#include <Fonts/FreeMonoBold24pt7b.h>
#include <Fonts/FreeMonoBold12pt7b.h>
#include <DHT.h>

const char* ssid = "Velxio-GUEST";
const char* password = "";

GxEPD2_BW<GxEPD2_750_T7, GxEPD2_750_T7::HEIGHT> display(
  GxEPD2_750_T7(/*CS=*/5, /*DC=*/17, /*RST=*/16, /*BUSY=*/4));

#define DHT_PIN 33
DHT dht(DHT_PIN, DHT22);
#define UV_PIN 34

int weatherType = 0; 
String weatherMain = "SUNNY";
float outdoorTemp = 28.5;
float outdoorHum = 45.0;

void setup() {
  Serial.begin(115200);
  
  SPI.begin(18, 19, 23, 5); 
  Wire.begin(21, 22);
  delay(500);
  
  display.init(115200, true, 50, false);
  display.setRotation(0); 
  display.setFullWindow();
  dht.begin();

  WiFi.begin(ssid, password);
  int attempts = 0;
  while (WiFi.status() != WL_CONNECTED && attempts < 10) {
    delay(500);
    attempts++;
  }
  
  updateWeather();
  updateDisplay();
}

void updateWeather() {
  int uvValue = analogRead(UV_PIN);
  
  int uvi = map(uvValue, 0, 2000, 0, 15);
  uvi = constrain(uvi, 0, 15); 
  
  if (uvi >= 8) { 
    weatherType = 0; 
    weatherMain = "SUNNY"; 
    outdoorTemp = 28.5; 
    outdoorHum = 45.0; 
  }
  else if (uvi >= 4) { 
    weatherType = 1; 
    weatherMain = "CLOUDY"; 
    outdoorTemp = 22.0; 
    outdoorHum = 65.0; 
  }
  else { 
    weatherType = 2; 
    weatherMain = "RAINY"; 
    outdoorTemp = 16.5; 
    outdoorHum = 85.0; 
  }
  
  Serial.print("UVI: "); Serial.println(uvi);
}

void drawWeatherIcon(int x, int y, int type) {
  if (type == 0) { // Sun
    display.fillCircle(x, y, 40, GxEPD_BLACK);
    for(int i = 0; i < 8; i++) {
      float angle = i * PI / 4;
      display.drawLine(x + cos(angle)*50, y + sin(angle)*50, x + cos(angle)*70, y + sin(angle)*70, GxEPD_BLACK);
    }
  } else if (type == 1) { // Cloud
    display.fillCircle(x - 20, y, 30, GxEPD_BLACK);
    display.fillCircle(x + 20, y, 35, GxEPD_BLACK);
    display.fillCircle(x, y - 20, 30, GxEPD_BLACK);
    display.fillRect(x - 50, y, 100, 30, GxEPD_BLACK);
  } else if (type == 2) { // Rain
    // Cloud
    display.fillCircle(x - 15, y - 15, 25, GxEPD_BLACK);
    display.fillCircle(x + 15, y - 15, 30, GxEPD_BLACK);
    display.fillCircle(x, y - 30, 25, GxEPD_BLACK);
    display.fillRect(x - 40, y - 15, 80, 25, GxEPD_BLACK);
    
    // Detached Raindrops
    display.fillCircle(x - 30, y + 15, 4, GxEPD_BLACK);
    display.fillTriangle(x - 30, y + 5, x - 34, y + 15, x - 26, y + 15, GxEPD_BLACK);
    
    display.fillCircle(x - 10, y + 25, 4, GxEPD_BLACK);
    display.fillTriangle(x - 10, y + 15, x - 14, y + 25, x - 6, y + 25, GxEPD_BLACK);
    
    display.fillCircle(x + 12, y + 18, 4, GxEPD_BLACK);
    display.fillTriangle(x + 12, y + 8, x + 8, y + 18, x + 16, y + 18, GxEPD_BLACK);
    
    display.fillCircle(x + 30, y + 28, 4, GxEPD_BLACK);
    display.fillTriangle(x + 30, y + 18, x + 26, y + 28, x + 34, y + 28, GxEPD_BLACK);
  }
}

void updateDisplay() {
  float indoorTemp = dht.readTemperature();
  flo

More projects by tareq-neoaz