How to measure solar panel voltage using arduino?

In summary, the voltage on the solar system is high and the solar negative is typically 40-70V UNDER the "system ground". In low light conditions even the solar positive comes down under the system ground level. Trying to bring the solar negative up to system ground using a resistor, does not work. The resistor gets hot and the voltage is quite unaffected. Can this be solved in any other way than powering the arduino directly off the solar? If so, how should I go about making a stable voltage supply of the solar?
  • #1
solvejskovlund
56
2
I would like to make the solar system a bit smarter. The challenge is that the voltage is high (up to 351Vdc) and the solar negative is typically 40-70V UNDER the "system ground". "System ground" is shared among battery negative, charger negative, inverter ground and ground cable digged down around the house.

In low light conditions even the solar positive comes down under the system ground level.

Trying to bring the solar negative up to system ground using a resistor, does not work. The resistor gets hot and the voltage is quite unaffected.

Can this be solved in any other way than powering the arduino directly off the solar? If so, how should I go about making a stable voltage supply of the solar? Available buck converters seems to not accept more than 90V. Solar provides up to 351Vdc.
 
Engineering news on Phys.org
  • #2
solvejskovlund said:
I would like to make the solar system a bit smarter.
How could that be possible, unless you design your own inverter?

The inverter will control the DC voltage relative to ground of the string of DC PV panels. It does that to prevent insulation breakdown.
I suggest you use the output from the inverter, not the raw high voltage DC.
 
  • #3
Inverter is one of the big consumers. If that thing is on at all times, battery won't last a night. Would be quite silly to have any device that doesn't require AC to depend on AC.

What can be smarter? Say if the sun is shining and battery is full, then it is nice to run hotwater. That saves quite a bit of firewood. However, if there are clouds comming, that hot water tank needs to be switched off or it will drain house battery is few minutes.
(From mid March to mid September we didn't use any firewood last year, because solar provided all energy needed. However, I had to be on alert the switch things off. If I couldn't stay at home to watch the clouds, there were no hotwater until the next sunny day.)
 
  • #4
To measure the PV string voltage will require a couple of high-voltage resistive attenuators, followed by a difference amplifier. That is dangerous ground.

Measuring PV voltage will not be as much use as measuring the current, but current only flows in the PV string when there is some load.

You might do better dedicating one PV panel to power the controller and instrumentation.
 
  • #5
solvejskovlund said:
Trying to bring the solar negative up to system ground using a resistor, does not work.
...
...
... the only safe solution I can suggest is to get a DMM with remote (bluetooth?) connection.
If it's a handheld one then please DO NOT try to hack with the battery.
 
  • #6
Measuring the voltage tells quite a lot. If voltage can be measured within 2V accuracy it will tell how much more power the system can handle, or how much power has to be reduced. I that is accounted for how much charging current the battery can handle at the current state of charge, how much load is on the inverter, and how much the sun is shining. All this in one reading! And whenever a could comes by, the voltage will drop immediately telling an overload is about to happen. And whenever battery is fully charged the voltage will increase, telling there is capacity available for direct consumption.

Could it be an option to put a 5-90V buck converter (and a 1A fuse) between system ground (as +) and solar negative to power the arduino?

Some kind of opto coupling should also work, right?
 
  • #7
solvejskovlund said:
Some kind of opto coupling should also work, right?
Sorry if I missed it, but what are your battery voltage(s)? You can likely power your isolated Arduino circuit from the battery voltage with a buck downconverter and use opto-isolated SPI for the serial communication about the measured voltages that you send back to your main controller circuit.
 
  • #8
solvejskovlund said:
The challenge is that the voltage is high (up to 351Vdc) and the solar negative is typically 40-70V UNDER the "system ground".
The Arduino could be supplied by a buck converter powered by the lowest panel in the string. Only one resistive divider from above is then needed.

I would use a high resistance chain to convert string voltage to current, then a current to frequency converter, followed by an isolator. That would generate pulses at a rate proportional to string voltage. The Arduino could then operate safely, from an isolated supply, close to the ground.
 
  • Like
Likes Tom.G
  • #9
berkeman said:
Sorry if I missed it, but what are your battery voltage(s)? You can likely power your isolated Arduino circuit from the battery voltage with a buck downconverter and use opto-isolated SPI for the serial communication about the measured voltages that you send back to your main controller circuit.

