Unreliable reads from AnalogIn from mbed lib

Home Forums mDot/xDot Unreliable reads from AnalogIn from mbed lib

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #12470
    Michael
    Participant

    I’m trying to implement the Sparkfun weather meter
    connected to a Sparkfun WeatherShield to a Multitech UDK2 with mDot.

    I have found some sample code but haven’t gotten it to work fully. Currently, I am looking at the weather vane (wind direction) capability which requires the mDot to read an analog voltage and do some magic to determine the direction.

    I’ve used AnalogIn in the past to read the light level on the WeatherShield with no problem.

    However, trying to read the voltage from the weather vane is unreliable. With the weather vane in a fixed position (“north” relative), using a DVM I can measure 3.60V on the Weather Shield and mDot’s pin20 (AD0 / PB_1).

    In turn, I believe I should get back 0.72f (=5V/3.6V) from a read() of that analog input. Sometimes I do, but often I get back a 1.0. This never happened with the light level implementation mentioned earlier.

    Any ideas?

    • This topic was modified 7 years, 11 months ago by Michael.
    • This topic was modified 7 years, 11 months ago by Michael.
    #12473
    Mike Fiore
    Blocked

    Hi Michael,

    The analog reference voltage on the mDot is VDD3, which is 3V. Once pins are configured as analog input, they are no longer 5V tolerant, meaning that >3V should never be applied to a pin in analog input mode. This is why you’re getting strange and inconsistent results.

    You’ll need to scale down the voltage from your sensor before trying to read it with an analog input pin on the mDot.

    Cheers,

    Mike

    #12492
    Michael
    Participant

    That’s depressing – I don’t have that voltage available. 3.3V, yes, but not 3.0V.

    OK, I’ll have to conjure up a scheme.

    Thanks.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.