Arduino PWM solar charge controller

Arduino PWM solar charge controller

How to make very small, simple and cheap PWM solar charge controller with Arduino Pro Mini for 12V off-grid installations. The size of circuit board is the same as size of Pro Mini board, so they can be sandwiched together. PCB plans are for universal prototype board.

Arduino PWM solar charge controller circuit 4

Connection and usage of this Arduino solar charge controller is very simple – there are 2 input leads from solar panel (+ and -) and 2 output leads going to the lead acid battery. Ground of solar panel and battery is joined together. Any load should be connected directly on battery terminals and charge controller will automatically handle the rest.

Arduino PWM solar charge controller circuit

Arduino regularly measures lead acid battery voltage and according to detected value, switches the MOSFET on to charge battery from solar panel and switches MOSFET off when the battery is full. When your load pulls power from the battery, controller detects the voltage drop and immediately starts to charge battery again. During the night, when solar panel stops producing, controller waits until panel starts to output again.

Arduino PWM solar charge controller circuit 2

Arduino PWM solar charge controller circuit 3 bottom view

Positive lead to the solar panel needs Schottky protection diode placed directly on the cable (wrapped in heat-shrink tubing). It’s not included in main PCB as this makes it easier to replace it and cool down at the same time. You could easily make the board a bit longer to fit in a different type of diode.


Schematic & function description:

Arduino PWM solar charge controller schematic

Arduino PWM solar charge controller Pro Mini used pins

Function is based on N-Channel MOSFET IRF3205 in the high-side of circuit. This requires gate voltage higher than 12V to open the MOSFET properly. To omit the need for external MOSFET driver, it is driven by charge pump created with diodes, 2 capacitors and two Arduino PWM output pins (3 and 11). Pin A1 is measuring battery voltage and pin 9 controls MOSFET ON/OFF cycle. Arduino Pro Mini integrated LED connected to pin 13 is used to show off current PWM duty cycle.

Delete the code line analogWrite(13, 255 - pulseWidth); // pwm to LED if blinking LED bothers you too much.

Voltage Regulator and all the capacitors around (C6, C5 and C4) could possibly be excluded as there is a regulator included in the Arduino Pro Mini. However because I used cheap clone board, I am not willing to count on its ability to sustain higher voltages than 12V for longer time periods. LP2950 is very cheap and effective up to 30 Volts, so it’s worth to have it on board in any case.


PCB – top & bottom view:

Arduino PWM solar charge controller PCB top view parts placement

Arduino PWM solar charge controller PCB bottom view


Parts List:

  • Low-Power Voltage Regulator
    • LP2950ACZ-5.0
  • Transistors
    • 2N3904
    • 2N3906 x 2
  • N-channel mosfet
    • IRF3205
  • Resistors
    • 82K (1%)
    • 20K (1%)
    • 220K x3 (0,4W is enough)
    • 4K7 (0,4W is enough)
  • Diodes
    • 1N4148 x 5
    • P6KE33CA
    • 90SQ035 (or any similar Schottky diode 35V minimum 9A)
  • Capacitors
    • 47N/50V x2 ceramic
    • 220P/100V ceramic
    • 1M/50V (1000nF) ceramic
    • 4M7/10V tantalum
    • 1M/35V tantalum x 2

Arduino code:

void setup() {
TCCR2A = TCCR2A | 0x30;
TCCR2B = TCCR2B & 0xF8 | 0x01;
analogWrite(11, 117);
analogWrite(3, 137);
// Serial.begin(9600);
const int setPoint = 13.5 * 20 / (20+82) * 1024 / 5;
int measurement = 0;
int pulseWidth = 0;
int difference = 0;
int stepSize = 0;
void loop() {
measurement = analogRead(A1);
difference = abs(setPoint - measurement);
stepSize = difference;
if (measurement < setPoint) { pulseWidth += stepSize; if (pulseWidth > 255) pulseWidth = 255;
if (measurement > setPoint)
pulseWidth -= stepSize;
if (pulseWidth < 0) pulseWidth = 0; } // Serial.println(pulseWidth); analogWrite(9, pulseWidth); analogWrite(13, 255 - pulseWidth); // pwm to LED delay(10); }

Arduino code download: arduino-pwm-solar-charge-controller.ino

Schematic and code of this charge controller is by Julian Ilett, he is the mastermind behind this clever thing. All this is just a refined documentation and a suitable PCB design to perfectly fit Arduino Pro Mini board. He is sharing videos of more effective Arduino MPPT charge controller, but its construction is much more complicated and the project is not finished yet.

If you improve the code or construction in any way, please share your improvement in the comments :-)

  1. Hi.
    How mich power may the solarpanel provide for this circuit? Is it suitable for a 100watts 12-18 volts panel?

    • Hi, 100watts panel is OK, maximum for shottky diode 90SQ035 is 150W, there will still be operational reserve. Just make sure cables soldered to mosfet leads are copper and thick enough (at least 1mm automotive cable).

  2. I have a substantial bank of batteries in an RV and am going to install solar panels. I have an Onan Gen to otherwise charge the batteries but it is manual turn on an turn off. Can a controller such as yours be added to the Gen to start it when the batteries fall below acceptable levels at (i.e. at night) and then turn it off when they reach the required voltage level – maybe through the use of a relay.?
    Thank you
    Steve Lukinuk

  3. can you design same controller with 12v 2A and which show the charging current, Voltage power, remaining charging all about this on LCD also wifi data transmit….. Reply please…..

  4. C4 is 100nF not 1000nF. Watch here:

  5. Hello,

    Can this charge controller to use for the solar panel 240 w/p , maximun voltage 31v and 7,8 Amp.
    Of not what must be the component to change to use this solar panel.


  6. hi,
    what modification is possible for 300w solar panel, battery 12v,
    change only 90SQ035 or more components
    big thanks,

    • Hi, correct you need to change 90SQ035 for a stronger Schottky rectifier (35A or more – 60CIQ045, 80CPQ150 or whatever you have available) mounted on a heatsink. Mosfet is rated for 110A, can handle 300W solar panel easily but needs aluminum heatsink too.

      Here is a list of Schottky rectifiers from IRF, sortable by Amps:

  7. Hello.

    Many thanks for the work you’ve done in laying out the components in such a clever way. I’ve put it together and it works brilliantly. I’ve popped a video up on youtube with thanks to you and Julian Ilett for your hard work!

  8. Lambros frantzeskakis November 27, 2015 at 5:14 pm

    can we change the mosfet with a logic level mosfet ?the circuit will became a lot easier .. I believe we can :-) and also for the voltage regulator we can use an lm317 .. it’s also easier to find . For current mesurement and data export we can make a new version

  9. hy frnds an i use this circut for a 150 watt panel where short crcut current is 9.08 ampere , is it charge the battery safly and prevent the overchargng and reverse chargng or not

  10. is P6KE33CA Diodes is necessary ??

    • It’s there to protect mosfet and voltage regulator in case of voltage spike from solar panel. Not really necessary, but its cheap and it will ensure long life cycle of charge controller.

  11. Can I use this code for arduino uno or arduino nano or arduino Leonardo pro micro?

  12. hi Julian quick question would you be able to explain where each of these values came from just cant figure out where they came from:

    const int setPoint = 13.5 * 20 / (20+82) * 1024 / 5;

    thank you ryan

  13. hi arduined

    can i use the as replacement for the 90SQ035. ?

  14. Do you know if there is any variants of what you have created that can be used with wind turbines instead of solar. I am looking for a 24V system that should be able to handle up to 700Watts

  15. can we use Arduino Uno instead??

  16. Hi, I’m going to do this this weekend. Can I use a DC adapter as a power source instead of solar panel ?

  17. How would this cope with more than one controller on the chip.
    Could the outputs from different mosfets be chained together

    • Yes they can be chained, it should work as long as each mosfet has its own R6 4k7 resistor. Mosfet chaining is often used in 12V to 220V converters, like this one

  18. Can it be connected to 100 watts solar panel and 60amp battery for running a load of 60watt/hr.
    And if yes how much time it would support that load.

  19. void setup() {
    TCCR2A = TCCR2A | 0×30;
    TCCR2B = TCCR2B & 0xF8 | 0×01;
    analogWrite(11, 117);
    analogWrite(3, 137);
    // Serial.begin(9600); }

    May I know whats the purpose of this code? thaanks

    • Code starts the internal oscillator on output pins 3 and 11. This is used for charge pump circuit consisting of D1, D2, D3 and C1, C2. When input (VBATT) is 12V, the output from charge pump (measured on D3) is around 20V.
      Charge pump multiplies the voltage so mosfet works more effectively, with no overheating without the heatsink. It also allows N-Channel mosfet to switch positive side of the circuit, because voltage on mosfet Gate is much higher (20V) than voltage on mosfet Source-Drain (12V).

      • thanks for that! may I know the full ratings of your charge controller? and can i still use this when the voltage max output from solar panel is 24V? thanks

Leave a Reply


<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>