Cerbuino AnalogInput problem

I’ve a cerbuino with a problem reading analog input.
I’m using a

  Private _adc As Microsoft.SPOT.Hardware.AnalogInput

to read data.
I’ve a pin connected to a sensor, that seems ok. All other pins are free. But


reports something through 200 and 600… why?

Is it better to use ReadRaw or Read to sample an analog sensor?


did you specify which pin?
such as _adc = new AnalogInput(FEZCerbuino.Pin.AnalogIn.A0);



for the pin A0 (where I’ve the sensor connected)


for the pin A1 (currently not connected)

readraw returns the raw ad 0-1023. where
0= 0 volts
1023=3.3 volts
so if you want the voltage you need to divide the returned value by 310

Ehm, how did I explain this reading? :frowning:

? _adc.ReadRaw 

sorry about that it is 12 bit adc not 10 bit as i thought so the range is
4095=3.3 volts
so to get the voltage divide your value by 1240.9

So, if my sensor measures a value between 0 and 12.7, the right formula to read it from cerbuino ADC, rounded to 2 decimal digits, is

 Return System.Math.Round(cPrecision * (_adc.ReadRaw() * 12.7 / 4095) / cPrecision