House battery is 48V (46-53). I have buck converters that accept 0-90V input.
Opto-isolated SPI should work. But how do I convert the voltage reading to a SPI signal?
I've been searching for VCO IC's this morning and there is one issue that applies to all models I find. They send out so high frequency that it cannot be detected by arduino. A typical wide band VCO uses output of 5-20GHz. The arduino would need a 1/1000th of that.
 
  • #10
Baluncore said:
The Arduino could be supplied by a buck converter powered by the lowest panel in the string. Only one resistive divider from above is then needed.

I would use a high resistance chain to convert string voltage to current, then a current to frequency converter, followed by an isolator. That would generate pulses at a rate proportional to string voltage. The Arduino could then operate safely, from an isolated supply, close to the ground.

That might be the easiest way to go. Are you familiar with current to frequency circuits that will work?
 
  • #11
solvejskovlund said:
Are you familiar with current to frequency circuits that will work?
Yes. There are many things that influence selection.

There are the traditional precision LM331 circuits, that can be modified for current input.
https://www.ti.com/lit/ds/snosbi2c/snosbi2c.pdf

There are also cascode circuits that charge a capacitor to a reference voltage, using an LM555 to then dump the accumulated charge through the LED of an opto-isolator.

The output of the remote I-F converter can be counted after reception, by a CMOS prescaler for perhaps a second, to give a low-pass filtered output to the controller.
 
  • #12
Think I've found the solution:
Adafruit INA219 current sensor breakout
https://www.adafruit.com/product/904?gclid=EAIaIQobChMIrIfH39fs9gIVmv_jBx24LggDEAQYBiABEgLX0PD_BwE

To my understanding this thing can sense current passing through a 0.1ohm onboard resistor. The arduino can be kept electrically separate from the circuit being measured. It has a max current of 3.2A. Gain can be set to 1/8, giving a max current of 0.4A, with an improved accuracy.

Say I'll aim for a accuracy of about 1V and dimension for a max of 500V in the solar circuit (everything else there is rated to 500-600V). That means I need 9 bit numbers. This device gives 12 bit numbers. That means I can aim for 1/8th of the rated current = 50mA. So I can connect a 10k resistor in series with the INA219 between the solar + and -. If solar provides 500V the resistor will waste 25w. For a normal cloudy day peak power, this thing will consume 5w..... That is still more than I'd like. Could the 0.1ohm resistor of the breakout board be swapped for a 1ohm, or maybe a 10ohm? Will the output of the breakout board scale proportional to that resistor? Will a 10ohm resistor scale the 9 bit number to 0.5mA? I so the series resistor can be 1M and max power loss at 500V solar will be 1/4w. That sounds very good. But this may cause a big error in the measurements? It's ok if the readouts are off by quite a bit, as long as they are consequent. If 100V is always read as 150V, it's ok. But if it's read as 150V one second and 120V the next second, it will be problematic.
 
  • #13
solvejskovlund said:
To my understanding this thing can sense current passing through a 0.1ohm onboard resistor.
Will you measure the PV string voltage or the current ?

I was expecting to measure up to 400 volt, by the current of 100 uA flowing through a chain of four * 1 megohm resistors.
 
  • #14
I guess I'll have to measure current, through some resistors. All though technically that is done measuring voltage drop over a small resistor in series with several large ones, as you suggest.
The INA219 track led me to INA228/INA229/INA237/INA238/INA239. The potential issue with INA219 is that the Vin- voltage might be too far from GND plane. Reading the datasheet it seems like problems may occur if this voltage is outside the range [-0.3 .. 26]V. With a solar voltage variable in the range [0 .. 351]V, and most of the time it seems like solar negative is up to 70V below GND, it's hard to find a chain of resistors that keeps the "measure negative" in the range [-0.3 .. 26]V ABOVE GND. The INA228/INA229/INA237/INA238/INA239 models has a range of [-0.3 .. 85]V, which will make it easier to stay within range. However all these ICs seems to be impossible to buy. Some are expecting them in stock 18 months from now. This again makes those who actually have a couple in stock put the price crazy high.
An option might be the INA226 which has a range of [-0.3 .. 36]V.

