If we wanted to get the battery level as a voltage value (say 3.1v) rather than a % what should we do?
Hello Brian, I need more details:
- What’s the maximum voltage of your battery?
- Which board are you using?
- Which programming language?
You can find that answer in this thread: https://rntlab.com/question/get-battery-level/
You need to do what Sara already suggested. First, you need to use a voltage divider in the battery (so it only outputs 3.3V, because that’s the maximum voltage the ESP32 GPIOs can read): https://rntlab.com/esp32-lora-sender-solar-powered-part-4/
In line 133 of the code https://github.com/RuiSantosdotme/ESP32-Course/blob/master/code/LoRa_Project/LoRa_Sender/LoRa_Sender.ino you should use something as follows:
batteryLevel = map(analogRead(batteryPin), 0.0f, 4095.0f, 0, 3.3);
Instead of mapping to a range of 0 to 100, you use a range of 0 to 3.3V.
I haven’t tested this, but I think it should definitely work.