## Measuring Battery Life

AgentSmithers
Posts: 178
Joined: Sat Apr 01, 2017 1:21 am
Contact:

### Measuring Battery Life

Hi everyone, I am using the Wemos D1 Mini Pro. I just want to reach out and make sure I'm going down the correct path by setting my 107th byte in my init.bin and also I call system_get_vdd33 to get an arbitrary value depending on my battery correct?
The batter will be connected to pin 3v3 and gnd.
https://wiki.wemos.cc/products:retired: ... pro_v1.1.0
Thanks!
-Agent

AgentSmithers
Posts: 178
Joined: Sat Apr 01, 2017 1:21 am
Contact:

### Re: Measuring Battery Life

Anyone?
Thank you!

blubb
Posts: 116
Joined: Mon Jun 22, 2015 5:35 am

### Re: Measuring Battery Life

Why not just try it?

The 107th (0x6B) byte has to be 0xFF.
system_get_vdd33() returns the voltage in 1/1024 Volt.

So calculate system_get_vdd33() * 1000L >> 10 to get the battery voltage in mV.

It works here... (ESP-01)

AgentSmithers
Posts: 178
Joined: Sat Apr 01, 2017 1:21 am
Contact:

### Re: Measuring Battery Life

blubb wrote:Why not just try it?

The 107th (0x6B) byte has to be 0xFF.
system_get_vdd33() returns the voltage in 1/1024 Volt.

So calculate system_get_vdd33() * 1000L >> 10 to get the battery voltage in mV.

It works here... (ESP-01)

That's interesting. Do I need to put a voltage divider for this example? After reviewing the command it seems it pulls from
Pin 3/4 aka VDD3P3
https://wiki.wemos.cc/_media/products:d ... v1.1.0.pdf

This here above shows those are Pins GPIO 16 (D0) and 14(D5) . Do both these pins detect a voltage somehow or do I have to add a Voltage + to one and GND to another?

blubb
Posts: 116
Joined: Mon Jun 22, 2015 5:35 am

### Re: Measuring Battery Life

system_get_vdd33() directly measures the supply voltage. No other pins are required for this. The SDK manual also says that TOUT pin needs to be suspended. I am using the very simple ESP-01 modules. I have no idea what they did to that pin, but it works just fine.

AgentSmithers
Posts: 178
Joined: Sat Apr 01, 2017 1:21 am
Contact:

### Re: Measuring Battery Life

blubb wrote:system_get_vdd33() directly measures the supply voltage. No other pins are required for this. The SDK manual also says that TOUT pin needs to be suspended. I am using the very simple ESP-01 modules. I have no idea what they did to that pin, but it works just fine.

Gotcha, So TOUT for me I think is A0 on my board. Can't tell from the Schematic directly but I think that's the pin it is talking about. I just need to leave it floating.
So Basically I need to hook up my device via battery to 3.3 and GND then make sure my default.bin offset 107 is set to FF then run the command and see what I get.
Correct?

AgentSmithers
Posts: 178
Joined: Sat Apr 01, 2017 1:21 am
Contact:

### Re: Measuring Battery Life

blubb wrote:Why not just try it?

The 107th (0x6B) byte has to be 0xFF.
system_get_vdd33() returns the voltage in 1/1024 Volt.

So calculate system_get_vdd33() * 1000L >> 10 to get the battery voltage in mV.

It works here... (ESP-01)

Blubb,
How does your logic work
Do you take the value returned by vdd multiply it by 1000 then bitshift it over 10 bits?
I am unsure on how that will return the mV, Can you enlighten?
Thank you!! =)

blubb
Posts: 116
Joined: Mon Jun 22, 2015 5:35 am

### Re: Measuring Battery Life

Then just write

system_get_vdd33() * 1000L / 1024

Same result (because 1 << 10 == 2 ^ 10 == 1024)

Return to “ESP8266 SDK”

### Who is online

Users browsing this forum: No registered users and 6 guests