Hi all,
First time posting so let me know if I need to do anything differently in the future or add any more details.
Working on my master's thesis and analyzing long-term solar tracker performance at higher latitudes in the mountains of western North Carolina. Ideally, the test will run for around six months and be a fully standalone system that monitors and stores its own data that I will just need to collect every week or so for analysis. Below is my 3D-printed armature for the tracker and a fixed panel stand that will be my control for the test.
I discovered the INA260 chip and I wanted to use it to monitor various aspects of my solar tracker, but I had questions about how to correctly hook them up to the solar panel and servos that would be moving the tracking panel about. Here's a Fritzing diagram of most of the circuit (the only parts I couldn't find were the power management system I'm using and the solar panel itself):
The Arduino will be hooked up to a DFRobot Solar Power Manager V1.1 on the regulated 5V 1A output (Found here, and some documentation about it can be found here). The power manager will have a 6W solar panel and a 3.7V 10Ah battery connected to it.
Ok so after that preamble, on to the actual questions:
(1) For monitoring the servos is the correct placement for the INA chips in high-side configuration between the 5V line on the Arduino and the servo? Will the INA chip interfere with the servo working? I wanted to monitor the power usage from the two servos compared to the power gain seen by the tracking panel to weigh the pros and cons of a tracked system as a part of the ROI/cost analysis since I hadn't seen any papers talk about it so far (but now I'm realizing the struggle I've signed myself up for).
(2) For monitoring the two panels, I've been measuring the voltage and current of each panel separately across a small load resistor in a high-side configuration. Will this interfere with the charge cycle on the power manager? I've tried emailing DFRobot and posted the question to their website directly but haven't heard back from them yet so I figured it wouldn't hurt to ask here too.
(3) In my particular set up is there anything that would be causing the Arduino to reset itself periodically? I've been running various tests in my office using a fixed 5V bench power supply as my "solar panel" on the load resistor to try and dial in the sensitivity of the INA chips, but I noticed in the serial monitor that the Arduino was running the setup loop again periodically as if it had reset itself. During testing the Arduino has remained connected to my computer but I'm wondering if it's somehow not getting enough power. Do I need an external power supply for the Arduino with everything hooked up to it? The power manager only has a USB hookup so I'm going to have to completely revisit how this circuit is built if the Uno isn't getting enough power...
Monitoring a solar tracker with INA260 chips
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- llombard17
- Posts: 8
- Joined: Fri Oct 21, 2022 1:32 am
Monitoring a solar tracker with INA260 chips
- Attachments
-
- solarpanels.jpg (113.75 KiB) Viewed 275 times
-
- ThesisCircuit.jpg (138.53 KiB) Viewed 275 times
-
- ThesisCircuitImg.jpg (400.92 KiB) Viewed 275 times
- adafruit_support_bill
- Posts: 88136
- Joined: Sat Feb 07, 2009 10:11 am
Re: Monitoring a solar tracker with INA260 chips
(1) The INA current sensor should not interfere with servo operation. It uses a 2 milliohm shunt resistor for sensing, so the voltage drop will be negligible. To minimize servo power utilization, you might consider intermittent operation. Since the sun is moving rather slowly across the sky, small adjustments every few minutes are probably sufficient. And if your panels are well balanced, you could power down the servos between adjustments.
(2) A load resistor on the input side of the power manager should not disrupt the charge cycle. It will just reduce the available power it has to work with. Given that solar power is variable, too much shunt resistance can make the difference between charging and not-charging in marginal solar conditions. If using something like the INA260, the 2 milliohm shunt should have negligible impact.
(3) The servos are a likely suspect here. Servos are electrically noisy devices with high peak current demands. They can cause 'brownouts' and generate noise on the power & ground rails that can interfere with processor operation. A separate power source is the 'best' solution. But that is not always feasible. Another approach is to add some large-ish capacitance between the power and ground rails near the servos. This will help to smooth out the spikes in current demand.
(2) A load resistor on the input side of the power manager should not disrupt the charge cycle. It will just reduce the available power it has to work with. Given that solar power is variable, too much shunt resistance can make the difference between charging and not-charging in marginal solar conditions. If using something like the INA260, the 2 milliohm shunt should have negligible impact.
(3) The servos are a likely suspect here. Servos are electrically noisy devices with high peak current demands. They can cause 'brownouts' and generate noise on the power & ground rails that can interfere with processor operation. A separate power source is the 'best' solution. But that is not always feasible. Another approach is to add some large-ish capacitance between the power and ground rails near the servos. This will help to smooth out the spikes in current demand.
- llombard17
- Posts: 8
- Joined: Fri Oct 21, 2022 1:32 am
Re: Monitoring a solar tracker with INA260 chips
Hey Bill, thanks for the speedy reply!
(1) I am planning on only prompting the movement from the servos according to a P&O algorithm and the time reading from the DS3231M. The way the code is written, it only pulses the servos if it's on the hour or half hour and the LDRs are measuring a noticeable difference between the four corners on the panel.
(3) Unfortunately when the Arduino was resetting itself during testing, neither of the servos we're connected to the Arduino so they were not the culprit this time. (Though I will see where I could add on that capacitor once they're back in the circuit for that bit of testing...) Is there anything else that could be problematic in the circuit?
Thanks!
(1) I am planning on only prompting the movement from the servos according to a P&O algorithm and the time reading from the DS3231M. The way the code is written, it only pulses the servos if it's on the hour or half hour and the LDRs are measuring a noticeable difference between the four corners on the panel.
(3) Unfortunately when the Arduino was resetting itself during testing, neither of the servos we're connected to the Arduino so they were not the culprit this time. (Though I will see where I could add on that capacitor once they're back in the circuit for that bit of testing...) Is there anything else that could be problematic in the circuit?
Thanks!
- adafruit_support_bill
- Posts: 88136
- Joined: Sat Feb 07, 2009 10:11 am
Re: Monitoring a solar tracker with INA260 chips
Your diagram does not show any power connections supplying the Arduino. If it was connected via USB, it should be getting a stable supply from your computer. Were there any connections from your solar power controller?
- llombard17
- Posts: 8
- Joined: Fri Oct 21, 2022 1:32 am
Re: Monitoring a solar tracker with INA260 chips
Ah sorry yes the Arduino is connected to a USB 3.0 port on my computer for these tests so I could get Serial Monitor output so it's getting power from there. The breadboard is connected to the 5V and Gnd pin via the red and blue wires (I realized those weren't in the diagram either sorry).
- adafruit_support_bill
- Posts: 88136
- Joined: Sat Feb 07, 2009 10:11 am
Re: Monitoring a solar tracker with INA260 chips
Not sure how Elegoo implemented the power section on their UNO clone. But it is possible that you are getting some conflict between the USB voltage regulator and your other power source. I'd disconnect from the power rails on the breadboard when you are connected via USB. (The other option would be to cut the 5v VBUS line on a USB cable so that it is 'data only' for communication to the PC).
- llombard17
- Posts: 8
- Joined: Fri Oct 21, 2022 1:32 am
Re: Monitoring a solar tracker with INA260 chips
Hmm I don't think I can completely isolate the breadboard from the Arduino because all of the various chips are getting their power from the 5V/GND connections on the Arduino. The desktop power supply is only going into the INA chips in the V+ connections and is commonly grounded on the ground rail on the breadboard, but the 5V power from the power supply isn't going to the Arduino directly in any capacity that I can tell. (In the bottom image of the physical circuit, it's the three alligator clips going to the INA chips).
Could I add an external power supply via the barrel jack or the Vin line?
Could I add an external power supply via the barrel jack or the Vin line?
- adafruit_support_bill
- Posts: 88136
- Joined: Sat Feb 07, 2009 10:11 am
Re: Monitoring a solar tracker with INA260 chips
If your external supply is only going to the INA sensors, then it should not cause a conflict with your USB supply. I don't see any other obvious sources interference or power issues.
Sometimes the best way to isolate the problem is to start disconnecting parts of the circuit until the problem goes away. Then the last thing you disconnected is probably the culprit.
Sometimes the best way to isolate the problem is to start disconnecting parts of the circuit until the problem goes away. Then the last thing you disconnected is probably the culprit.
- llombard17
- Posts: 8
- Joined: Fri Oct 21, 2022 1:32 am
Re: Monitoring a solar tracker with INA260 chips
Hey Bill,
I'm still having the issue where the Arduino is periodically resetting itself (every fourth cycle) and going through the setup loop again when it shouldn't. I've removed everything from the setup, excluding a single INA260 chip connected to the Uno connected to my computer. I switched the Elegoo clone out for a genuine Arduino Uno, and I don't currently have any power supply connected to the INA chip. Yet, the Arduino was resetting every fourth cycle, regardless of what the INA chip measured when the load resistor was connected (or even when nothing was connected). At this point, I'm convinced the problem lies in my code, but nothing is glaringly wrong when I look at various code examples for the INA chip online. Could you take a look at it? (posted code below)
At this point, I do not even involve data storage or timekeeping, so this code's only purpose is to convey the three INA measurements after each minute delay has passed. Since there is no "end" command in the INA library, I do not see how to halt communication with the INA chip after each cycle. I suspect I'm causing some kind of data overflow or miscommunication by repeatedly attempting to communicate with the chip. Eventually, the final device will need to be able to switch between four INA chips and an RTC chip on the I2C bus, but first, I'd like to establish at least what I'm doing wrong with the single INA chip.
Thank you for all of your help,
BANNED
I'm still having the issue where the Arduino is periodically resetting itself (every fourth cycle) and going through the setup loop again when it shouldn't. I've removed everything from the setup, excluding a single INA260 chip connected to the Uno connected to my computer. I switched the Elegoo clone out for a genuine Arduino Uno, and I don't currently have any power supply connected to the INA chip. Yet, the Arduino was resetting every fourth cycle, regardless of what the INA chip measured when the load resistor was connected (or even when nothing was connected). At this point, I'm convinced the problem lies in my code, but nothing is glaringly wrong when I look at various code examples for the INA chip online. Could you take a look at it? (posted code below)
At this point, I do not even involve data storage or timekeeping, so this code's only purpose is to convey the three INA measurements after each minute delay has passed. Since there is no "end" command in the INA library, I do not see how to halt communication with the INA chip after each cycle. I suspect I'm causing some kind of data overflow or miscommunication by repeatedly attempting to communicate with the chip. Eventually, the final device will need to be able to switch between four INA chips and an RTC chip on the I2C bus, but first, I'd like to establish at least what I'm doing wrong with the single INA chip.
Thank you for all of your help,
BANNED
Code: Select all
// Libraries
#include <Servo.h>
#include "Arduino.h"
#include <Wire.h>
#include <SD.h>
#include <SPI.h>
#include <DS3231M.h>
#include <Adafruit_INA260.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
// Declare INA260 Chips
Adafruit_INA260 INA260F = Adafruit_INA260( ); // Address 0x40 for Tracked Panel (Default)
// The other three chips are physically removed, so these are commented out for now
//Adafruit_INA260 INA260T = Adafruit_INA260( ); // Address 0x41 for Fixed Panel
//Adafruit_INA260 INA260MH = Adafruit_INA260( ); // Address 0x44 for Horizontal Motor
//Adafruit_INA260 INA260MV = Adafruit_INA260( ); // Address 0x45 for Vertical Motor
void setup() {
Wire.begin(); // Initialize serial communication
Serial.begin(115200); // 115200 baud rate
while (!Serial) { delay(10);} // Wait until Serial Port is open
Serial.println("Setup Loop Done");
}
int t = 0; // Initialize a time variable for iteration count
void loop() {
Serial.print("Current Time is: ");
Serial.println(t); // Print current "time" value
INA260F.begin(0x40); // Begin communication with INA260F at address 0x40
Serial.print("INA260F Current: ");
Serial.print(INA260F.readCurrent());
Serial.println(" mA");
delay(10);
Serial.print("INA260F Bus Voltage: ");
Serial.print(INA260F.readBusVoltage());
Serial.println(" mV");
delay(10);
Serial.print("INA260F Power: ");
Serial.print(INA260F.readPower());
Serial.println(" mW");
delay(10);
t = t + 1; // Increment time
delay(60000); // Wait 1 minute
}
- adafruit_support_bill
- Posts: 88136
- Joined: Sat Feb 07, 2009 10:11 am
Re: Monitoring a solar tracker with INA260 chips
You mean every 4th time through the loop? Is it always every 4 iterations? Never 3 or 5?I'm still having the issue where the Arduino is periodically resetting itself (every fourth cycle)
I don't see anything in the code that should trigger a reset. And nothing at all that should work differently on every 4th iteration.
Are you sure it is not time based? If you cut the delay to 30 seconds does it still reset every 4 iterations?
- llombard17
- Posts: 8
- Joined: Fri Oct 21, 2022 1:32 am
Re: Monitoring a solar tracker with INA260 chips
Hey, so I reran the code today. Instead of resetting the Arduino, it's just ceased outputting to the serial monitor after the 5th loop (I may have mistakenly assumed it was four loops because I forgot there is a "0th" loop because of the way the code is written to increment "i" at the bottom of the loop). After a while, I manually reset the Arduino after each test. I looked back at my copy of the serial monitor from previous tests, and it was consistently stopping output after the 5th loop, even back when I had the RTC chip involved for timekeeping.
I copied the output from the most recent test below; it's running the same code as what I posted previously, except there is a 30-second delay instead of 60. So the serial monitor is receiving the 5th "time" readout/iteration count, but it doesn't receive anything beyond that point, no matter how long I wait before I reset the Arduino. I've tried this code on all the Arduinos I have access to, and it's consistently happening, even on the Arduino brand Uno.
I've removed everything that I can, excluding the jumper wires going to the spots on the breadboard where the other chips would be if they were plugged in. Adding external power via the barrel jack also did not help so I'm completely stumped as to what could be causing this issue...
I copied the output from the most recent test below; it's running the same code as what I posted previously, except there is a 30-second delay instead of 60. So the serial monitor is receiving the 5th "time" readout/iteration count, but it doesn't receive anything beyond that point, no matter how long I wait before I reset the Arduino. I've tried this code on all the Arduinos I have access to, and it's consistently happening, even on the Arduino brand Uno.
Code: Select all
(For the first two iterations, there is *no voltage* supplied so the Vin+/- terminals on the INA chip)
Setup Loop Done
Current Time is: 0
INA260F Current: -2.50 mA
INA260F Bus Voltage: 0.00 mV
INA260F Power: 0.00 mW
Current Time is: 1
INA260F Current: -1.25 mA
INA260F Bus Voltage: 0.00 mV
INA260F Power: 0.00 mW
Current Time is: 2
INA260F Current: -2.50 mA
INA260F Bus Voltage: 0.00 mV
INA260F Power: 0.00 mW
Current Time is: 3
INA260F Current: -3.75 mA
INA260F Bus Voltage: 0.00 mV
INA260F Power: 0.00 mW
Current Time is: 4
INA260F Current: -1.25 mA
INA260F Bus Voltage: 0.00 mV
INA260F Power: 0.00 mW
Current Time is: 5
(I manually reset the Arduino here after it sat doing "nothing" for several minutes)
Setup Loop Done
Current Time is: 0
INA260F Current: -3.75 mA
INA260F Bus Voltage: 0.00 mV
INA260F Power: 0.00 mW
Current Time is: 1
INA260F Current: -1.25 mA
INA260F Bus Voltage: 0.00 mV
INA260F Power: 0.00 mW
Current Time is: 2
INA260F Current: -2.50 mA
INA260F Bus Voltage: 2.50 mV
INA260F Power: 0.00 mW
Current Time is: 3
INA260F Current: -2.50 mA
INA260F Bus Voltage: 0.00 mV
INA260F Power: 0.00 mW
Current Time is: 4
INA260F Current: -2.50 mA
INA260F Bus Voltage: 0.00 mV
INA260F Power: 0.00 mW
Current Time is: 5
(Reset the Arduino again, and turned on the 5V power supply to see if anything changed when Vin+/- had power)
Setup Loop Done
Current Time is: 0
INA260F Current: 12.50 mA
INA260F Bus Voltage: 4967.50 mV
INA260F Power: 80.00 mW
Current Time is: 1
INA260F Current: 13.75 mA
INA260F Bus Voltage: 4966.25 mV
INA260F Power: 60.00 mW
Current Time is: 2
INA260F Current: 15.00 mA
INA260F Bus Voltage: 4967.50 mV
INA260F Power: 80.00 mW
Current Time is: 3
INA260F Current: 13.75 mA
INA260F Bus Voltage: 4966.25 mV
INA260F Power: 60.00 mW
Current Time is: 4
INA260F Current: 13.75 mA
INA260F Bus Voltage: 4967.50 mV
INA260F Power: 80.00 mW
Current Time is: 5
(Reset Manually)
Setup Loop Done
Current Time is: 0
INA260F Current: 13.75 mA
INA260F Bus Voltage: 4967.50 mV
INA260F Power: 60.00 mW
Current Time is: 1
INA260F Current: 13.75 mA
INA260F Bus Voltage: 4968.75 mV
INA260F Power: 80.00 mW
Current Time is: 2
INA260F Current: 13.75 mA
INA260F Bus Voltage: 4968.75 mV
INA260F Power: 60.00 mW
Current Time is: 3
INA260F Current: 12.50 mA
INA260F Bus Voltage: 4970.00 mV
INA260F Power: 60.00 mW
Current Time is: 4
INA260F Current: 12.50 mA
INA260F Bus Voltage: 4968.75 mV
INA260F Power: 80.00 mW
Current Time is: 5
(Reset Manually)
Setup Loop Done
Current Time is: 0
INA260F Current: 13.75 mA
INA260F Bus Voltage: 4967.50 mV
INA260F Power: 60.00 mW
Current Time is: 1
INA260F Current: 13.75 mA
INA260F Bus Voltage: 4967.50 mV
INA260F Power: 60.00 mW
Current Time is: 2
INA260F Current: 13.75 mA
INA260F Bus Voltage: 4967.50 mV
INA260F Power: 60.00 mW
Current Time is: 3
INA260F Current: 13.75 mA
INA260F Bus Voltage: 4968.75 mV
INA260F Power: 80.00 mW
Current Time is: 4
INA260F Current: 12.50 mA
INA260F Bus Voltage: 4968.75 mV
INA260F Power: 60.00 mW
Current Time is: 5
I've removed everything that I can, excluding the jumper wires going to the spots on the breadboard where the other chips would be if they were plugged in. Adding external power via the barrel jack also did not help so I'm completely stumped as to what could be causing this issue...
- llombard17
- Posts: 8
- Joined: Fri Oct 21, 2022 1:32 am
Re: Monitoring a solar tracker with INA260 chips
Update: Moving the INA260F.begin(0x40) line from the void loop up to the setup loop ceased the resetting issue, but I would have five I2C devices that I would need to switch between, so I can't "begin" them all in the setup loop, right? How would I switch between them outside of the setup loop?
- adafruit_support_bill
- Posts: 88136
- Joined: Sat Feb 07, 2009 10:11 am
Re: Monitoring a solar tracker with INA260 chips
Looks like the begin function does a bunch of heap allocations. The UNO is pretty memory limited. You may be crashing the stack with the multiple calls in the loop.Moving the INA260F.begin(0x40) line from the void loop up to the setup loop ceased the resetting issue,
https://learn.adafruit.com/memories-of- ... o-memories
The device has only 4 possible addresses. With 4, you could probably initialize all in setup. Although if you are running out of memory at 5, you may want to upgrade to a processor with more memory.I would have five I2C devices that I would need to switch between
If you do need to have more than 4 of these devices, you will need something like an i2c multiplexer to avoid problems with duplicate addresses: https://www.adafruit.com/product/2717
- llombard17
- Posts: 8
- Joined: Fri Oct 21, 2022 1:32 am
Re: Monitoring a solar tracker with INA260 chips
Ah no, sorry, I only have the four INA260 chips (addressed 0x40,0x41,0x44,& 0x45); the RTC DS3231M chip would be the fifth I2C device. I'll keep working with the code some more tomorrow when I return to the office and see if I can get them all working together. When calling each INA chip separately using the INA260.readCurrent (or Power or Voltage) commands, will all of them sending data on the I2C bus be too much "chatter" for the Uno to decipher, or does it only send data when requested by the Arduino?
Thank you so much for all of your help!
Thank you so much for all of your help!
- adafruit_support_bill
- Posts: 88136
- Joined: Sat Feb 07, 2009 10:11 am
Re: Monitoring a solar tracker with INA260 chips
The Arduino is the 'master' device and the 'slave' devices will only respond when requested. So there is no unsolicited 'chatter' on the bus.
Please be positive and constructive with your questions and comments.