I need to wait for a sunny day to measure where the solar negative actually goes when in the high voltage range.
 
  • #15
It is wise to define what you need to measure, before you start selecting components.
 
  • Like
Likes Averagesupernova
  • #16
All though we haven't had a clear sky day yet, I've seen solar negative 96V under GND, with a total solar voltage of 150V. That makes my plan with the INAxxx components fail...
 
  • #17
solvejskovlund said:
I would like to make the solar system a bit smarter. The challenge is that the voltage is high (up to 351Vdc) and the solar negative is typically 40-70V UNDER the "system ground". "System ground" is shared among battery negative, charger negative, inverter ground and ground cable digged down around the house.

In low light conditions even the solar positive comes down under the system ground level.

Trying to bring the solar negative up to system ground using a resistor, does not work. The resistor gets hot and the voltage is quite unaffected.

Can this be solved in any other way than powering the arduino directly off the solar? If so, how should I go about making a stable voltage supply of the solar? Available buck converters seems to not accept more than 90V. Solar provides up to 351Vdc.

A isolated DC-DC converter can power the controller and monitoring devices. I've built a few solar energy monitor systems using PIC controllers for some DIY solar energy systems I play with. I normally use Hall current sensors to provide panel/battery bank voltage isolation for the controller pins.
https://forum.allaboutcircuits.com/...c-controlled-battery-array.32879/post-1448225
https://forum.allaboutcircuits.com/...c-controlled-battery-array.32879/post-1463914For the negative voltage measurement you can use a voltage offset divider and scale in software.
https://cq.cx/interface.pl#6
int-read--15-15-v.png
 
  • #18
There seems to be a phase-pattern to the solar-ground balancing. Starting at night, there is <5V from the solar. When voltage increase, the negative seems to stay near GND (within 5-10V) until the solar positive reaches battery voltage (near 48V). As the solar voltage continue to increase the positive stays at battery voltage while the negative drops until it's about 140V below GND. As solar voltage increases even more, the negative stays there (relative to GND) while the positive increases.

Wonder if this can be done very simple. I needed to see nsaspooks circuit to get the idea. The idea is simply to put a voltage divider (R3, R4) with high resistor values between solar positive and GND to measure/calculate the positive solar voltage. Then put an other voltage divider (R1, R2) between solar negative and aurduino power supply (48V->3.3V buck converter) positive to measure/calculate solar negative voltage. By adding those measurements I should be able to get what I want.
What is the downside of using high resistor values? Could they be too high? The highest I have is 4.3M. Using 28k shunt resistors (R2, R3) I hope this circuit will serve the purpose even if solar goes 500V above or below GND (even handels both at the same time). (I plan to log max/min voltages over time, and based on that I can safely increase the shunt resistor values if better accuracy is needed.)
In the circuit attached V2 and V3 combined serves as the solar input, they are split in two in order to balance them around GND.
Are the R5 and R6 serving any purpose? I'm thinking they might protect the Arduino, but I'm not sure.
(I think my arduino pro micros are 3.3V. Have to figure out how to confirm that.)

Does this look like it would work?

solar-volt-sensor.png
 
  • #20
solvejskovlund said:
What is the downside of using high resistor values? Could they be too high? The highest I have is 4.3M.
Resistors have a voltage rating that is often ignored.
Assume there is a limit of 100 V per resistor. That will also reduce surface leakage currents, and stress on the PCB. For example, a 400 V divider will require four equal resistors in a series chain.

Once resistor values go above 100k, you need to protect them from condensation and the environment.
 
  • Like
Likes berkeman
  • #21
Oh. I had no clue about that. How do I find a resistors voltage rating? They aren't labeled with anything that could point me to a datasheet.
Why is condensation an issue with high value resistors? I thought that would be related to the power passing through (heat), and higher resistor values reduces current, hence less power/heat.
 
  • #23
solvejskovlund said:
How do I find a resistors voltage rating?
Identify the manufacturer through the supplier, and get their data. Otherwise, assume 100 V.

solvejskovlund said:
Why is condensation an issue with high value resistors?
Because leakage current, across the dirty wet surface, is in parallel with the resistive element.
After hand assembly, your fingerprints can be a problem.
Resistors run warm, which attracts life in a cold environment.
Moulds grow on surfaces, insects excrete, and mice pee.
Operate the equipment in a clean and dry environment.
 
  • #24
