Solar Project

Hello,

I just can't seem to get my arms around this. All I want to do is use an Arduino to at least monitor the charging for 12V batteries from solar panels.

At first, I wanted to build an Arduino controlled MPPT charger. I've seen several sets of schematics but they all seem to either have problems doing what they were designed to do, or are simply too weak. I want to attach only 200 Watts of solar panel, but many of the schematics were designed for only 20 or 50 watts. Getting the right sized MOSFETs and inductor coils seems to be the biggest challenge for most of these designs.

Eventually, I decided to Abandon that idea and use a commercial charger but put the Arduino Sensors in front of the charger. From the solar oanel, through the Arduino sensor, to the input of the charger. From the charger, through the Arduino sensor, into the battery. Same thing for load. As sensors, I wanted to use the INA219. I procured three INA219s and designed a circuit which provided the correct shunt.

I built the board and when I connected it I realised it wouldnt work! The chargers all seem to have common plus connectors (solar panel, battery, and load). To monitor the voltage and amps, I have to connect each INA219 to the Arduino ground and the negative side of the circuit to be measured (for example the solar Panel). That means, I would have a common rail on the negative side of all three circuits and a positive rail on all three circuits which obviously leads to trouble.

So, anyone got any brilliant ideas? How can I charge or at least monitor the charge/battery level/load of a 12V battery from 200 Watts of solar panels?

I've been working on this for six months and am getting no where! Any input or thoughts would be greatly appreciated.

You have not said what you want to measure with the Arduino - volts? amps? both? where?

A schematic of your system with the proposed measuring points would be useful.

If you already have a competent charge controller I'm not sure what you will gain by further monitoring.

...R

Theres no problem in simply measuring the battery voltage , with just a couple of resistors to reduce the voltage down to less than 5V , and a simple connection to any of the analog input pins, from the divided down voltage.
As the battery is after the charger, how the charger regulates the output is not relevant.
Simply connect the Arduino ground to the negative terminal of the battery, and supply the Arduino power from the batteries +ve terminal via a voltage downconverter.
A switch mode 12 > 5V converter would be the most efficient.
Theres no easy way to measure the currents apart from using isolated hall effect sensors.

@Robin2 - I want to measure both volts and amps in three different places. 1) Solar Panel Output, 2) Battery (to detect if charging/discharging), and 3) Load. This setup is only a part of a larger system. The purpose is not to second-guess the charger, but to detect situations where power may be available from the solar panels which is not needed to charge the already full batteries and divert that power to other tasks.

The INA219 is an I2C device that measures voltage on the "high side" (+) and also measures amps. I would run the + of the solar Panel to the INA "v+" and the INA "v-" to the + of the solar panel input for the charger. That way, the Arduino can measure the voltage and the amps coming from the solar panel. If the voltage is relatively high and the amps fairly low, then the charger is not using the available power and I can divert it, for example to directly power a pump or heater. By having all the data in the Arduino, I can make the best decisions on how to use the power available. While the charger has the data also, it's only purpose is in charging the battery and the data is not useable to make other decisions.

@mauried - Measuring the voltage with a voltage divider is possible, but insufficient in this scenario. I need the voltage and amperage and that's why I chose the INA219 (also because of the ease of connectivity using I2C).

As far as I can see from a quick read of the datasheet the INA219 has 2 isolated voltage sense pins which require an external shunt resistor in order to measure current. Each current source you wish to measure will require its own shunt resistor, chosen according to the expected current. After that you can connect any number of sensors each across its own shunt and only have a common ground.

Typically you can estimate if a battery is charged just by its voltage so you dont really need to mess around with current in and out unless you really want to. Just measure the voltage and divert power to other uses if its high enough- some solar chargers have an output for excess power already built in.

Unless you have a resistance or an open circuit somewhere the voltage will be the same at all points in your circuit. The state of charge of the battery will normally dictate the voltage (at least for lead-acid batteries which I am familiar with).

If your solar energy is affected by clouds you will find that the output from the panels can vary by a large percentage in a second or less.

What is the output of your solar panels and what is the capacity and the chemistry of your battery?

...R

