Testing some code to read the voltage divider and convert the A/D read to a voltage.
The 4.092 will need to be adjusted based on your resistors and tolerances.
This pix shows the web board, but the sample code is just testing the voltage divider.. I found the w5100 introduces resistance on pin A2,3,4,5 requiring some code tweeks. Also A0/A1 are not usable without modes the the network module since those pins are used for SD card control.
/*
Read voltage divider module.
Gary Sanders (N8EMR)
ohgary@gmail.com
*/
int volt_pin=5;
void setup() {
Serial.begin(9600); // initialize serial communications for debugging.
}
void loop() {
float voltage;
float l_volt;
l_volt=analogRead(volt_pin);
voltage=(l_volt/4.092)/10;
Serial.print(voltage);
Serial.println("V ");
delay(1000);
}
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.