AnalogIn showing random values when it should show 0v

11 Apr 2012

Hello,

I've been using the mbed microcontroller for over 2 months, and since day one I keep getting random values in the AnalogIn when I don't a power source connected to a port.

I searched the forum for a solution and didn't find anything that helped me to resolve this problem.

To test this I'm using this short program:

#include "mbed.h"

AnalogIn ain(p20);

int main() {
    while (1){
        printf("ain = %f \r\n", ain.read());;
    }
}

Do you know any way to resolve this?

Regards, Adriano

11 Apr 2012

It's not a problem, it's a feature, or better said, it's physics.

11 Apr 2012

It's floating, so it's not going to measure "anything"....

Tie it to ground and it'll measure 0V. Right now, it's not actually connected to anything, so it's not 0V.