Measuring battery voltage with ADC gpio

Thomas
Thomas New Member Posts: 18
edited May 2017 in UP Board Linux
I am trying to measure battery voltage using the ADC pin which is listed as gpio2 on the data sheet. However when I try to create the gpio object

mraa:Gpio adc = new mraa::Gpio(2);

I get the error "Invalid GPIO pin specified". Is the mraa gpio numbering the same as the datasheet's?

Also from what I read about the ADC, I think the command

printf("voltage %d \n",adc->read());

should print a integer between 0-255 which corresponds to the voltage between 0-3.3v on the gpio pin. Is this correct?

Thanks!

Thomas

Comments

Privacy Policy