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

STM32 and ESP8266-Based Electric Grid Monitoring and Control System with I2C LCD Display

View and Edit Project In Cirkit DesignerImage of STM32 and ESP8266-Based Electric Grid Monitoring and Control System with I2C LCD Display

Electric Grid Monitoring and Control System

Summary

This circuit is designed to monitor and control an electric grid. It uses voltage and current sensors to measure the grid parameters and displays the readings on a 16x2 I2C LCD screen. The system is powered by a 3.3V battery and controlled by an STM32 microcontroller. Additionally, an ESP8266 WiFi module is used for remote monitoring, and a relay module is used to manage the load based on the measured parameters.

Component List

  1. LCD screen 16x2 I2C

    • Description: A 16x2 character LCD screen with I2C interface.
    • Pins: SCL, SDA, VCC, GND
  2. Ac Supply

    • Description: AC power supply.
    • Pins: +ve, -ve
  3. BULB

    • Description: Standard light bulb.
    • Pins: +, -
  4. ZMPT101B

    • Description: Voltage sensor module.
    • Pins: OUT, GND, VCC, NEUTRO, FASE
  5. ACS712 Current Sensor 5A 20A 30A

    • Description: Current sensor module.
    • Pins: 1, 2, GND, OUT, VCC
  6. STM32F0DISCOVEREY

    • Description: STM32 microcontroller development board.
    • Pins: gnd, PB9, PB8, VDD, PA1, PA0, PA9, PA10, PA11
  7. 3.3v battery

    • Description: 3.3V battery for powering the circuit.
    • Pins: +, -
  8. Relay module 5v-30v

    • Description: Relay module for controlling the load.
    • Pins: common contact, normally open, normally closed, trigger, V-, V+
  9. ESP8266 ESP-12E WiFi Module

    • Description: WiFi module for remote monitoring.
    • Pins: GND, GPIO_15, GPIO_2, GPIO_0, GPIO_4, GPIO_5, RXD, TXD, REST, ADC_0, CH_PD, GPIO_16, GPIO_14, GPIO_12, GPIO_13, VCC

Wiring Details

LCD screen 16x2 I2C

Ac Supply

BULB

ZMPT101B

ACS712 Current Sensor 5A 20A 30A

STM32F0DISCOVEREY

3.3v battery

Relay module 5v-30v

ESP8266 ESP-12E WiFi Module

Documented Code

STM32F0DISCOVEREY Code

/*
 * Electric Grid Monitoring and Controlling
 * This code monitors voltage and current using ZMPT101B and ACS712 sensors
 * and displays the readings on a 16x2 I2C LCD screen. The system is powered
 * by a 3.3V battery and controlled by a TI microcontroller.
 */

#include <msp430.h>
#include "lcd.h"

// Pin definitions
#define VOLTAGE_SENSOR_PIN BIT0 // Assuming P1.0
#define CURRENT_SENSOR_PIN BIT1 // Assuming P1.1

void setup() {
  // Stop watchdog timer
  WDTCTL = WDTPW | WDTHOLD;

  // Initialize the LCD
  lcd_init();
  lcd_clear();
  lcd_set_cursor(0, 0);
  lcd_print("Grid Monitor");
  __delay_cycles(2000000);
  lcd_clear();

  // Initialize ADC
  ADC10CTL1 = INCH_1; // Channel 1 (P1.1)
  ADC10CTL0 = SREF_0 + ADC10SHT_2 + ADC10ON + ADC10IE;
}

void loop() {
  // Read voltage value
  ADC10CTL0 |= ENC + ADC10SC; // Start conversion
  while (ADC10CTL1 & ADC10BUSY); // Wait for conversion to complete
  float voltage = ADC10MEM * (3.3 / 1023.0);

  // Read current value
  ADC10CTL1 = INCH_0; // Channel 0 (P1.0)
  ADC10CTL0 |= ENC + ADC10SC; // Start conversion
  while (ADC10CTL1 & ADC10BUSY); // Wait for conversion to complete
  float current = ADC10MEM * (3.3 / 1023.0);

  // Display voltage and current on LCD
  lcd_set_cursor(0, 0);
  lcd_print("Voltage: ");
  lcd_print_float(voltage);
  lcd_print("V");

  lcd_set_cursor(0, 1);
  lcd_print("Current: ");
  lcd_print_float(current);
  lcd_print("A");

  // Print values to serial monitor (