Beaglebone Black comes with analog input pins and analog-to-digital converter (ADC) modules. The process I followed to access these pins is documented here.
Beaglebone Black, PC running on Linux system (Ubuntu ver 20.04)
Serial to USB cable, USB type A to mini B cable
To access the analog pins, the ADC device tree overlay has to be loaded.
On the board, run the following command to check the loaded device tree overlays:
sudo beagle-version | grep UBOOT
The following line indicates that the ADC overlay is loaded.
UBOOT: Loaded Overlay:[BB-ADC-00A0.kernel]
If it is not present, check the /boot/uEnv.txt, make sure device tree overlay is enabled:
enable_uboot_overlays=1
And the ADC overlay is included:
#disable_uboot_overlay_adc=1
If you want to disable the overlay afterwards, just uncomment the line:
disable_uboot_overlay_adc=1
Reboot the system after making changes:
sudo reboot
After ADC device tree overlay is loaded, the /iio:device0 directory should appear under /sys/bus/iio/devices.
Switch to the directory, it should contain in_voltage0_raw to in_voltage7_raw.
To access the value:
cat in_voltage0_raw
It can also be used in user-space applications:
file_p = fopen("/sys/bus/iio/devices/iio:device0/in_voltage0_raw", "r");
fgets(buff, LENGTH, file_p);
- https://forum.beagleboard.org/t/bullseye-cant-find-files-of-opt-scripts-tools/35076/10
- https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays
- https://groups.google.com/g/beagleboard/c/P_Y5yjJyuu4/m/G0J70kZoAwAJ
- https://askubuntu.com/questions/882433/enable-adc-input-on-beaglebone-with-4-x-kernel
- https://learn.adafruit.com/introduction-to-the-beaglebone-black-device-tree/exporting-and-unexporting-an-overlay
- https://www.linux.com/training-tutorials/how-get-analog-input-beaglebone-black/
- https://www.kernel.org/doc/html/v5.10/driver-api/iio/index.html
- https://elinux.org/EBC_Exercise_10a_Analog_In
- https://forum.beagleboard.org/t/repurposing-pins-for-gpio/37588