Open rigr opened 1 year ago
thanks for your reply. Is there a on-board way to measure the voltage without using external hardware?
TTGO-T-display for example allows monitoring the voltage using float measurement = (float)analogRead(34); float battery_voltage = (measurement / 4095.0) * 7.26; So is there a pin on bpi-leaf-s3 that allows the same?
Different lithium batteries have different characteristics.
You can do a statistical experiment, record the histogram of your battery voltage and power, and then design a function that meets your needs.
I can't give you the answer directly.
You have found a suitable example.
How to do it depends on you.
Enjoy development 👍
:) well, thanks for your reply. All I wanted to know was what pin to monitor for the battery voltage, but it's ok, if you can't tell me. I can use two 100k resistors and build a voltage divider, and connect + from the battery, but it would be nice if no external parts were needed.
I still have issues measuring the voltage. Here is my code. Strange thing happens: If I use it as displayd below I get reading of 2320 to 2395 without a battery attached. If I have both serial.println - statements, the first is about 2200 while the other one is higher and if I comment out the first measurement the serail shows values of about 1900-2050.
With a battery atached and both readings I get values like:
2032.00 2381.00
2036.00 2386.00
2032.00 2383.00
2037.00 2383.00
2036.00 2379.00
2033.00 2379.00
2031.00 2386.00
It looks strange that analogRead(14) in a double is so much lower than (float)analogRead(14).
Is there an explanation or am I doing something wrong?
Thank you!
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
double reading = analogRead(14);
// Serial.println(reading);
Serial.println(String((float)analogRead(14)));
Serial.println(" ");
delay(2000);
}
Reopened because of strange readings.
Please help me writing a small arduino sketch that monitors the voltage of the battery connected to the bpi-leaf-s3. I'd like to see he voltage on a small oled and when the voltage is below a certain value (for example 3.7V) the leaf should go into deep sleep. What pin should be read? what multiplication is needed to give a good value? I tried A13 but am not happy yet. :) And if there is a better place to ask - please let me know. Thank you and best regards!