🔋⚡ Smart Anti-Theft System for Solar Panels: Real-Time Detection of Panel Removal or Failure (2026 Guide)
Salut les makers ! Ici Electro. As the use of photovoltaic (PV) panels continues to grow, securing solar installations against theft or malfunction becomes essential. Solar panels are expensive, often mounted on rooftops or in remote locations, and are prime targets for thieves — especially in off-grid installations. In this article, we introduce a simple yet effective detection system that can alert users if one or more panels are removed, disconnected, or become non-functional — day or night, regardless of weather conditions.
🔄 Guide updated for 2026: complete circuit explanation, BOM, ESP32 code for real-time monitoring, GSM/SMS alert integration, and troubleshooting tips.
The complete anti-theft system: voltage monitoring during the day, reverse current injection at night, and ESP32 + GSM alerts.
🧠 How the Detection System Works
☀️ Daylight Detection (Voltage Monitoring)
During daylight hours, each solar panel produces a small voltage, even under cloudy conditions (typically 18-22V open-circuit for a 12V nominal panel). By constantly monitoring this voltage at the panel terminals or combiner box, the system can confirm that a panel is still in place and operating. If the voltage drops to zero or disappears entirely, it likely means the panel has been removed, disconnected, or has failed.
The ESP32's ADC (Analog-to-Digital Converter) reads the panel voltage through a simple resistor divider (to step down the 20-40V range to the ESP32's 0-3.3V input range). If the voltage is below a threshold (e.g., < 5V during daytime), the system triggers an alarm.
🌙 Nighttime Detection (Reverse Current Injection)
But what about at night or during extremely poor weather, when the panel isn't generating power? The open-circuit voltage drops to near zero, making voltage monitoring useless.
This is where the system's intelligence shines. A low DC voltage (typically 3-5V from a small battery or the ESP32's 3.3V output) is injected into the panel string through a current-limiting resistor (e.g., 100Ω to 1kΩ), and the resulting current is measured using a shunt resistor and an op-amp or Hall-effect current sensor (like the ACS712).
Thanks to the panel's built-in bypass diodes (or external protection diodes), the injected current can flow in the reverse direction through the panel's internal diodes, allowing us to detect if the panel is still physically connected. A typical solar panel will draw 10-50 mA when reverse-biased with 3-5V.
If any panel is removed or disconnected, the circuit is broken, and no current flows — triggering the alarm system, either locally (buzzer, LED) or remotely (SMS, IoT notification, email).
📊 System Architecture
| Component | Function |
|---|---|
| ESP32 DevKit | Main controller, ADC readings, WiFi/GSM alerts |
| Voltage divider (100kΩ + 10kΩ) | Step down panel voltage (0-40V → 0-3.6V) for ESP32 ADC |
| ACS712-05B current sensor | Measure reverse current during night mode (0-5A range) |
| 5V relay module | Switch between day mode (voltage read) and night mode (current injection) |
| 3.3V/5V power source | Inject reverse current at night (can be ESP32's 3.3V or external battery) |
| SIM800L GSM module (optional) | Send SMS alerts when theft/failure detected |
| Buzzer + LED | Local alarm indication |
🛒 Bill of Materials (BOM)
| Component | Model / Value | Qty | Role |
|---|---|---|---|
| Microcontroller | ESP32 DevKit V1 | 1 | Main controller + WiFi |
| Current sensor | ACS712-05B (5A range) | 1 | Measure reverse current |
| Resistors | 100kΩ, 10kΩ, 100Ω (1W) | 3 | Voltage divider + current limiter |
| Relay module | 5V single-channel relay | 1 | Switch day/night modes |
| GSM module (optional) | SIM800L | 1 | SMS alerts |
| Buzzer | Active 5V buzzer | 1 | Audible alarm |
| LED | Red 5mm + 220Ω resistor | 1 | Visual alarm |
| Power supply | 5V 2A USB adapter or 12V→5V buck converter | 1 | Power the ESP32 and relay |
| Enclosure | IP65 waterproof box | 1 | Outdoor protection |
💻 ESP32 Code: Complete Monitoring System
// Smart Anti-Theft System for Solar Panels - Electro (TechFix Hub)
// Monitors solar panel voltage (day) and reverse current (night)
#include <WiFi.h>
#include <HTTPClient.h>
// Pin definitions
#define VOLTAGE_PIN 34 // ADC input for panel voltage (via divider)
#define CURRENT_PIN 35 // ADC input for current sensor (ACS712)
#define RELAY_PIN 26 // Controls day/night mode switching
#define BUZZER_PIN 25 // Alarm buzzer
#define LED_PIN 27 // Alarm LED
// WiFi credentials (for IoT alerts)
const char* ssid = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";
// Thresholds
const float VOLTAGE_THRESHOLD_DAY = 5.0; // Volts - below this = alarm (day)
const float CURRENT_THRESHOLD_NIGHT = 0.005; // Amps - below this = alarm (night)
const int CHECK_INTERVAL_MS = 60000; // Check every 60 seconds
// Time-based mode switching (simple: use RTC or NTP for real implementation)
bool isDaytime = true; // Set based on light sensor or time
void setup() {
Serial.begin(115200);
pinMode(RELAY_PIN, OUTPUT);
pinMode(BUZZER_PIN, OUTPUT);
pinMode(LED_PIN, OUTPUT);
digitalWrite(RELAY_PIN, LOW); // Start in day mode (voltage monitoring)
digitalWrite(BUZZER_PIN, LOW);
digitalWrite(LED_PIN, LOW);
// Connect to WiFi
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nConnected to WiFi");
Serial.println("Solar Panel Anti-Theft System Initialized");
Serial.println("Monitoring started...");
}
void loop() {
// Determine day/night (simplified - use LDR or RTC in production)
// isDaytime = checkLightSensor() or checkTime();
if (isDaytime) {
monitorVoltage();
} else {
monitorCurrent();
}
delay(CHECK_INTERVAL_MS);
}
void monitorVoltage() {
// Read panel voltage through voltage divider
int adcValue = analogRead(VOLTAGE_PIN);
float voltage = adcValue * (3.3 / 4095.0) * 11.0; // 11:1 divider ratio
Serial.print("Day Mode - Panel Voltage: ");
Serial.print(voltage);
Serial.println(" V");
if (voltage < VOLTAGE_THRESHOLD_DAY) {
triggerAlarm("LOW VOLTAGE - Panel removed or failed!");
}
}
void monitorCurrent() {
// Switch to night mode: inject reverse current
digitalWrite(RELAY_PIN, HIGH);
delay(1000); // Let current stabilize
// Read current from ACS712
int adcValue = analogRead(CURRENT_PIN);
float voltage = adcValue * (3.3 / 4095.0);
float current = (voltage - 2.5) / 0.185; // ACS712-05B: 185mV/A, offset 2.5V
Serial.print("Night Mode - Reverse Current: ");
Serial.print(current * 1000);
Serial.println(" mA");
if (current < CURRENT_THRESHOLD_NIGHT) {
triggerAlarm("NO CURRENT - Panel disconnected or stolen!");
}
// Switch back to day mode
digitalWrite(RELAY_PIN, LOW);
}
void triggerAlarm(String message) {
Serial.println("⚠️ ALARM: " + message);
// Local alarm
digitalWrite(BUZZER_PIN, HIGH);
digitalWrite(LED_PIN, HIGH);
// Send IoT alert (HTTP POST to your server or IFTTT)
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
String url = "https://maker.ifttt.com/trigger/solar_alarm/with/key/YOUR_IFTTT_KEY?value1=" + message;
http.begin(url);
http.GET();
http.end();
Serial.println("Alert sent to IFTTT");
}
// Alarm duration: 30 seconds
delay(30000);
digitalWrite(BUZZER_PIN, LOW);
digitalWrite(LED_PIN, LOW);
}
🛠️ Step-by-Step Setup
- Build the voltage divider: Connect 100kΩ in series with 10kΩ between the panel's positive terminal and GND. The junction (between the two resistors) goes to ESP32 GPIO34. This scales 0-40V down to 0-3.6V.
- Wire the current sensor: Connect the ACS712 in series with the reverse current injection path. The ACS712's analog output goes to GPIO35.
- Install the relay: The relay switches between "voltage monitoring mode" (day) and "current injection mode" (night). In day mode, the relay connects the voltage divider to the panel. In night mode, it connects the 3.3V/5V source + current limiter (100Ω) to inject reverse current.
- Mount in waterproof enclosure: Use an IP65-rated box, with cable glands for the panel wires and power input. Mount near the combiner box or inverter.
- Calibrate thresholds: During the day, measure the actual panel voltage and set VOLTAGE_THRESHOLD_DAY to ~25% of that value. At night, measure the reverse current and set CURRENT_THRESHOLD_NIGHT to ~50% of that value.
- Test the system: Disconnect a panel and verify the alarm triggers. Reconnect and verify it clears.
📡 Adding GSM/SMS Alerts (Optional)
For remote installations without WiFi, add a SIM800L GSM module to send SMS alerts. Wire the SIM800L's TX/RX to the ESP32's Serial2 (GPIO16/17), and use the following code snippet:
// Send SMS via SIM800L
void sendSMS(String phoneNumber, String message) {
Serial2.println("AT+CMGF=1"); // Set SMS mode to text
delay(1000);
Serial2.print("AT+CMGS=\"");
Serial2.print(phoneNumber);
Serial2.println("\"");
delay(1000);
Serial2.print(message);
Serial2.write(26); // Ctrl+Z to send
delay(5000);
}
💡 Pro Tips (by Electro)
- Use an LDR (light-dependent resistor) to automatically switch between day and night modes, instead of relying on a timer. Connect the LDR to GPIO32 with a 10kΩ pull-down resistor.
- Add a tamper switch: Mount a normally-closed microswitch or magnetic reed switch on the panel frame. If someone tries to remove the panel, the switch opens and triggers an immediate alarm — even before the voltage/current check.
- Monitor multiple strings: If you have multiple panel strings, use a multiplexer (like CD4051) to switch between strings and monitor each one individually.
- Log data to SD card: Add a microSD card module to log voltage/current readings over time. This helps diagnose gradual panel degradation or partial shading issues.
- Use MQTT for IoT integration: Instead of HTTP POST, use MQTT to publish panel status to a broker (like Mosquitto or HiveMQ). This integrates easily with Home Assistant, Node-RED, or custom dashboards.
- Battery backup: Add a small 18650 Li-ion cell with a TP4056 charger module to keep the ESP32 running during grid outages — thieves often cut power before stealing panels.
❓ FAQ
Will the reverse current damage my solar panels?
No. The reverse current is very small (10-50 mA at 3-5V), well within the panel's reverse-bias ratings. Solar panels are designed to handle reverse currents from bypass diodes during partial shading. Just ensure the current-limiting resistor is sized correctly (100Ω to 1kΩ).
Can this system detect partial shading or soiling?
Yes, but you'll need to adjust the thresholds. Partial shading reduces voltage and current output gradually, not to zero. Set the alarm thresholds lower (e.g., 50% of expected output) to catch significant degradation, but not so low that normal cloud cover triggers false alarms.
What if I have a microinverter system (one inverter per panel)?
Microinverters complicate voltage monitoring because each panel's output is converted to AC immediately. In this case, rely on the reverse current injection method (night mode) or use the microinverter's built-in monitoring (most have WiFi or Zigbee reporting). You can also add tamper switches to each panel frame.
How do I prevent false alarms from clouds or dirt?
Add a "grace period" in the code: only trigger the alarm if the voltage/current is below threshold for 3 consecutive readings (e.g., 3 minutes). This filters out transient drops from passing clouds. Also, use an LDR to confirm it's actually daytime before checking voltage.
Can I monitor the system from my phone?
Yes! Use the ESP32's WiFi to send data to a cloud platform like ThingSpeak, Blynk, or Home Assistant. You can view real-time voltage/current graphs, receive push notifications, and even control the system remotely. For cellular-only setups, use the SIM800L to send SMS alerts or post to a Telegram bot.
🎯 Conclusion
With this simple circuit, you can enhance the security of your solar installation and ensure continuous monitoring regardless of weather or time of day. The system uses the panel's own voltage during the day and injects a safe reverse current at night, making it impossible for thieves to remove panels without triggering an alarm. Whether you're protecting a small off-grid cabin or a large commercial array, this DIY solution costs less than $30 in components and can save you thousands in replacement costs.
As green energy adoption rises, protecting that investment becomes just as important as producing the energy itself. With an ESP32, a few resistors, and some clever code, you've got a professional-grade security system that works 24/7.
Have you built this system or have questions about adapting it to your specific setup? Drop a comment below — I read every single one!