@rw950431 - The INA (or at least the Adafruit breakout board) has two pins labelled VIn+ and VIn-. The VIn+ is to be attached to the positive side of a circuit (the solar Panel, a battery, whatever). The VIn- (which would better be labelled VOut+) passes the positive connection on, for example to the battery chargers input, or a 12V load. The shunt resistor sits between Vin+ and VIn- and the INA reads across that shunt to get the amperage. It reads the VIn+ to get the Volts. Of course, the INA has to also be connected to the negative side of the solar panel, battery, or whatever as voltage is read across VIn+ and Ground. To get the readings from the INA into the Arduino, I also have to connect power and ground from the Arduino to the INA (+5V and Gnd). This would all work just fine for a single sensor. My Problem is that I need three sensors (solar panel, battery, and load) which are all connected between the solar Panel/battery/load and the solar charger. That charger uses a positive bus. All three (solar panel, battery, and load) have a common positive rail. If I connect all three sensors to a single Arduino, I also have a common negative/ground rail.

@Robin2 - You would be right. All three Connections should theoretically have the same voltage. I don't think that's true here though. For example, the charger is supposedly using PWM/MPPT Technology to isolate the solar panel from the battery with the explicit purpose of allowing the solar panel to work at its optimum voltage (for example 18V) while supplying whatever voltage/current to the battery (for example 14V) to charge the battery. I really would expect the battery and load to have the same voltage (though the charger can shut the load down to prevent over discharge of the battery) and could live with only measuring one. I just measured both because the chosen sensor, INA219, does voltage and amps anyway. I wouldn't have gained anything by NOT measuring both voltages.

The solar panels provide up to 200 Watts. The battery (one now, maybe more later) is "12V 45Ah Yuasa Akku für Solar Photovoltaik Solarenergie AGM Blei". The charger was chosen because it is one of the few that allows you to set all the parameters like charge end voltage instead of just being fixed at some value which is usually not optimal. The charger is "Andoer 30A 12V/24V Intelligent LCD Solar Panel Batterie Regulator PWM".

That Charger is simply a PWM charger, it has no MPPT capability, which is very common.
You wont get 200 Watts from your panel in any conditions with such a charger.

That may be true. However, it still doesn't get me any closer to being able to measure what is coming in/going out. Be that 200 Watts or 2 Watts. I do realize that nothing is 100% efficient and have scaled the Project accordingly. To be honest, 100 Watts of input would be sufficient, but realizing the inefficiencies (and overrating of products!) I chose to use two 100 Watt Panels. The 30A charger is also overkill. Hopefully, the battery is also overkill because I want to use the energy available from the Panels without having to tap the battery very often. If I have dreamt too big, I can add battery capacity and also a panel. Experience will tell if I can ever get it working at all.

You have described a lot of technical detail without actually telling us what you are trying to achieve.

Your 200watt panels can probably produce about 10 amps at 20v (approx) and they will also only provide about 10 amps at 12v unless you use an MPPT charger. (However I reckon you need a lot of careful thought and calculation before concluding the the extra cost of an MPPT charger would actually pay for itself)

For that much output a 45Ah battery is very small and, in practice, the real capacity of that battery is probably more like 22Ah. I have a pair of 80w panels charging a 200Ah battery to reduce the amount of diesel used for charging.

What are you planning to power with the solar panels?

...R

In reality, for the Problem I have, it is irrelevant how many Watts/Amps the Panels are delivering or how much is actually getting to the battery. The battery size is also irrelevant as my final Goal is to use as much of the solar power as possible directly. The battery, admittedly small, only powers the Monitoring device (Arduino) which turns the users of the solar power (heater, pump) on/off as needed and when power is available.

If there is a charger, with (preferably) MPPT or not, which can be used, I'm perfectly willing to consider that Option. The one I planned to use won't work with the INA sensors because the charger connects all + lines together and the INA would require all the negative lines to be tied together.

If there is a different sensor which someone recommends, I'm willing to consider that too.

I want to use the solar power when it is available. When it's not, the battery will only be used in an emergency.

As mentioned, I'm using part of the solar power to supply heat (to a 200L tank). The tank has thermal latency and an operating range of like 15°C so when no power is available, there's no Problem.
The Problem I'm looking for help on is in the Subsystem to Monitor the solar energy, keeping the battery charged and using the rest for the auxiliary Systems.

