UPDATE: As pointed out by JohnWasser, the ground of the lipo and solar charger are connected, so I can just plug the positive of the lipo into an analogread pin of the tiny. I have since tried this, and I now get a reading of 800 for 3.85V (when checked by oscilloscope). I'm hoping this is good and will continue to update as I progress.
Hey all,
I'm trying to measure the voltage of a LiPo battery using an ATTiny85, but through hours of googling I have only found solutions for multiple cells or measuring the same voltage the tiny is running off, which don't work here.
The ATTiny85 is powered by the LiPo via a charging circuit that incorporates a solar panel connection. The output of which is 5V unchanged throughout the battery life.
The reason I want to do this is because when the battery gets low, it seems like the current draw limit gets higher (as expected) but my circuit will stop functioning properly and wreak havoc (explained in detail below). I want to see when the battery is low, stop performing certain functions in the circuit, and wait until the battery voltage goes back up.
I have made two diagrams (attached below) , one showing what I'm trying to do as an individual issue, and the other showing most of the project components.
I've attempted to use AnalogRead(); on the A2 pin of the tiny but it became hot and smelled great.
I've also tried searching endlessly online but as mentioned before I found nothing within my knowledge range.
Any help on what I should do (or even google) would be greatly appreciated, thank you.
You diagram is not very useful since it suggests that "other sensors" and "water pump" is connected only to the ATtiny which is probably not right. If your ATtiny has been warm and smelly, then it is most likely not functioning properly anymore and should be replaced.
If the voltage fed to VCC equals the maximum voltage in the cirquit then that voltage should be all you need to read. You may want to read the voltage during or right after high current consumption has happened. You could also look at the fuses for brown out detection which will cause the ATtiny not to boot before a minimum threshold of voltage is available.
If higher voltages are present then look up on "voltage dividers".
Oops! You're right about the diagram, yes everything is powered by the Vcc from the charger circuit.
But the problem with the Vcc is the voltage doesn't change when various loads are applied, on the LiPo however it does, (checked using an oscilloscope). So measuring the Vcc on the charger circuit still won't do anything.
The issue in question arises after too much current is taken and it's too late to undo. So I need to see the voltage in advance.
No higher voltages are present, everything is 5V or less
The big question is: Does the negative side of the LiPo cell connect directly to ATtiny Ground through the charging circuit? If so, just connect the positive side of the cell to the ATtiny analog input and read the cell voltage directly. This will not work if the LiPo cell ground and ATtiny ground are not connected to each other.
If you are trying to read the voltage with analogRead, then you must remember that the voltage to the input-pin is equal to the reference voltage and therefore the reading will always be 1023 or a smidgeon less. You can however get the supply voltage by using the "Secret Arduino Voltmeter" - I just cannot remember if it works with the ATTiny85, but you can try!
johnwasser:
The big question is: Does the negative side of the LiPo cell connect directly to ATtiny Ground through the charging circuit? If so, just connect the positive side of the cell to the ATtiny analog input and read the cell voltage directly. This will not work if the LiPo cell ground and ATtiny ground are not connected to each other.
Great idea! I tested the grounds of the lipo and charger output and they are indeed directly connected! I will try something with the analog input now and see if I can get a reading.