solvejskovlund said:
Oh. I had no clue about that. How do I find a resistors voltage rating? They aren't labeled with anything that could point me to a datasheet.
Why is condensation an issue with high value resistors? I thought that would be related to the power passing through (heat), and higher resistor values reduces current, hence less power/heat.
If using carbon-composition resistors the maximum voltage is limited by internal arcing between the carbon grains.

Metal film resistor are constructed by depositing a resistive metal film on a ceramic body. Then a spiral groove is cut in the metal film to get the desired value. Arcing can occur across this narrow groove to the adjacent turn. A similiar problem can occur with wirewound resistors.

The other voltage limitation is the amount of power dissipated by the resistor. For instance if you want to drop 200V across across a 39k resistor, the resistor better be rated for 2 Watts.

A major resistor manufacturer is Ohmite in the USA. You can probably find more details than you want on their site: https://www.ohmite.com

Cheers,
Tom
 
  • #25
DaveE said:
These led me to a document called "±480-V isolated voltage-sensing circuit with
differential output"
https://www.ti.com/lit/an/sbaa321/sbaa321.pdf?ts=1674928488075

Sounds very much like what I've been looking for. I notice they are using a chain of 4 resistors in the divider, just like Baluncore pointed out.

To my understanding, if the high side of this is grounded at solar negative, the low side output will never get negative, hence I don't need to deal with that.

So, using this... what's the best way to supply power to the high side of this thing? Voltage is to high for any buck converters I've seen. Could a voltage divider (1:6) work to supply power to a buck converter that supports up to 90V input? (I have a couple of those laying around)

Maybe something like this would work (needs modifications to accept more than 250V in, and 5V out)
high-voltage-regulator.jpg

Source: https://www.planetanalog.com/build-a-high-voltage-linear-regulator/
 
  • #26
Baluncore said:
Identify the manufacturer through the supplier, and get their data. Otherwise, assume 100 V.Because leakage current, across the dirty wet surface, is in parallel with the resistive element.
After hand assembly, your fingerprints can be a problem.
Resistors run warm, which attracts life in a cold environment.
Moulds grow on surfaces, insects excrete, and mice pee.
Operate the equipment in a clean and dry environment.

Is it enough to place it in a sealed waterproof box? Or should I cover them in some stuff to keep air out?
 
  • #27
solvejskovlund said:
These led me to a document called "±480-V isolated voltage-sensing circuit with
differential output"
https://www.ti.com/lit/an/sbaa321/sbaa321.pdf?ts=1674928488075

Sounds very much like what I've been looking for. I notice they are using a chain of 4 resistors in the divider, just like Baluncore pointed out.

To my understanding, if the high side of this is grounded at solar negative, the low side output will never get negative, hence I don't need to deal with that.

So, using this... what's the best way to supply power to the high side of this thing? Voltage is to high for any buck converters I've seen. Could a voltage divider (1:6) work to supply power to a buck converter that supports up to 90V input? (I have a couple of those laying around)

Maybe something like this would work (needs modifications to accept more than 250V in, and 5V out)
View attachment 321354
Source: https://www.planetanalog.com/build-a-high-voltage-linear-regulator/
Sorry, there are some threads I just don't want to be involved with to a significant extent. This is because of safety concerns and my own selfish desire not to be associated with a bad outcome.

Granted I haven't carefully read the whole thread, but I have read enough. You are dealing with dangerous high voltages but haven't clearly communicated the grounding situation (for example, your schematic above appears as if the solar panels have three connections?). There has been little to no mention by anyone of isolation of dangerous voltages in the measurement system, which would be required by any of the safety standards I am familiar with (EN60950, EN61010, etc.).

It is clear to me that you are not familiar with circuit design with dangerous voltages (resistors have voltage limits, for example). This is not a DIY project and I am not confident that I could properly instruct you in this subject via text based questions. Nor am I confident that you would want to do that.

Good luck. Be careful. Don't endanger others with your installation.
 
  • Like
Likes Rive, anorlunda and Baluncore
  • #28
@solvejskovlund
Your use of the Monte Carlo method will eventually find a solution that seems to work, most of the time, but only after many failures. Juggling the components of other designs is a very inefficient design technique, without a safe and reliable endpoint.

