How to get ADC value in python from 6ul-start kit

Hi guys,

Deeply thanks for your support always.
I am trying to set my 6ul-start board for my data logger project.
And done almost all functions for it including uarts, sd, USB etc.
however, I am confused getting ADC data from adc port in python.
I can only get the data from linux file which has one line datum: /sys/bus/iio/devices/iio:device1/in_voltage4_raw

Is this the only way to get ADC data?
Can’t access it directly from python like GPIO?

Best regards,

we have C library and APIs but not python ones. The easiest way to access ADC values in Python is to read from that device like from a file:

import time

# Define the device directory
DEVICE_DIR = "/sys/bus/iio/devices/iio:device0"

# Define the function to read the value from the device
def read_value(file_path):
    with open(file_path, "r") as file:
        return file.read()

# Read the value from the device
value = read_value(f"{DEVICE_DIR}/in_voltage0_raw")

# Print the value
print(value)

or just use system command:

import os

# Execute the ls command
output = os.system('cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw')

# Print the output of the command
print(output)