#include <ESP8266WiFi.h>
extern "C" {
uint16 readvdd33(void);
}
void setup() {
WiFi.mode(WIFI_AP_STA); // readvdd33 doesn't work currently in WIFI_STA mode
Serial.begin(115200);
Serial.println();
}
void loop() {
float vdd = readvdd33() / 1000.0;
Serial.print("Vdd: ");
Serial.println(vdd);
delay(1000);
}
Moderator: igrr
//used samples from http://www.esp8266.com/viewtopic.php?f=33&t=2485
//Use a silicone diode to drop the voltage from the Lithium battery to within a safe range for the ESP module (should be between 2.5-3.6v)
//readvdd33() does not return correct values if anything is connect to the ADC pin
extern "C" {
uint16 readvdd33(void);
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println();
Serial.println();
Serial.print("VCC:");
Serial.println(readvdd33()); //this is the raw reading in mV, should something like 3300 if powered by 3.3volts
Serial.print("Battery:");
Serial.println(readvdd33()+600); //here we add the voltage drop from the diode back to give us an idea of the battery voltage
}
void loop() {
// put your main code here, to run repeatedly:
}
I don't have a chip spare to try it on atm
Can you have a wire on the adc that can be activated further down the program?