Hi,
I have Maduino Zero A9G with an ATSAMD21G18 and an A9G circuit (Maduino Zero A9G), I was able to use the GPS and GPRS functionality of the board but I hit a road block when I tried to read the battery voltage and the USB voltage, two information that the board is supposed to provide.
I looked at the schematic of the board (Maduino Zero A9G Schematic)and I couldn't figure out how the voltage information is read. I was confused on whatever the A9G or the ATSAMD21G18 provide that information.
This is the only reference to the battery and USB voltage I was able to find, but it doesn't provide any detail on how it's done. Hackaday.io sample project
I would really appreciate it if someone can provide me with a clue on how to get the voltage information.
Thank You!
If you look at the Schematic top right corner, VBAT and VSYS are connected to A1 and A2 via a voltage divider.
Klaus_K gave you a good answer, in addition I would suggest going onto youtube and searching with "basic electronics" this will get you past the basics and on your way to becoming knowledgeable. This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil
Thank you for pointing that out! I used this code to read from both A1 and A2 and it provided me with a constant value which correspnd to the VBAT and VSYS(USB).
#define VBATPIN A1
#define VSYSPIN A2
#define SerialMonitor SerialUSB
void setup()
{
SerialMonitor.begin(9600);
}
void loop()
{
readbattinfo();
}
void readbattinfo()
{
float measuredvbat = analogRead(VBATPIN);
measuredvbat *= 2; // we divided by 2, so multiply back
measuredvbat *= 3.3; // Multiply by 3.3V, our reference voltage
measuredvbat /= 1024; // convert to voltage
SerialMonitor.print("VBat: " ); SerialMonitor.println(measuredvbat);
float measuredvsys = analogRead(VSYSPIN);
measuredvsys *= 2; // we divided by 2, so multiply back
measuredvsys *= 3.3; // Multiply by 3.3V, our reference voltage
measuredvsys /= 1024; // convert to voltage
SerialMonitor.print("VSys: " ); SerialMonitor.println(measuredvbat);
delay (1000);
}