You must first specify the problem.

You have a virtually floating (±1 kV) PV source.
The voltage of one panel, (assumed to be at the bottom of a string), is available to generate a lower voltage floating supply to power the instrumentation.
1. What is the maximum open circuit voltage of a single panel?
2. What is the maximum number of panels in a string?
3. What is the maximum short circuit current?
4. Do you want to measure the string voltage, over what range, and how accurately?
5. Do you want to measure the string current, over what range, and how accurately?
 
  • Like
Likes Rive and Tom.G
  • #29
Well, as I've mentioned it before, for this project the only safe option I can think of is a factory made DMM with an isolated output (USB, BT, optical: whatever) (and preferably, an isolated power supply to prevent the frequent battery replacement what's just asking fro trouble).

Wiring it properly would be still a bit tricky, but still far less mess than DIYing the whole thing.
 
  • #30
When I started this thread I was hoping someone would respond "Hey, this device does exactly what you need". I'd prefer if there was a device that could be bought ready. The lack off such reply leads me to think this will end up being a DIY thing.

Powering with battery would make stuff a lot easier. So much easier that I see that a possible solution.

Powering with one panel.... Voc=38,1V; within the range of a buck converter. Even two panels will be within the range. I'm not sure if that is a good idea though - it will unbalance the strings as it will load one panel in one string. (Due to the panels location I can't really connect them in parallel before series.) However the load is microscopic, this shouldn't be an issue, most of the time. The main concern is that it may fail to power the sensor on cloudy days. Say my 18 panels is able to generate 10w total on a cloudy day. That's 0.5w each. If the buck converter needs 0.5w to power the sensor, pulled from one panel only.... What will happen to the charging in such case? The tiny power given in cloudy days is actually what makes us have light and water pump in the fall/winter.
I'm not a fan of that solution, but I do see it's advantage. If going that route, at least a battery backup is needed, and a low volt cut off in front of the buck converter.
Isc = 9ish A.

Voltage range from 0 to 352 is the currently needed. Later upgrades to the solararray may increase this range. Everything else on the solar side is rated for at least 500V, so I'd prefer if the voltage sensor can go to 500V as well. Accuracy doesn't need to be much. What is important is to sense major changes. If the sensor say 150V when the actual voltage is 200V, that's OK. If the sensor say voltage dropped 5V between two readings, when it actually dropped 10V, that's OK as well. But if the sensor say it dropped 5V, when it didn't change, that will be an issue. What I'm trying to say is that the values is not important, but the consistency is important. I guess the term noise level could be used here.
When reading datasheets, I've been aiming for 1V accuracy. If a device shows up that solves this challenge with a downside of accuracy being 5V, I would go for it. If 10v.... maybe not.
There are some critical voltage ranges at [48V..60V] and [105V..140V] where I'd like accuracy near 1V. Outside these ranges accuracy doesn't matter. "<48V", "between 60 and 105" and ">140" could be good enough outside the critical ranges.

Current measuring is in a range that can be solved using a hall sensor. That is simple. I've been wondering if I could just drop voltage sensing, stay with current sensing, do some guess work about the voltage based on current sensing both the solar circuit, battery circuit and inverter output current, but I ended up with the conclusion that this will take too long. When the solar voltage drop occur that needs my logic to switch off a high power device, the current in battery circuit will rush towards the inverter, which should trigger my logic to disable the 220V relay for the device, but at this point the BMS logic will also sense issues and disconnect the battery. I doubt I can make any logic that responds faster than the BMS, when sensing on the same line. I do need this thing to make decisions based on the solar circuit only. Due to the MPPT logic, there is no way I could estimate the voltage based on current measurements only.

I do lean towards the circuit posted in #18. (Replacing large resistors with chain of smaller ones.) It's ugly, but if the resistors are large enough it shouldn't cause problems. (I can leave my voltmeter there without making trouble.) It's advantage is that it does not require any power supply on the solar side.

The solar lines are not completely floating. One or the other seems to be fixed relative to battery negative in intervals depending on the voltage intervals between them.
Solar voltage < battery voltage: solar negative = -0ish V, positive = [0..battery voltage]
battery voltage < solar voltage < 138V: solar negative = [-0.. -88V], positive = battery voltage
138V < solar voltage < 140V: solar negative = [-138.. -140V] (it jumps from -88V), positive = 0
140V < solar voltage < 352V: solar negative = -40V, positive [0..312V]
 
