ESP32 Makes Great MPPT Controller In Low-Cost Solar Installation

Solar power projects have become, in general, a matter of selecting components like panels and batteries, hooking them together with industry-standard connectors, and sitting back to watch the free electricity flow. As such, solar projects have become a bit boring, so it’s not often we see one that attracts our attention the way this dirt-cheap open-source solar project does.

The backstory on [Tim O’Brien]’s DIY off-grid PV system starts with his desire to charge his eWheel, which amounts to a battery-powered standing unicycle. They look like a fun option for getting around an urban environment if you have the requisite degree of coordination, which we clearly lack. But charging something like that or an eBike is a great use case for solar, especially since [Tim] happened upon a 450W PV panel on the cheap. Sadly, the panel was a commercial unit, and compatible off-the-shelf MPPT, or maximum power-point tracking, controllers are expensive.

His solution was to build his own controller using a cheap DC-DC converter that just so happens to have serial remote control. An ESP32 monitors the panel voltage and controls the buck converter to run whatever he wants. When he’s not charging his eWheel, the system runs his laptop and router. As a bonus, the ESP32 talks to IoT services like Adafruit.io and Thingspeak, allowing him to track MPPT data without shipping it off to parts unknown.

While we appreciate a DIY MPPT controller and like [Tim]’s build, we feel like the documentation needs a bit of fleshing out. With solar installations, the devil is in the details, and not addressing seemingly mundane issues like cable routing and connector installation can lead to disaster.

