Open SUPScientist opened 3 months ago
@efarq, can you check this out?
Here's a reference design for a voltage divider that Particle uses to measure the battery voltage on an Argon: https://docs.particle.io/reference/device-os/api/battery-voltage/battery-voltage-photon-2/#battery-voltage-argon. The voltage on VUSB on the Boron will be higher but the nominal resistances used here are helpful nonetheless. At ≈ 1 MΩ, current wasted will be ≈ 5 µa which isn't too bad.
fuel gauge does not seem to work with usb input: https://community.particle.io/t/fuel-gauge-reading-on-the-usb/62568/3
Just to confirm - is there anything else you'd like me to look into with this since Evan found that community forum?
Yes, I didn't think the fuelgauge would work but it was worth double-checking. See the voltage divider reference above for a proposed solution. I think it will be critical to have solar panel/battery monitoring ability and a voltage divider is very easy to implement and for @ebgoldstein to include in the PCB.
@efarq to design/test voltage divider to scale 5 V nominal solar panel output down to 3.3 V max acceptable Boron ADC analog input. Using equation Vout = Vin*(R2/(R1+R2)) in standard voltage divider circuit, R2 to be ≈ 2 MΩ and R1 to be rounded up to nearest available resistor that keeps Vout ≤ 3.3 V.
Just following up - I think I got it worked out! With Phil's help, I found that R1 = 1.125 megaohms, so I rounded it up to 1.3 megaohms, and R2 = 2 megaohms. Then I set up the Boron with some resistors (photo and circuit diagram attached) and ran the code on it. The Boron V(out) was consistently reading about ~2.7V while it was receiving usb power from my laptop. I checked with the multimeter, and that matched what the Boron was saying too.
I'm uploading the script folder to the Firmware folder, and the Boron+resistors+breadboard are on the counter in Phil's lab. Let me know if anything looks like it needs to be changed.
Great, thanks, @efarq. Nice work. I see the test script in your commit here https://github.com/TinyCamML/Boron-and-OpenMV/commit/e2b713a82b8a3a851c1bc34a9584dc5fcb082bdf and in the new subdirectory here https://github.com/TinyCamML/Boron-and-OpenMV/tree/main/Firmware/TestingVoltageSplitter.
To close this issue, I recommend the following:
(@ebgoldstein, workflow seem appropriate to you? As we add teammates here, I'm more than open to thinking through desired github workflow together/following your lead.)
Okay I think I correctly created a new branch, got the firmware to work with the boron+openMV so it publishes the solar voltage into google sheets, and merged it back into main?
Before closing, I do have a question - how should we calculate the percent of battery charge left? For testing purposes, I just did (voltage read on pin A1)/3.3V*100. However, the voltage going into A1 should never actually reach 3.3V fully because of all the resistors. So the only other way I was thinking of getting that true "full" number is if I use the power supply in the lab to provide the boron with a perfect 5V and see what it reads with that? Any other ideas?
Great! That looks good at a first glance. Confirming that you tested this on the hardware? If so, please say so and click "close with comment."
I recommend removing the percent charge variable and report. Battery charge is non-linearly related to voltage (google "battery discharge curve" for visuals) and can easily be inaccurate. Voltage will suffice. No branch/pull request needed for that change; just remove relevant parts of .ino file and recommit/push, please.
Yes, I tested it on the Boron and OpenMV that bentley was using, and it seems to work.
I'm reopening this so I remember to look at it this week. I just need to double check the code/voltage with a multimeter for this because it's still reporting about 2.8-2.9 V when plugged into usb power. I thought I scaled it up properly by multiplying by an extra ((R1 + R2) / R1)
Need
Want to be able to monitor voltage of external solar panel/battery which is plugged into Boron's V_USB via the micro-USB socket.
Challenge
Particle has methods for monitoring VBATT where a LiPo battery would be connected (via the FuelGauge methods: https://docs.particle.io/reference/device-os/firmware/#fuelgauge) but unclear how to monitor V_USB. Assumption may be that V_USB comes from a stable power supply and does not need to be monitored.
Steps to Solve