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

ESP32-Based Electric Grid Monitoring and Control System with TFT Display and NeoPixel Ring

View and Edit Project In Cirkit DesignerImage of ESP32-Based Electric Grid Monitoring and Control System with TFT Display and NeoPixel Ring

Circuit Documentation

Summary

This document provides a detailed overview of an electric grid monitoring and control system. The system includes various components such as relays, a TFT display, an energy monitor, a NeoPixel ring, and an ESP32 microcontroller. The system is designed to monitor and control the electric grid by measuring voltage, current, power, and energy, and displaying this information on a TFT screen. Additionally, it uses relays to control the grid based on the measured parameters and provides visual feedback using a NeoPixel ring.

Component List

  1. 5V 2-Relay JD-VCC

    • Description: A relay module that allows control of high voltage devices using low voltage signals.
    • Pins: JD-VCC, VCC, GND, IN1, IN2, NO, COM, NC
  2. XL4015 5A DC Buck Step-down

    • Description: A DC-DC buck converter that steps down voltage from a higher input to a lower output.
    • Pins: Output +, Output -, Input +, Input -
  3. DC Power Source

    • Description: Provides DC power to the circuit.
    • Pins: Ground, Positive
  4. Ac Supply

    • Description: Provides AC power to the circuit.
    • Pins: +ve, -ve
  5. Adafruit 12 NeoPixel Ring

    • Description: A ring of 12 individually addressable RGB LEDs.
    • Pins: OUT, VDD, IN, GND
  6. PZEM004t

    • Description: An energy monitor that measures voltage, current, power, and energy.
    • Pins: VCC, RX, TX, GND, IN, OUT
  7. Socket

    • Description: A standard electrical socket.
    • Pins: earth, life, neutral
  8. ST7735 128x128 1.44 TFT I2C Color

    • Description: A 1.44-inch TFT display with I2C interface.
    • Pins: BL, C5, DC, RES, SDA, SCL, GND, VCC
  9. ESP32 (30 pin)

    • Description: A powerful microcontroller with Wi-Fi and Bluetooth capabilities.
    • Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, Vin, D23, D22, TX0, RX0, D21, D19, D18, D5, TX2, RX2, D4, D2, D15, 3V3
  10. Circuit Breaker

    • Description: A safety device that interrupts the flow of current in case of an overload or short circuit.
    • Pins: -, +

Wiring Details

5V 2-Relay JD-VCC

XL4015 5A DC Buck Step-down

DC Power Source

Ac Supply

Adafruit 12 NeoPixel Ring

PZEM004t

Socket

ST7735 128x128 1.44 TFT I2C Color

ESP32 (30 pin)

Circuit Breaker

Documented Code

ESP32 (30 pin)

/*
 * Electric Grid Monitoring and Control System
 * This code interfaces with relays, a TFT display, a PZEM004T energy monitor,
 * and a NeoPixel ring to monitor and control an electric grid.
 */

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <Adafruit_NeoPixel.h>
#include <PZEM004Tv30.h>

#define RELAY1_PIN 14
#define RELAY2_PIN 27
#define TFT_CS 5
#define TFT_RST 4
#define TFT_DC 2
#define NEOPIXEL_PIN 17
#define NUMPIXELS 12

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800);
PZEM004Tv30 pzem(D16, D17);

void setup() {
  pinMode(RELAY1_PIN, OUTPUT);
  pinMode(RELAY2_PIN, OUTPUT);
  digitalWrite(RELAY1_PIN, LOW);
  digitalWrite(RELAY2_PIN, LOW);
  tft.initR(INITR_BLACKTAB);
  tft.fillScreen(ST77XX_BLACK);
  tft.setTextColor(ST77XX_WHITE);
  tft.setTextSize(1);
  strip.begin();
  strip.show();
  Serial.begin(115200);
}

void loop() {
  float voltage = pzem.voltage();
  float current = pzem.current();
  float power = pzem.power();
  float energy = pzem.energy();
  tft.setCursor(0, 0);
  tft.print("Voltage: "); tft.print(voltage); tft.println("V");
  tft.print("Current: "); tft.print(current); tft.println("A");
  tft.print("Power: "); tft.print