Look, I know the routine. You build an amazing outdoor weather station, seal it in Tupperware with half a roll of duct tape, and deploy it triumphantly in your backyard. Then, three days later, the 9V battery dies, and it becomes nothing more than a plastic tomb for a lifeless ESP32.
You could keep buying AA batteries in bulk and risking spider bites every time you have to change them, OR you could harness the giant, free fusion reactor in the sky.
Yes, today we are talking about Solar Power and Energy Harvesting. But this isn’t just about hot-gluing a solar panel to your Arduino and praying. If you connect a solar panel directly to a microcontroller, it’s going to reset every time a bird flies overhead or a cloud passes by. You need a buffer. A sponge to soak up the sun juice and dish it out steadily.
We’re going to use a LiPo battery and the CN3065 Mini Solar Lipo Charger Board to keep your projects alive indefinitely (or at least until the sun expands and swallows the Earth).
Before we start harvesting photons, you’ll need a few components. (Don’t cheap out on the charging board unless you want a backyard bonfire).
You might be asking, “Why can’t I just use that TP4056 module we learned about in Lesson 185?”
Great question, hypothetical reader. The TP4056 is designed for a constant 5V USB power source. A solar panel’s voltage swings wildly depending on the sunlight. If a cloud rolls in, the voltage drops. The TP4056 gets confused, tries to draw too much current, and drags the solar panel’s voltage down so low that charging stops entirely.
The CN3065 is specifically designed for solar panels. It uses a rudimentary form of MPPT (Maximum Power Point Tracking) to ensure it draws exactly the right amount of current without collapsing the panel’s voltage.
Wiring this up is incredibly satisfying because once it’s done, you never have to plug it into a wall again.
graph LR
A[6V Solar Panel] -->|Solar In| B(CN3065 Solar Charger)
B -->|BAT| C[3.7V LiPo Battery]
B -->|SYS Out| D[ESP32 / Arduino]
style A fill:#f9f06b,stroke:#333,stroke-width:2px
style C fill:#99c1f1,stroke:#333,stroke-width:2px
style B fill:#8ff0a4,stroke:#333,stroke-width:2px
style D fill:#ffb3ba,stroke:#333,stroke-width:2px
PWR IN or SOLAR terminals on the CN3065.BAT terminals. Check polarity three times! LiPo batteries don’t forgive backwards wiring.SYS OUT or VOUT terminals on the charger board.Note: If you are using an ESP32, it runs on 3.3V. A fully charged LiPo is 4.2V. Make sure you connect the power to the VIN or 5V pin on your dev board so the onboard voltage regulator can step it down safely.
Hardware is only half the battle. If your code is running a continuous delay(10) loop reading a sensor 100 times a second, your battery will die overnight, solar panel or not.
You MUST use deep sleep. (If you forgot how to do this, go review Lesson 156: Battery Super-Saver).
Here is a basic template for a solar-powered ESP32 that wakes up, reads a sensor, sends the data, and goes back to sleep:
#include <WiFi.h>
// Time to sleep (in microseconds): 30 minutes
#define uS_TO_S_FACTOR 1000000
#define TIME_TO_SLEEP 1800
void setup() {
Serial.begin(115200);
// 1. Connect to WiFi
// 2. Read your sensors (Temperature, Soil Moisture, etc.)
// 3. Send data to your server/dashboard
Serial.println("Data sent! Going back to sleep to save battery...");
// Configure the wake up timer
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
// Go to sleep
esp_deep_sleep_start();
}
void loop() {
// This will never be reached in deep sleep mode
}
Welcome to the world of infinite power! Now go build a remote weather station that you can actually ignore for a year.