AnalogIn reading
- This topic has 2 replies, 2 voices, and was last updated 7 years, 5 months ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.
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.
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
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.