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

ESP32-Based Solar-Powered Current Monitoring System with OLED Display

View and Edit Project In Cirkit DesignerImage of ESP32-Based Solar-Powered Current Monitoring System with OLED Display

Circuit Documentation

Summary

This circuit is designed to measure current using an ACS712 Current Sensor and display the readings on a 0.96" OLED screen. It is controlled by an ESP32 microcontroller, which processes the sensor data and manages the display. The circuit is powered by a 12V 5Ah battery, which is regulated down to a lower voltage suitable for the components using an LM2596 Step Down Module. Photocells (LDRs) are included to potentially measure light intensity, and servomotors are present, possibly for actuation based on the microcontroller's logic. The circuit includes various resistors and a ceramic capacitor for stability and voltage division.

Component List

Power Supply Components

Sensing and Actuation Components

Display Components

Processing Components

Passive Components

Wiring Details

LM2596 Step Down Module

0.96" OLED

ACS712 Current Sensor

Photocells (LDR)

Servomotor MG90S

Resistors and Capacitor

Documented Code

ESP32 Microcontroller Code

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

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

const int currentSensorPin = 35; // Pin connected to ACS712 OUT

void setup() {
  // Initialize serial communication
  Serial.begin(115200);

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

  // Initialize the current sensor pin
  pinMode(currentSensorPin, INPUT);
}

void loop() {
  // Read the current sensor value
  int sensorValue = analogRead(currentSensorPin);
  float voltage = sensorValue * (3.3 / 4095.0); // Convert to voltage
  float current = (voltage - 2.5) / 0.185; // Convert to current (assuming 5A sensor)

  // Display the current on the OLED
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);
  display.print("Current: ");
  display.print(current);
  display.println(" A");
  display.display();

  // Print the current to the serial monitor
  Serial.print("Current: ");
  Serial.print(current);
  Serial.println(" A");

  delay(1000); // Wait for a second before the next reading
}

This code snippet is for the ESP32 microcontroller. It initializes the OLED display and reads the current sensor's output. The current is calculated from the sensor's voltage output and displayed on the OLED screen. The current value is also sent to the serial monitor for debugging purposes.