AnalogIn reading

Home Forums mDot/xDot AnalogIn reading

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #19229
    Shaheen Parvizi
    Participant

    I am having trouble figuring out how to get a reading from the analog inputs on the developer board.

    I am using the AnalogIn pin(PB_0) to get a reading from A1 on the developer board, and I am trying to send that to the conduit gateway.

    Everytime I upload the binary file onto the developer board, the mdot sends a random hexadecimal value to the conduit each time I upload it, even though nothing is connected to the A1 pin.

    What am I doing wrong.

    #19256
    Mike Fiore
    Blocked

    Shaheen,

    If the pin isn’t connected to anything, I don’t think I’d expect the value to remain perfectly consistent. Have you tried connecting 3V or ground to the pin and seeing if your ADC reading is correct?

    The following equation can be used to convert the 16 bit ADC reading to a voltage:

    voltage = (read_u16() /65535) * (float)VREF

    where VREF is the supply voltage to the mDot.

    Cheers,
    Mike

    #19351
    Shaheen Parvizi
    Participant

    So I just use it like this?

    int voltage = (int)(pinn.read_u16() /65535) * (float)3.3;

    It is just returning 000300 back to me.

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