Just hooked this board up to the Le Potato, exciting!
I’m getting this sort of output.
The below measurements are with the sensor not blocked. I.e. distance being measured is “infinite”. While I took these readings, the multimeter (which I also had hooked up to measure the same) was bouncing around between 0.08v and 0.15v
# cat /sys/bus/iio/devices/iio:device0/in_voltage0_raw
79
# cat /sys/bus/iio/devices/iio:device0/in_voltage0_raw
94
# cat /sys/bus/iio/devices/iio:device0/in_voltage0_raw
105
# cat /sys/bus/iio/devices/iio:device0/in_voltage0_raw
118
# cat /sys/bus/iio/devices/iio:device0/in_voltage0_raw
168
The below measurements are with the sensor being held by my soldering third-arm, and the third-arm holding a piece of paper above the sensor at a fixed distance. The multimeter was reading between 1.192v and 1.196v.
# cat /sys/bus/iio/devices/iio:device0/in_voltage0_raw
2641
# cat /sys/bus/iio/devices/iio:device0/in_voltage0_raw
2608
# cat /sys/bus/iio/devices/iio:device0/in_voltage0_raw
2602
# cat /sys/bus/iio/devices/iio:device0/in_voltage0_raw
2644
# cat /sys/bus/iio/devices/iio:device0/in_voltage0_raw
2652
I need to figure out what these numbers output by the Le Potato mean and how to correlate them to actual voltages. Or, maybe the correlation between these numbers and actual voltages doesn’t matter, and I can create a formula to convert these numbers to distances.
After some more tinkering, the maximum value from the SARADC seems to be 4095, which suggests a 12 bit value.
Assuming the ADC value is 0 at 0v, and assuming the ADC value is 4095 at 1.8v, one can assume the following:
1.8 ÷ 4095 = 0.00043956
This would indicate each integer within the 12 bit range represents 0.00043956v. This allows us to create the following formula by rearranging things with algebra.
Using this formula, solving voltage for 2641, we get 1.16v, which is nearly what the multimeter was reading for that SARADC value.
Though I’m still not totally sold on the need to convert to a voltage… I think I can work with the raw SAR ADC values. I basically just need to map them to distances.