34 thoughts on “ESP32 Makes Great MPPT Controller In Low-Cost Solar Installation

        1. My thoughts exactly. As someone who lives in New England, I’m saddened that all the cheap (like $50/250W panel cheap) used panels are in California and cost a bunch to ship each, cost is better on a pallet full of course.

      1. A 40 pound solar panel will sit there generating hundreds of kWh a year for 25+ years. That displaces extracting well over a ton (50 times its weight) of fossil fuel then burning it in a power plant. The environmental trade-off is completely obvious unless your math illiterate and lacking in common sense.

        The faux concern over pollution from making solar panels (and batteries) is a ruse by fossil fuel interests to distract people from the actual global problem of global warming. Sure, we should produce all manufacturer goods cleanly, but people criticizing renewal energy never express the same worry about how roof tiles or chrome auto parts are made.

    1. No polution – as long as we don’t consider the fossil fuel used to mine and refine the raw materials. Oh, and let’s not forget the massive amounts of energy it takes to create silicon wafers. I almost forgot to mention the absolutely STUNNING volumes of heavy diesel it takes to run container ships back and forth across the oceans carrying shipments of solar panels from China to the US. So yes, it must be super-clean and good for the planet since all of this didn’t happen in your own back yard. We won’t even get into the slave labor used in many places to extract the raw materials from the earth…

    1. Output voltage. I’m guessing what they mean is that standard off-grid or ‘domestic’ panels have an output voltage that is designed to be just about right for charging either a 12v system or more likely a 24v or even 48v system. Whilst ‘commercial’ on-grid panels don’t bare any relation to these system voltages because they are designed to be strung together in series reaching anywhere up to 1500v and then converted down by a string inverter. Hence the requirement to take one panel with a random output voltage and let the mppt buck converter stabilise it to whatever charging voltage is required.

      In fact these things do already exist, and are available on aliexpress. I bought one for a 260w commercial panel I had lying around and it works very well, it is a sealed waterproof unit with three pairs of wires, a multi coloured led and some calibration pins. About €30 delivered I believe.

      1. Be careful of cheap Chinese “MPPT” charge controllers. Some of them are not MPPT. An MPPT charge controller requires logic to adjust the input load continuously to find the voltage and current where you get maximum power. It then uses a DC-DC inverter to output the proper voltage for charging the battery.
        I’ve purchase cheap “MPPT” controllers which are just cheap inefficient PWM controllers.
        You can test this by measuring the input and output voltage and current to the controller. A real MPPT controller will have a higher voltage input which is then converted to the lower voltage battery output at a higher current.
        Here’s a (very rough) video I put together on the subject:
        https://youtu.be/z6MCeDjGqH8

  1. It use a cheap DC-DC power supply, which is not a MPPT.

    MPPT are complex stuff, that change its input impedance to best match the current solar conditions. (panel produce more energy at a given current…)

      1. It adjust the output current & voltage to feet the battery need, but this is not how a MPPT works. Checks Marc comment here. MPPT adjust input impedance. Solar panel aren’t linear between open-circuit and shortcut.

    1. Hey, project author here! Sure, the DC-DC is absolutely not an MPPT by itself. If you set it up manually to find the current maximum power point it’d, very temporarily, be a Maximum-Power-Point _holding_ system.. but it lets the voltage collapse within seconds.

      With the addition of the ESP32 closely following & testing the input voltage this is 100% an MPP-Tracker, an MPPT. My algorithm periodically tests the solar array to find the array-voltage that corresponds with the maximum output power then uses feedback-control to manipulate the output current to hold that array-voltage constant. This is exactly the behavior of any other MPPT, just a little stranger since I’m effectively having to add input-following feedback-control to negate the DC-DC buck’s output following feedback control system.

      Here’s the code for the sweeping logic if you’re curious: https://github.com/opensolarproject/OSPController/blob/master/lib/MPPTLib/solar.cpp#L137

      1. I understand what you ‘ve done. But, the DC-DC converter adjust the output current & voltage to obtain the best output power, but the DC-DC don’t change its input impedance.. so your output power is max for a given input voltage, but not the best for given solar panel & condition.

        Did I missed something ?

        1. This is not the way I approach thinking about or explaining this– but I’ll give it a shot. A variable DC-DC load is, from the perspective of the system supplying power, a variable impedance system. The wikipedia article on MPPTs implementation section introduction (https://en.wikipedia.org/wiki/Maximum_power_point_tracking#Implementation) approaches it in this manner, and even mentions that the DC-DC’s duty ratio is what controls its effective impedance.

          Any implementation, and that article then details several, doesn’t have to calculate anything related to an impedance. From the solar panel’s perspective any load is an impedance, but from the MPPT implementation’s perspective they’re just a variable duty ratio power supply that tracks the incoming voltage and outputs to the battery (or grid for AC systems) the maximum power it can supply before the panel’s voltage collapses.

          That wikipedia article has list of implementation types– If you’re curious I use a periodic ‘current sweep’ method to find the best power-point regardless of partial shade coverage (I had to deal with that a lot in my testing) as well as a subsequent constant-input-voltage method they mention but don’t really talk about.

          1. A DC-DC converter doesn’t care about resistive Ohm law. Solar panel are not linear, thus the power source is not following V=IR law either (else, MPPT would not be required). The output of a solar panel is V = f(I) with f being unknown/specific per panel. The main point of MPPT is to best estimate f so that V and I is chosen to maximize V*I = f(I)*I. A DC-DC converter will try its best to give the output you asked by switch its own MOSFETs faster or slower until the output fit the spec. It does not adjust the input resistance (it’s very low anyway), but instead adjust the “average” input impedance (by switching capacitor & inductors). The main issue is in fitting f(I) with such “unknown” highly non linear system (panel + chinese DC/DC converter input stage). I doubt the ESP32 code could come close to estimating such a complex system correctly, so in the end either you’re running in “current limited” mode of the converter, that is: a PWM system, either you are running in sub optimal “capacitor charge/discharge cycle”, where the solar panel is “switched” on a capacitor, and oscillating between “shortcut current” when the capacitor is charging and “max voltage mode” when it’s charged. It’s not MPPT in that case (at least, not as I understand it).

      1. Hey! Project author here, I’ve seen just over 400 watts maximum actually. I’m quite proud (since it’s a 450W panel and I’m pretty far from the equator).

        Re: what can you run? I’m actually directly charging a large bank (2kWh) of 36V LiFePO4 batteries that are from an old electric city bus, and with that I power everything DC in my home. Laptop, router, modem, rope lights, phone chargers, 3D printer, and my eWheel charger.

        An MPPT charger needs something to put a variable amount of energy into: either a battery or an AC electric grid. This system is specifically for charging a battery, and it will work with practically any out there like Lithium Ion, lithium ion polymer, or even lead acid. (lead-acid would require a little more work to add charge-float behavior)

  2. Hey folks, project author here. Ask me anything!

    Here’s the real-time data feed visualization of my system: https://io.adafruit.com/t413/dashboards/mppt

    So far today (10:30am) I’ve stored ~400 Wh of energy, and that’s steadily climbing as always. I used about 1000Wh last night charging my wheel (after this weekend’s adventuring) so I expect I might just barely top-off my 2kWh battery today. I use about 400Wh/day on laptop+modem+router+lights (~17W * 24h) and this time of year I generate 1400-1600Wh.

    Here’s the 7-day history dashboard: https://io.adafruit.com/t413/dashboards/power
    You can see I topped-off my battery the last four days to 42V, so the days previous to that had the highest stored energy at 1574Wh. Last week I was 3D printing *lots* (halloween props) and that uses a TON of power.

  3. I wouldn’t tell anyone to “use speaker wire” for a PV installation. It degrades in the sun, and is available in sizes too small for a code-compliant design.

    For a safer design, look for 600V USE-2 sunlight resistant cable of an appropriate gauge for your current draw (8-10A * 1.25*1.25 puts single-string designs at a ~12AWG design requirement in most cases).
    Side note, 12AWG is the most common single-conductor PV wire size; you don’t need full-blown 1kV or 2kV PV wire on a single module installation, but it wouldn’t hurt.

    The wire routing in the photo sketches me out too, but I guess you’re kinda close to the 6′ NEC minimum support distance – as long it’s ziptied to the back of the module for strain relief before going into the connector, anyway. If that loose run goes directly into connectors, expect a failure at the connector.

    The connector behind the module is a common failure point too, probably worth inspecting for overheating ~1/year when checking for module hotspots. Those failures are more common on connectors in combined strings with currents in the 20-40A range, and more fun on commercial 1kV systems…

    1. Excellent feedback.

      I used a secondary UV resistant tubing over all the outdoor wiring.. I’ll add that and some extra disclaimers to the wiki. I’m absolutely not an expert in PV panel installation, my intention was more to show how to build the MPPT portion so I’ll make that more clear too. I did indeed take care to strain relief everything, but not up to a level of polish a commercial project would see.

  4. Thanks for this post, I love anything solar related. I’ve been using solar energy to power my Amateur Radio shack for about two years now, and have really enjoyed thinking of ways to overcome the often inclement weather here in the UK.

    While the application here isn’t quite to my needs or specifications, it’s given me some great food for thought. I only wish that all the people commenting who are so quick to be negative, were more positive (no pun intended). Cheer people, the outlook is sunny.

    1. Aside from the “boo solar” people, it seems that some people don’t understand just how MPPT works and realize that this is a good implementation of MPPT. It uses a DC-DC power supply where the output (to the batteries) voltage and current can be controlled by the ESP32 which does what all good MPPT controllers do which is to continuously adjust the load to keep the solar panel operating at MPP (Power is I x V). This is the same way that all good MPPT controllers work.
      (BTW, I don’t know if you’ve found this guy yet but this website is a good source of amateur radio, solar, etc. information. http://oh8stn.org/ )

  5. That DC/DC converter is a terrible design, that much I can tell just by looking at the PCB. The traces are much smaller than they could be, the cooling pad of the switching MOSFET is tiny, although they would have had plenty of space to use a bigger one, the shottky diode is a through-hole one, whereas a SMD version with a big cooling pad would’ve been much better, etc.

    Also, the high-current traces are very long and without a ground plane on the back, so this thing probably acts more as a rf transmitter than a DC/DC converter.

    Besides that, the idea itself is great.

    1. I think you are confused. Do you have this power supply? I don’t think so. All of the power MOSFETs are fastened to a large aluminum heat sink with a fan at the end. Not fastened to the circuit board. All of the power traces are wide and fully tinned and perfectly capable of handling the max 12 amp output. Shottky diode should have to dissipate only 1-2 watts max.

  6. This blog is a game-changer for solar enthusiasts! Using the ESP32 as an MPPT controller in low-cost solar installations is a brilliant and cost-effective approach. The integration of cutting-edge technology into renewable energy solutions opens up new possibilities for affordable and efficient solar setups. Looking forward to more insights on maximizing the potential of ESP32 in solar applications!

    Best regards,

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.