If anyone is really interested in what the Overall System is, it's a small bio-gas System that turns my kitchen waste into gas for the kitchen stove. The System works except that I want to use solar power to heat the digester and pump the gas from low pressure intermediate storage into higher pressure Long term storage when I produce more than I am using.

JaBa:
As mentioned, I'm using part of the solar power to supply heat

So why not just use a temperature sensor and switch on/off the solar power to the heater based on that.
Separately have a regulator to prevent over-charging the small battery.
No need to measure any voltage or current.

Alternatively, if there is enough solar energy to make it worthwhile storing some for night-time heater operation you need a very much bigger battery.

Based on my own calculations and experience I remain to be convinced that complicated solar solutions pay for themselves.

...R

Robin, first off, thanks for your interest in the project and its problems. Unfortunately, I don't think it's as easy as simply switching the heater on/off based on a thermostat. You see, the bio-gas digester will perform within a range of 25°C to 40°C with better performance at the higher end of that range. The 200L tank is insulated. It takes a while to get to temperature, but once there it will remain warm enough overnight or over a cloudy day or two. Therefore, I'm not really interested in drawing from the battery to provide heat. I simply want to prioritize the use of solar power when available. First priority is keeping the battery charged as a constant backup for emergencies. Second priority occurs seldom but is to power the gas pump when the short term gas storage is near full and move some of the gas to long term, pressurized storage. Third priority is to heat the digester if it's not at the maximum temperature. Most of the total energy is stored thermally in the digester or as pressurized gas. That's why I'm less concerned, at this point, about having lots of battery storage. Honestly, I expect the 200 Watt panels to provide all the power the system Needs. Optimizing the solar power is more of a "nice to have" than a must. This system is not like those used in recreational vehicles to provide all the power for the mobile home Environment. I am not interested in storing the maximum electrical power, I'm more concerned about using it when it is available to fulfill the proritized needs. What may happen is that I tap the battery on a rare occassion when the temporary gas storage get full at night. If I don't get the gas out, it will pop the overpressure valve and vent which is not a good idea at all. That pump would only run a minute or two so the battery can handle it. Im with you, it is probably cheaper to add an extra Panel than to over complicate everything by tring to maximize everything with an overly complicated MPPT. (Most of them only have one situation where they are truly optimal and the situation changes daily.) Along those same lines, I only plan on adjusting the angle twice a year and there is no sun-tracking.

So, any ideas on how to track 2-3 voltage and amperage sensors from the same Arduino considering that all 2-3 circuits have a common positive rail?

Alternatively, any ideas how to build an Arduino based charger for 20-30 Amps? (Allowing for some growth later.)

That gives a much more helpful picture of the project.

If I can try to simplify as much as possible it seems to me like this. (Please correct any errors).

  • Your first priority is to charge the battery.
  • If there is spare solar power you want to use it to heat the tank.
  • The gas-pump can be powered from the battery as it is infrequent and only runs for a short time.

You have not said what draws power from the battery (apart from the short usage by the pump).

If the battery is just for standby use and hardly ever used it will not need much solar energy.

I think we need to know the demands on the battery before going further.

...R

Robin, your simplification is mostly correct.

The first priority is to charge the battery.
If there is spare solar power:
It should power the pump if the temporary storage is nearly full.
It should heat the tank if the temperature is not already maximum.

Regardless of solar power availability, the gas pump MUST be powered if the temporary storage is nearly full, even if this means drawing power from the battery because no solar power is available.

