I live in an apartment building and I installed a small photovoltaic system behind a window so that I can use the energy it produces to power my various IoT projects.
However, I found that I have no control over the battery discharge, especially at night or when there are clouds in the sky.
That's why I thought of creating a device that would monitor the energy produced by the photovoltaic panel, the energy consumed by the load (whether it's the 12V-220V inverter or a 5V/2A max auxiliary source), monitor the energy remaining in the battery and generate alarms when a threshold of remaining energy is exceeded, so as to protect the battery from excessive discharge (at night or on cloudy days).
Project descriptionTo monitor the currents and the 12V voltage I used INA219 type sensors together with a series of shunts chosen for various purposes: 12V battery charging/discharging, inverter consumption, auxiliary source consumption and monitoring the entire system consumption.
The MCU used for this project is from STmicroelectronics and is part of the STM32U083C-DK development board; I chose it because: it use a low power MCU, STM32U083MCT6, is oriented for baterry working and contains a lot of RAM and program storage along with a rich set of peripheral, such is internal RTCC, I2C, SPI, UART/USART, glass LCD driver, CRC and more.
For the display I choosed a small 200x200 pixels e-Ink display (this consumes current only when refreshing the displayed data) with I2C interface.
The data collected and processed locally can be sent to a Smart Home solution based on NodeRed (I developed such a solution here ) or to Home Assistant. This data will be sent periodically or when a certain parameter changes significantly. For data transmitions used an ESP8266-01 module.
To activate the auxiliary 5V/2A and/or 12V/220V inverter I used two buttons for each output and the status activation/deactivation is signaled on e-paper display.
The hardware part of this project is splitted in two parts: one is the development board STM32U083C-DK and the other one si a custom made addon board. I prefered to use the STM32U083C-DK board because he has an glass LCD, on board temp sensor and I want to benefit on the presence of them in the project.
The custom board contein:
- 5V power supply, using ST L6983CQTR;
- 3.3V, only for add board, using ST LD39150;
- 4 x INA219;
- relay that will command On/Off the 12V-220V inverter;
- CR2032 battery used for internal RTC;
- F-RAM memory FM24W256-GT used for logs;
- connectors, other passive components.
The addon board pictures (th components was soldered by me):
Also, I create a application that will be used to configure this project in terms of: shunts parameters, battery type, RTC set, sleeps period; moreover, the application can read and interpret the internal log stored in case of some issues will encounter (this is noy implemented yet). The application is written in Python.
The SW application that will rum on ST MCU contains an state machine with four stages, to cover all four possibe situations:
- solar panel produce energy but no load is connected;
- solar panel produce energy and the load is connected;
- solar panel not producing energy and no load is connected;
- solar panel not producind egengy and load is connected.
Because this system will run only on the solar panel 12V battery, is crucial that the power consumption of the system itself to be as low as possible. To achive this, I used several ways/methods:
- for displaying data I used an e-Ink/e-paper display; this display will be updated only when the data is changed;
- MCU will stay in sleep (STOP 1 mode) for a period of time depending on the solar panel status (if produce energy or not) and the load presence;
- during sleep, all INA219 sensors will be in sleep mode to preserve energy;
- ESP8266 will start in sleep mode and will be powered up only at request.
OBS: I used STOP 1 mode for MCU sleep because I need to preserve the output state of some pins, used to commands the inverter and auxilliary 5V/2A power supply.
Because the MCU and sensors are frequently put to sleep and woken up, we have provided a system for checking the functionality of the sensors and other subassemblies (internal RTC, external memory) as well as a mechanism for logging any problems; the logs are recorded in the F-RAM memory and the presence of a failure is signaled on the e-paper display by a specific sign. Then, using the application above, these logs can be downloaded and processed to be interpreted.
How it's workingBelow is a working diagram that show what are the main functions:
After power up or reset, the following actions are performed:
- check if the RTC had the good data; if not, then a special mark is displayed on e-paper display and RTC is set with default date and time;
- read the settings stored in flash for current sensors and timers;
- check if the log memory is present on I2C bus; if the memory is not responding, an special mark is displayed on e-paper display;
- check if the sensors are present on I2C bus; if a sensor is not responding, the event is loged in F-RAM memory along with date and time;
- set the sensors registers with specific data read from flash;
- show the initial data on e-paper display and on-board glass LCD;
- calculate the battery energy based on the voltage value (measure the voltage on 12V battery);
- display the read data from sensors and calculated valued on e-paper display;
- display temperature on glass LCD.
Next, read the current sensor associated with solar panel, to check if the solar panel produce energy or not. This sensor is connected in series with output of MPPT converter.
From here, we have two main stages, both with another tho sub-stages, as following:
A. The panel produces electrical energy:
A.1. The load is present and connected (12V to 220V inverter and/or aux 5V/2A);
A.2. The load is not present;
B. The panel does not produce electricity:
B.1. The load is present and connected (12V to 220V inverter and/or aux 5V/2A);
B.2. The load is not present;
After one of the stages was enabled and all the data was computed, displayed, and sent to the smart home, the sensors and MCU enters in sleep mode (MCU in STOP 1 mode) to save the power from 12V battery; this sleep period depends on the stage and can be set from the Python app.
Power supplyThe STM32U083C-DK and the addon board works at 5V and 3,3V but these boards are connected to 12V battery through a power supply build around this IC made by ST, L6983CQTR for the 5V/2A, witch is an step-down power regulator. The main feature of this steo-down converter is LCM (low consumption mode) that increase the efficiency at light-loadl in other words, the internal po0wer consumption is propotrional with the load consumption.
To design the power supply with L6983CQTR, I used an ST tool, called "Power Supply Design Tool", from here. The project created with this tool is a 5V/2A power supply and is attached.
Next, I used an ST LD39150 to create 3,3V from main 5V, to power the components from addon board. The LD39159 is a fast ultra low drop linear regulator which operates from 2.5 V to 6 V input supply. The main features of this chip are: low drop voltage, low noise, and ultra low quiescent current.
Hardware and connectionsThe connections between solar panel, battery, inverter and aux power supply through shunts is presented below:
The entire project is presented here and is self explanatory:
Explanation of addon board connectors:
- on the left side we have: shunt connectors for battery. MPPT and inverter; inverter and aux On/Off buttons and main power supply, 12V (from photo-voltaic system battery);
- on right side we have: connector for EDSP8266, connector for e-paper display, connector for serial communication (with setup applicxation), output for aux 5V/2A power supply and relay for Inverter OnOff.
The schematic and PCB for this addon board is attached to the project.
The addon custom board was created using KiCad v9.0 and PCB and PCBA was done by PCBWay.
Settings applicationI create an application in Python to setup RTC and all the parameters needed to configute this project. This application is created in Python and connect to the MCU board via J13 Serial conn (USART2). When the application is connected to the MCU board, the MCU will not enter in STOP 1 mode. This is the UI of this application:
All the parameters are followed by the SET button. When I press SET button, then all the data are saves in MCU RAM. To save the values in MCU flash, I need to press the the big SAVE button.
The RTC not follow this rule; when I press SET button, then the RTC is set; to verify that, press GET button and compare date and time.
Setup MCU and addon boardsThe entire project is powered from 12V solar power battery; this voltage is applied on specific connector from addon board and there to the 5V and 3,3v; the 5V will be applyed also to the STM32U083C-DK board through CN7 connector (see schematic attached). But, during the development faze, the board will be powered using ST-Lonk USB connector. So, in order to work properly, some modifications are necessary on each of the boards in these two cases: normal run and development/programming faze.
1. add internal RTC battery backup: here is the place from were we have to remove the jumper SB6 from STM32U083C-DK; the jumper is here:
2. programming mode; in this mode we have to follow those steps: SW1 set to Prog (from addon-board) --> SP3 Source set to STLINK --> connect board to PC via ST-Link USB connector.
3. normal mode; in this mode we have to follow those steps: SW1 set to Run (from addon board) --> SP3 Source set to E5V --> disconnect board from PC via ST-Link USB connector.
We need to modify the addon board to re-route input for inverter OnOff to other MCU pin. Initially, the pin used for inverter OnOff was PB6 (pin 26 from CN10, see board manual) but this pin is blocked or locked by the STM32CubeMX board config because is used to sense the USB connected device (to MCU). So, I have 2 posibilities here: one is to use in CubeMC a normal config or use the config special created for this board. I choosed the second option and I re-routed the button for inverter OnOff to pin:
Here is presented the data from epaper display:
Note: the project is in working progress...
Update from 22.06.2026Until now I tested the following fucntionalities of this project:
- setup, calibrate read INA219 current sensors;
- save in MCU flash and read back all the setup parameters using serial application written in Python;
- BMS function is working;
- on MCU board LCD is displayed only the onboard temperature sensor value, for the moment;
- the sleep period is working and is based on the solar panel activity (day/night) and active load (aux or inverter);
- I connect the hardware module, that include the STM32U083-DK and addon board (made by PCBWay) to my existing solar panel, MPPT, battery and shunts.
The software tested is in download section, named "Solar_panel_monitor_22062026.zip"
Here is a video with the working:
Shunts used:
Limitations:
- for the moment, the project can use only GEL VRLA type battery;
- only 12V system can be monitored;
-
Next steps:
- add more battery types;
- add a second display or use a large one to show alarm and other messages along with already existing data;
-
CreditsA huge thank you to PCBWay for sponsoring the fabrication and assembly of this add-on board!
The build quality of the PCBs is absolutely top-notch, and the SMT component soldering is incredibly clean and precise. Thanks to their professional manufacturing services, I was able to bring this prototype to life much faster and ensure everything works flawlessly.
If you are working on your own electronic projects, I highly recommend checking out their quick-turn PCB and assembly services!


_4YUDWziWQ8.png?auto=compress%2Cformat&w=48&h=48&fit=fill&bg=ffffff)
Comments