Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32C3 and SIM800L Powered Smart Energy Monitor with OLED Display and Wi-Fi Connectivity

View and Edit Project In Cirkit DesignerImage of ESP32C3 and SIM800L Powered Smart Energy Monitor with OLED Display and Wi-Fi Connectivity

Circuit Documentation

Summary

This circuit is designed to monitor power usage from various slave devices and display the total wattage on a 0.96" OLED display. The circuit includes an ESP32C3 microcontroller, a SIM800L GSM module for SMS communication, and a Mini AC-DC module for power conversion. The ESP32C3 collects data from slave devices via WiFi and SMS, processes the data, and displays the total wattage on the OLED display.

Component List

  1. 0.96" OLED

    • Pins: GND, VDD, SCK, SDA
    • Description: OLED display for showing total wattage.
    • Purpose: Display total wattage collected from slave devices.
  2. Mini AC-DC 110V-230V to 5V 700mA Module

    • Pins: GND, 5v, Neutral, Life
    • Description: AC-DC converter module.
    • Purpose: Convert AC power to 5V DC for powering the circuit.
  3. SIM 800L V2.0 GSM

    • Pins: SIM_TXD, VDD, SIM.RXD, 5V/4V, GND, RST
    • Description: GSM module for SMS communication.
    • Purpose: Send and receive SMS for data collection.
  4. ESP32C3 Supermini

    • Pins: GPIO05, GPIO06, GPIO07, GPIO08, GPIO09, GPIO10, GPIO20, GPIO21, GPIO00, GPIO01, GPIO02, GPIO03, GPIO04, 3.3V, GND, +5V
    • Description: Microcontroller for data processing and communication.
    • Purpose: Collect data from slave devices and display it on the OLED.
  5. AC power plug

    • Pins: positive terminal, negative terminal
    • Description: AC power plug.
    • Purpose: Provide AC power to the circuit.
  6. Resistor (200 Ohms)

    • Pins: pin1, pin2
    • Description: Resistor.
    • Purpose: Current limiting for LEDs.
  7. LED: Two Pin (red)

    • Pins: cathode, anode
    • Description: Red LED.
    • Purpose: Visual indicator.
  8. LED: Two Pin (green)

    • Pins: cathode, anode
    • Description: Green LED.
    • Purpose: Visual indicator.

Wiring Details

0.96" OLED

Mini AC-DC 110V-230V to 5V 700mA Module

SIM 800L V2.0 GSM

ESP32C3 Supermini

AC power plug

Resistor (200 Ohms)

Resistor (200 Ohms)

LED: Two Pin (red)

LED: Two Pin (green)

Code Documentation

/*
 * This Arduino Sketch is for an ESP32C3 microcontroller that acts as a master
 * device. It collects power usage data from slave devices via WiFi and SMS,
 * and displays the total wattage used on a 0.96" OLED display.
 */
#include <HTTPClient.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <WiFi.h>
#include <SoftwareSerial.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET    -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";

SoftwareSerial sim800l(21, 20); // RX, TX

void setup() {
  // Initialize Serial for debugging
  Serial.begin(115200);

  // Initialize OLED display
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  display.display();
  delay(2000);
  display.clearDisplay();

  // Initialize WiFi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }
  Serial.println("Connected to WiFi");

  // Initialize SIM800L
  sim800l.begin(9600);
  delay(1000);
  sim800l.println("AT");
  delay(100);
  sim800l.println("AT+CMGF=1"); // Set SMS to text mode
  delay(100);
}

void loop() {
  // Placeholder for collecting data from slaves via WiFi and SMS
  float totalWattage = getTotalWattageFromSlaves();

  // Display total wattage on OLED
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);
  display.print("Total Wattage: ");
  display.print(totalWattage);
  display.println(" W");
  display.display();

  delay(5000); // Update every 5 seconds
}

float getTotalWattageFromSlaves() {
   float totalWattage = 0.0;
  const char* slaveIPs[] = {"192.168.1.101", "192.168.1.102"}; // IP addresses of slave devices
  const int numSlaves = sizeof(slaveIPs) / sizeof(slaveIPs[0]);

  for (int i = 0; i < numSlaves; i++) {
    HTTPClient http;
    String url = String("http://") + slaveIPs[i] + "/getWattage";
    http.begin(url);
    int httpCode = http.GET();

    if (httpCode > 0) {
      String payload = http.getString();
      totalWattage += payload.toFloat();
    } else {
      Serial.print("Error on HTTP request to ");
      Serial.println(slaveIPs[i]);
    }

    http.end();
  }

  return totalWattage;
}

This code initializes the ESP32C3 microcontroller, connects to WiFi, and sets up the SIM800L GSM module for SMS communication. It collects power usage data from slave devices via WiFi and SMS, and displays the total wattage on a 0.96" OLED display. The