Last edited:
  • #31
solvejskovlund said:
When I started this thread I was hoping someone would respond "Hey, this device does exactly what you need". I'd prefer if there was a device that could be bought ready.
Must not have looked too hard...
Here's the first one I found, I'm sure there's many others:
https://www.dataq.com/products/di-4730/

Try a google search like "500V data acquisition".
 
  • #32
solvejskovlund said:
Powering with one panel.... Voc=38,1V; within the range of a buck converter. Even two panels will be within the range. I'm not sure if that is a good idea though - it will unbalance the strings as it will load one panel in one string.
If the isolated instrumentation required 20mA at 15V, an ideal switching buck converter running on 38 volts input, would only need a current input of 20 mA *15V / 38V = 8 mA. That is an unbalance, but I don't see it as a big problem.

By accumulating charge at a rate of say 100 uA in a capacitor, from the string-voltage sensing-chain, that charge can be dumped through an opto-isolator, which eliminates much of the instrumentation current that must come from the lowest isolated panel.

When the light level is low, the controller should reduce power by sleeping. Your system should allow all relays to open, automatically switching the PV panels into the low-power configuration.
 
  • #33
solvejskovlund said:
When I started this thread I was hoping someone would respond "Hey, this device does exactly what you need".
Rive said:
the only safe solution I can suggest is to get a DMM with remote (bluetooth?) connection.
Google 'DMM serial', it's still not late...
1675316525807.png

TP4000ZC is kind of 'dirt cheap'.

I still suggest to go for bluetooth, though. Good insulation, lot harder to mess up.:doh:

On second thought, I suggest to stop. The difficulty to do this safely and effectively just does not fits you.
 
Last edited:

FAQ: How to measure solar panel voltage using arduino?

How do I connect a solar panel to an Arduino to measure voltage?

To connect a solar panel to an Arduino to measure voltage, you need a voltage divider circuit to step down the voltage to a safe range that the Arduino can read (0-5V for most Arduino boards). Use two resistors to create the voltage divider, connect the solar panel's positive terminal to the input of the voltage divider, and connect the output of the voltage divider to one of the Arduino's analog input pins. Don't forget to connect the solar panel's negative terminal to the Arduino's ground (GND).

What components are needed to measure solar panel voltage with an Arduino?

To measure solar panel voltage with an Arduino, you will need the following components: an Arduino board (e.g., Arduino Uno), a solar panel, two resistors to create a voltage divider, connecting wires, and optionally a breadboard for easy assembly.

How do I calculate the resistor values for the voltage divider?

To calculate the resistor values for the voltage divider, use the formula: Vout = Vin * (R2 / (R1 + R2)), where Vin is the solar panel voltage, Vout is the desired voltage for the Arduino input (0-5V), and R1 and R2 are the resistor values. Choose R1 and R2 such that Vout is within the Arduino's analog input range. For example, if your solar panel outputs up to 20V, you might choose R1 = 10kΩ and R2 = 2.5kΩ to scale down the voltage to 5V.

How do I write the Arduino code to read the solar panel voltage?

To read the solar panel voltage with Arduino, you can use the `analogRead()` function. First, set up the analog pin in the `setup()` function. In the `loop()` function, read the analog value, convert it to voltage by multiplying with the reference voltage (usually 5V) and dividing by 1024 (the ADC resolution). Apply the voltage divider ratio to get the actual solar panel voltage. Example code:

void setup() {  Serial.begin(9600);}void loop() {  int sensorValue = analogRead(A0);  float voltage = sensorValue * (5.0 / 1024.0);  float solarVoltage = voltage * (R1 + R2) / R2;  Serial.println(solarVoltage);  delay(1000);}
Replace R1 and R2 with your actual resistor values.

What precautions should I take when measuring solar panel voltage with an Arduino?

When measuring solar panel voltage with an Arduino, ensure the voltage does not exceed the Arduino's input limits

Similar threads

Replies
10
Views
1K
Replies
5
Views
1K
Replies
153
Views
14K
Replies
17
Views
15K
Replies
88
Views
10K
Replies
9
Views
3K
Back
Top