Hello,
With my MKR1200, I tried to read the battery level and it doesn't work.
I read this variable with this function int sensorValue = analogRead(ADC_BATTERY);
and the variable sensorValue send me always the same value???
It's the same like if we do => analogRead(32)
A battery is connected on green screw terminals and I'm using the serial port from the pins.
Maybe one library is missing....
What can I do?
Thanks,
###################
Here the code I'm using :
#include <pins_arduino.h>
#include <ArduinoLowPower.h>
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial1.begin(9600);
Serial1.println("Setup done");
//analogReadResolution(12);//12bits
analogReference(AR_DEFAULT);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(ADC_BATTERY);
float voltage = sensorValue * (3.3 / 1023.0/1.2*(1.2+0.33));
Serial1.print("Battery Voltage Raw: ");
Serial1.print(sensorValue);
Serial1.print(" - ");
Serial1.print("Battery Voltage(V): ");
Serial1.print(voltage);
Serial1.println(" V");
}