Wemos S2 Mini Solar-Powered Battery Monitoring System with Wi-Fi Connectivity
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to monitor the voltage and power of a solar panel and a battery. It uses a Wemos S2 Mini microcontroller to read the voltages from the solar panel and battery through voltage dividers and then sends the data to an MQTT server. The circuit is powered by a 12V battery, which is regulated down to 3.3V using a Mini-360 DC-DC Step Down Buck Converter. A fuse is included for protection.
Component List
Wemos S2 Mini
- Description: Microcontroller used for reading voltages and sending data to the MQTT server.
- Pins: EN, GPIO 3, GPIO 5, GPIO 7, GPIO 9, GPIO 11, GPIO 12, 3.3V, GPIO 1, GPIO 2, GPIO 4, GPIO 6, GPIO 8, GPIO 10, GPIO 13, GPIO 14, VBUS, GND, GPIO 16, GPIO 18, GPIO 33, GPIO 35, GPIO 37, GPIO 39, GPIO 15, GPIO 17, GPIO 21, GPIO 34, GPIO 36, GPIO 38, GPIO 40
Mini-360 DC-DC Step Down Buck Converter
- Description: Converts 12V from the battery to 3.3V for the Wemos S2 Mini.
- Pins: Input -, Input +, Output +, Output -
Resistor (10k Ohms)
- Description: Part of the voltage divider for the battery.
- Pins: pin1, pin2
Resistor (8.2k Ohms)
- Description: Part of the voltage divider for the solar panel.
- Pins: pin1, pin2
Resistor (33k Ohms)
- Description: Part of the voltage divider for the battery.
- Pins: pin1, pin2
Resistor (47k Ohms)
- Description: Part of the voltage divider for the solar panel.
- Pins: pin1, pin2
Fuse
- Description: Provides overcurrent protection.
- Pins: Terminal 1, Terminal 2
Solar Panel
- Description: Provides power to the circuit.
- Pins: +, -
12V Battery
- Description: Powers the circuit.
- Pins: VCC, GND
SD30CRMA MPPT
- Description: Maximum Power Point Tracking (MPPT) controller for the solar panel.
- Pins: GND, VIN, BAT
Wiring Details
Wemos S2 Mini
- 3.3V: Connected to Terminal 1 of the Fuse.
- GPIO 1: Connected to pin2 of the 47k Ohms Resistor and pin2 of the 8.2k Ohms Resistor.
- GPIO 2: Connected to pin1 of the 33k Ohms Resistor and pin1 of the 10k Ohms Resistor.
- GND: Connected to Output - of the Mini-360 DC-DC Step Down Buck Converter.
Mini-360 DC-DC Step Down Buck Converter
- Input -: Connected to GND of the 12V Battery, pin2 of the 10k Ohms Resistor, GND of the SD30CRMA MPPT, GND of the SD30CRMA MPPT, pin1 of the 8.2k Ohms Resistor, and - of the Solar Panel.
- Input +: Connected to VCC of the 12V Battery, BAT of the SD30CRMA MPPT, and pin2 of the 33k Ohms Resistor.
- Output +: Connected to Terminal 2 of the Fuse.
Resistor (10k Ohms)
- pin1: Connected to GPIO 2 of the Wemos S2 Mini and pin1 of the 33k Ohms Resistor.
- pin2: Connected to GND of the 12V Battery, GND of the SD30CRMA MPPT, GND of the SD30CRMA MPPT, pin1 of the 8.2k Ohms Resistor, and - of the Solar Panel.
Resistor (8.2k Ohms)
- pin1: Connected to GND of the 12V Battery, GND of the SD30CRMA MPPT, GND of the SD30CRMA MPPT, pin2 of the 10k Ohms Resistor, and - of the Solar Panel.
- pin2: Connected to GPIO 1 of the Wemos S2 Mini and pin2 of the 47k Ohms Resistor.
Resistor (33k Ohms)
- pin1: Connected to GPIO 2 of the Wemos S2 Mini and pin1 of the 10k Ohms Resistor.
- pin2: Connected to VCC of the 12V Battery, BAT of the SD30CRMA MPPT, and Input + of the Mini-360 DC-DC Step Down Buck Converter.
Resistor (47k Ohms)
- pin1: Connected to VIN of the SD30CRMA MPPT and + of the Solar Panel.
- pin2: Connected to GPIO 1 of the Wemos S2 Mini and pin2 of the 8.2k Ohms Resistor.
Fuse
- Terminal 1: Connected to 3.3V of the Wemos S2 Mini.
- Terminal 2: Connected to Output + of the Mini-360 DC-DC Step Down Buck Converter.
Solar Panel
- +: Connected to VIN of the SD30CRMA MPPT and pin1 of the 47k Ohms Resistor.
- -: Connected to GND of the 12V Battery, GND of the SD30CRMA MPPT, GND of the SD30CRMA MPPT, pin2 of the 10k Ohms Resistor, and Input - of the Mini-360 DC-DC Step Down Buck Converter.
12V Battery
- VCC: Connected to pin2 of the 33k Ohms Resistor, BAT of the SD30CRMA MPPT, and Input + of the Mini-360 DC-DC Step Down Buck Converter.
- GND: Connected to pin2 of the 10k Ohms Resistor, GND of the SD30CRMA MPPT, GND of the SD30CRMA MPPT, pin1 of the 8.2k Ohms Resistor, and - of the Solar Panel.
SD30CRMA MPPT
- GND: Connected to GND of the 12V Battery, pin2 of the 10k Ohms Resistor, GND of the SD30CRMA MPPT, pin1 of the 8.2k Ohms Resistor, and - of the Solar Panel.
- VIN: Connected to + of the Solar Panel and pin1 of the 47k Ohms Resistor.
- BAT: Connected to VCC of the 12V Battery, pin2 of the 33k Ohms Resistor, and Input + of the Mini-360 DC-DC Step Down Buck Converter.
Documented Code
#include <WiFi.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>
#include <driver/temp_sensor.h>
// Definície pre časovanie
const long INTERVAL = 5000; // Interval merania (5 sekúnd)
unsigned long lastMsg = 0;
unsigned long lastWifiCheck = 0;
const long wifiCheckInterval = 30000; // WiFi kontrola každých 30 sekúnd
// Kalibračné konštanty podľa použitých rezistorov
const float BATTERY_RATIO = (33.0 + 10.0) / 10.0; // Batéria: 33k a 10k
const float SOLAR_RATIO = (47.0 + 8.2) / 8.2; // Solar: 47k a 8.2k
// Nastavenie pinov
const int STATUS_LED = 15; // GPIO15 pre S2 Mini
const int BATTERY_PIN = 1;