Of course, the Arduino and all sensors (voltage, amperage, gas Level) is powered from the battery but the System is designed to draw very Little power. The Arduino sleeps most of the time and the sensors are only powered on to take readings and then turned back off. Because None of this is time critical (the battery Level will not Change much within a minute or two, 200L at 38° isn't going to Change within and neither will gas Level increase quickly) I only plan on waking the Arduino every ten minutes or so.

The Arduino sleeps in power-down mode but I am considering, under certain conditions, possibly using less of a sleep mode and leaving the PWM running and possibly Controlling the heat better than simply on/off depending on how much solar is available.

Actually, it isn't even an Arduino. It's a bare-bone 328P that I built. It doesn't even have a single LED on it. No UART, a switched power supply instead of a linear one. It does have a LCD Display with a backlight but the entire Display is on a Switch and will be kept off unless I am physically looking at it.

Of course, if possible, I would like to have further Options open. Who knows... maybe a second digester, more Panels and batteries and powering the lights in the house. Maybe something entirely different to use spare power for when available (blow the hot air out of the attic on hot days?) Let's leave those as future dreams for now. I'd be happy to get this part finally up and running.

You are correct, I've made every effort to Keep the load on the battery at a Minimum. Summing it up, I am less interested in storing lots of electricity in a battery and more interested in effectively using power when it is available.

If you are determined to use the 3 INA sensors I dont see any problem with doing so. Please post your proposed circuit diagram (hand drawn and photographed will do) so that we can understand your problem. You should be able to supply power to the Arduino and measure voltage at 3 different points without causing any short-circuits.

JaBa:
Robin, your simplification is mostly correct.

The first priority is to charge the battery.
If there is spare solar power:
It should power the pump if the temporary storage is nearly full.
It should heat the tank if the temperature is not already maximum.

Regardless of solar power availability, the gas pump MUST be powered if the temporary storage is nearly full, even if this means drawing power from the battery because no solar power is available.

I am assuming from your comments in Reply #14 that the ONLY purpose of the battery is to have power available to operate the pump.

In my mind it will greatly simplify the project if you assume that the pump is ALWAYS powered from the battery. And I can't see that making any appreciable change to the overall energy balance.

I think, then, (if this was my system) that I would design a very simple system that would switch off power to the heater if the voltage falls below N (perhaps 12v for a 12v lead-acid battery (their full charge voltage while charging is over 13v) and leave the full power on the battery until the voltage exceeds (say) 13.5v. This would just need a single voltage measurement and a relay.

Of course you may also want an over-temperature detector on the tank and a spare "dump-load" for the solar power so that the battery is not over-charged if the tank cannot take solar output.

...R

Thanks to everyone who is trying to help!
By popular request, I am including a drawing of how I currently have things hooked up. This doesn't work! The Problem is that I didn't realize that the charger was connecting all the plus poles together until after I completed the wiring. Believe it or not, as soon as I connected the battery (and nothing else) the charger indicated that it was charging the (almost dead) battery! In fact, it was pulling power out of the battery, running it through the chargers PWM circuit (apparently stepping the voltage up in the process) and pushing it back into the battery. I wondered where the power was coming from and that's when I discovered my error and that the plus poles are all connected together internally in the charger. Since I connected all the negative/ground poles together...

In the attached diagram, red is of course always a positive line. Black is negative/ground. Lines which may cross are not attached unless there is a dot at the crossing.

Each INA must have the +5V and ground from the Arduino attached. The INA has a shunt resistor across VIn+ and VIn-. The INA measures voltage between VIn+ and ground and amperage across VIn+ and VIn-.

So, I really don't think this circuit can be saved. I don't think the INA will work at all because they will always require a common ground and the charger already has a common positive.

Anyone have ideas on other sensors? Or a charger that doesn't have a common positive rail?

I'd really like to stay with the idea of measuring both voltage and amperage at least at the solar panel and the battery.

@travis_farmer - Thanks for the idea, but the INA169 and 219 are similar. The 219 uses I2C which I feel is easier to communicate with. Both require having all the grounds/negatives connected together and that causes a problem because the charger already has all the positives connected together.

@Robin2 - The gas pump, Arduino, and sensors are all directly attached to the load of the charger and the charger has been set to never disable load except at battery undervoltage. Whether the charger can pass power from the solar panel directly to load is unknown. I've read comments both ways but I don't think it matters.

Funny that you mention "dump". Actually, I consider the heater to be the "dump". Any power not needed to charge the battery (or possibly being passed by the charger to "load") will be "dumped" to the heater. As mentioned in a previous post, if power is available and not needed for heat, I may eventually dream up other uses for that power. For the purposes of the current problem, I don't think that is relevant.

I am relying on the charger to not overcharge the battery.

Image from Reply #18 so we don't have to download it. See Image Guide

...R