Tuesday, October 3, 2023

Smart Solar Charger

Here we present the circuit of a highly efficient, automatic solar charger based on PIC16F877A microcontroller. It shows the system status on an LCD and can trickle charge. -- By Santhosh Jayarajan

- Advertisement -

Construction and testing

A single side PCB for the PIC microcontroller based solar charger is shown in Fig. 3 and its component layout in Fig. 4. Assemble the circuit on a PCB to minimise time and assembly errors. Carefully assemble the components and double-check for any overlooked error. Use IC base for microcontroller PIC16F877A. Before inserting the IC, check the supply voltage (5V) at test point TP1.

Fig. 3: An actual-size, single-side PCB for PIC16F877A microcontroller-based solar charger
Fig. 3: A single-side PCB for PIC microcontroller based solar charger
Fig. 4: Component layout for the PCB
Fig. 4: Component layout for the PCB
Fig. 5: Author’s prototype of the pic microcontroller based solar charger
Fig. 5: Author’s prototype of the PIC microcontroller based solar charger
Fig. 6: Flow-chart of the program
Fig. 6: Flow-chart of the program

Before using the circuit, the system has to be calibrated for battery and solar voltages. This is done as follows:

Battery voltage

With battery disconnected, apply 20V at TP2 with respect to TP0. Use a multimeter to monitor the voltage at test point TP3 and adjust preset VR1 to get 5V. Check whether the voltage at TP6 is around 5V. Connect back the batteries. Now the voltage at TP3 should be around 3V.

Solar voltage

- Advertisement -

Remove the solar panel from the circuit. Connect a 12V battery at test point TP4 with respect to TP0 and monitor the voltage at test point TP5. Adjust preset VR2 to get 3V. Relay (RL1) enable can be checked at TP7.

The circuit is ready to harness the energy of the sun after calibrations. The power is calculated and displayed on the LCD in watts every second. The energy in watt-second is calculated by integrating the power.

Fig. 5 shows the working prototype of PIC16F877-based solar charger.

The following parameters are cyclically displayed on the LCD module:
1. Battery voltage in millivolts
2. Battery current in milliamperes
3. Energy in watt-seconds
4. Power in watts
5. Solar panel voltage in millivolts
6. Charger mode: boost or trickle

Download PCB and Component layout: click here

Download Source Code: click here


The source program is written in basic language and compiled using PIC Simulator IDE from Oshonsoft. The IDE provides a facility to program using Basic like commands, then compile the program and generate hex code. Burn the generated hex code into the microcontroller by using a suitable programmer.

source code of the pic microcontroller based solar charger

The program works as per the flow-chart shown in Fig. 6. It starts by checking solar panel voltage. If solar panel voltage is more than 12.6 volts, the program moves to the next stage. If solar panel voltage is less than 12.6 volts, the program displays message “Low Solar Volts” on the LCD module and loops back to wait until solar panel voltage is above 12.6 volts.

If solar panel voltage is adequate, the system checks battery voltage and sets the charging mode to ‘boost’ or ‘trickle.’ A battery voltage of over 12V sets charging mode to ‘trickle,’ while a battery voltage of less than 12V sets it to ‘boost’ mode. During initialisation, the data is also read from the EEPROM, which stores the watt-hour readings. It gives an indication of the power absorbed from the sun.

The timer generates an interrupt every 65.56 ms. A 15-count in the interrupt service routine ensures that the energy and power are calculated every 65.56×15 =983.4 ms (almost 1 second).The power is integrated every second to get the energy in watt-seconds. The watt-hour readings are stored in the EEPROM of the microcontroller, so that the data is not lost due to power failure. To prevent too many write cycles in the EEPROM, the data is stored only every 30 minutes.

The author is working at Tata Realty and Infrastructure in Engineering Services as AGM


  1. i have just one qestion if an panel 50w with max 2.5amps is no strong for d1….i think the diode is just for 1 amp and if i use another tip ex…6 amp ultra rectifier diode and the relay change with another contact ex auto tip will damage ? just right now i built this and im not sure i intent to use 100w panel…..thank yo


Electronics News

Truly Innovative Tech

MOst Popular Videos

Electronics Components