ESP32-C3, Solar Panel and Supercapacitor. Simple Weather Station.
by aresta in Circuits > Electronics
1499 Views, 4 Favorites, 0 Comments
ESP32-C3, Solar Panel and Supercapacitor. Simple Weather Station.
This project will show you how to run an ESP32-C3 devboard without a battery, just with a small solar panel and a 10F supercapacitor.
The ESP32-C3 is a nice RISC-V single core microcontroller with low power consumption. This device can run virtually forever without batteries, collecting the weather data and sending it via the Wi-Fi connection. You can let it running for months and years unattended.
The device takes temperature, humidity and pressure samples every 15 minutes, stores them and sends the data every two hours.
The sampling and sending periods are adjustable, but with these values the device can survive two days (more than 48 hours) without any sun. I have tested it with the solar panel disconnected, but even in a gray cloudly day it harvest energy to slowly fill the supercaps.
The MCU also monitors the charge level of the supercaps allowing some power management strategies. For example, when the voltage is below a threshold, the connection frequency is reduced to save power and increase the surviving time until the sun shines again.
I generate some graphs offline to show the data throughout the year. You can also build a second indoor device with a nice screen to display graphs from the week/month/year weather data and other information like weather forecast data for your area from the Internet.
Supplies
- ESP32-C3 Supermini devboard.
- 2 x Supercaps of 5F each (or one).
- 1 small solar panel (8 x 6 cms) of 5V.
- BME280 sensor: temperature, humidity, pressure
- Boost step-up converter 0.9V - 5V to 5V
- LDO (low dropout) regulator MCP1700 2.3V - 6V to 3.3V
- 4 resistors of 1MΩ each
- 1 ceramic capacitor of 10uF
- 1 Electrolytic capacitor of 4700uF, or as big as you have
You will also need a IoT internet service to send the data via Wi-Fi connection. I use Amazon AWS IoT because I already have an account, but you can use any other. There are some free options for hobbyists.
Test the Supermini Devboard
The ESP32-C3 Supermini is a cheap and small devboard that fits very well for this project. It has not a lot of pins available, but we don't need more.
To start testing, you can just power and program it with a USB-C cable; there is no need for a TTL adapter. If you want to run the LED blink program, take into account that the LED is connected to GPIO8.
In the last step, when everything works fine, you will remove the power led and the LDO to save power, because they drain current all the time. Actually, the LDO on the board is not that bad; the quiescent current is about 50uA, but it is still too high. The MCP1700 LDO quiescent current is below 5uA.
To reduce the power consumption in the code, I set the CPU frequency to 10Mhz. Only when it needs to connect to the Wi-Fi I set the CPU frequency to 80Mhz.
Wiring
The wiring is quite straight-forward; following the connections is the schematic.
On the left side, we have the connector for the solar panel. It will generate power with a voltage ranging from 1V to 5V, depending on the strength of the sunlight. The idea is to use the boost converter to step up the voltage to 5V to be able to charge the supercaps to the maximum no matter how strong is the sun. Actually, with some sun the supercaps are fully charged in a couple of minutes; we don't need to optimize more here.
Then we have the two supercaps in parallel connected to the 5V rail. In the breadboard I use the power rails in one side for the 5V power rail and the other side for the 3.3V rail, with both grounds connected.
There is also a voltage divider connected to GPIO3 to be able to monitor the level of charge of the supercaps.
Next we have the LDO MCP1700 that steps down the voltage to 3.3V. It has a very low quiescent current, less than 5uA and this is very important because most of the time it is doing nothing as the MCU is in deep sleep.
When the supercaps voltage goes below 3.3V the LDO follows it down to 3.0V where the MCU stops working. Between 5V down to 3V the system can survive 48 hours connecting to the Wi-Fi every second hour and without power optimizations.
Then in the 3.3V rail we have a big capacitor of 4300uF. It is optional, but it's there to provide current quickly when the MCU connects to the Wi-Fi. It is like a reservoir close to the MCU. The LDO max current is 250mA, that should be enough, but for the short current spikes the capacitor helps.
Finally, we connect the MCU and the BME280 sensor.
Just pay attention to the 3.3V rail, don't connect there any 5V wire or you will damage the ESP32-C3, as we are powering it directly to the 3.3V pin without any regulation.
The Code
You can program it just connecting a USB-C cable. The code is relatively simple, you can copy and adapt it from here: https://github.com/aresta/ESP32-C3_Supercaps
It is developed in PlatformIO but should work fine in the Arduino IDE with some adjustments.
In any case, you will need to adapt the connection code to send the data samples to your own IOT cloud service.
The device is most of the time in deep sleep more. On every wake up the process just takes the sensor measures, checks the voltage level of the supercaps and depending on it connects to the Wi-Fi to send the samples or just go to sleep again.
These global variables with the label RTC_DATA_ATTR are stored in the RTC memory of the MCU, they keep their values during deep sleep.
RTC_DATA_ATTR Sample samples[ max_samples];
RTC_DATA_ATTR uint16_t sample_count = 0;
RTC_DATA_ATTR uint16_t sleep_mins = SHORT_SLEEP;
RTC_DATA_ATTR uint8_t samples_to_send = 8;
The first one "samples", is an array of structs to store the weather samples between deep sleep cycles.
struct Sample {
int16_t temp; // range: -50.0 - +50.0 celsius
uint8_t hum; // range: 0% - 100%
uint8_t pres; // range: 950 - 1050 millibars
uint8_t volts;// range: 0V - 5V
uint16_t sleep_mins;
};
We take one sample every 15 minutes and we can store many of them before sending. The RTC memory is small, only 8K, but it is enougth to store about one thousand samples.
It decides whether to send the accumulated samples or keep them in the array based in charge level. We can also increase the sleep time when the supercaps level is very low, to save power.
For testing uncomment the DEBUG flag in the conf.h file:
// uncomment to enable log output
// #define DEBUG
You will need to adjust your Wi-Fi connection settings in the env.h file. Just rename the example one: env_template.h to env.h and adjust or add your values.
The Wi-Fi connection is done using static IP to avoid the DHCP request and save power.
Testing and Optimizing
After everything is connected, checked and checked again, the next step is... to check again with the multimeter. If something is wrong, you can damage the MCU; just pay attention to the voltage at the 3.3V rail.
Once everything works, the device connects to the Wi-Fi, sends the samples and so on. You can let it running and verify that the supercaps charge properly, that they don't discharge too fast, etc.
The last step to optimize the power consumption is to remove the power LED and the LDO from the devboard. You can do it carefully with a solder iron, flux and solder wick.
If you look at the board image, you can identify the power led and the LDO:
- Power LED: it's at the top left side, labeled as "PWR". It is tiny, but you can remove instead either the diode or the resistor just above the LED.
- LDO: it's on the left side, the chip with five legs labeled: SOT23-5. Just remove it. If you had removed the diode in the previous step, probably the LDO is not powered, but when I take the iron solder, I can't stop!
I also put the devboard schematic for reference.
Future Improvements
- Build it on a perf-board, I will do it soon, or in a PCB.
- Housing.
- Use a buck-boost converter activated only when the voltage in the 3.3V rail goes below 3.3V, with a voltage comparator. This way most of the time the buck-boost converter would be deactivated not cosuming anything. And it would squeeze the supercaps below 3.V.
- Adjust better the power management to survive several days without sun. It can enter different modes depending on the voltage level. It could even take into account the hour of the day and the season to adjust better to sun hours.
- Test with bigger supercaps; 20F, 40F...
- Another device can be created to access the cloud data and show it indoors in a nice screen with some graphics, year, month, week statistics, weather forecast, etc.