ADC0 setup and in_voltage_raw reading

Running Ubuntu 14.04 + Ubilinux kernel. ADC is enabled in BIOS.

I have 24V connected to a voltage divider (R1=68k, R2=10k) and the output connected to ADC0/GPIO4/PIN7.

Via sysfs, I export gpio4, set direction to in, and connect the output of the voltage divider.

When I read in_voltage_raw (via sysfs /sys/bus/iio...), I get "7" or "8" no matter what, unless I ground it, which I get "0".

in_voltage_scale is 12.890625.

The voltage at the ADC0 pin is around 3.2 so I am expecting (3.2*1000) / 12.89, or 3.2/255, or something, but this thing just reads the same value regardless if its 1.2V, 2.4V at the pin or 3.2V.

How do you correctly setup this ADC0 pin? Do I need to drop the resistor values to 6.8k/1k? I don't know what the desired current rating for this pin is, and I cannot find any setup information to know if I am correctly exporting, writing direction, etc or if there are more steps I need to take to configure ADC0.

Answers

Privacy Policy