-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Description
Hardware:
Board: doit ESP32 devkit v1 (36 Pins) (ESP32-WROOM)
Core Installation/update date: ?11/jul/2017?
IDE name: Arduino IDE
Flash Frequency: 80MHz
Upload Speed: 921600
Computer OS: Windows 10
Description:
Hi folks
I use doit esp32-wroom (doit esp32 devkitv1) as temperature sensor in my tortoise enclosure.
I use this microcontroller with an 3.7v 18650 battery (4200 mAh). And it works. I connected the battery to the VIN pin.
Now I would like to measure the battery power level and send a MQTT message to log this. Because I would like to know when the battery is empty and send a message to change the battery. Another use case is how the battery will be reloaded (by solar panel)… but this comes later.
My problem is: I can't find how I can measure the power correctly.
I found a method with "extern "C" int rom_phy_get_vdd33();", but I don’t know what kind of data these are:
5471.00 5474.00 5477.00 5477.00 5480.00 5473.00 5474.00
Do I have to calculate something? Is there a better/standard way to calculate battery level?
These values seems to have no relevance to my 18650 (3.7v, 4200mAh)...
I don't have used any resistors from 18650 to VIN pin. I found a lot posts about use resistors for analog pins, but nothing about VIN pin.
That's my first "battery"-project, and I didn't find anything to help me.
Sketch:
extern "C" int rom_phy_get_vdd33();
...
...
void setup() {
...
/* battery power measuring */
int internalBatReading;
if (WiFi.status() == 255) {
btStart();
internalBatReading = rom_phy_get_vdd33();
Serial.println(internalBatReading);
btStop();
}
...
}