Table of Contents

VIM1S ADC

Introduction

This document aims to guide you on how to use the ADC (Analog-to-Digital Converter) interface on the GPIO pins of the Khadas VIM1S SBC. The ADC interface allows you to convert analog signals into digital values, providing you with flexibility to connect analog sensors and devices on the VIM1S.

Hardware Information

The ADC is a 12-bit successive approximation register (SAR) A/D Converter.

Pin SIGNAL Voltage Device Node
10 ADC_CH0 0~1.8V /sys/bus/iio/devices/iio:device0/in_voltage0_raw
12 ADC_CH2 0~1.8V /sys/bus/iio/devices/iio:device0/in_voltage2_raw

Get Raw ADC Value

Replace the variable x in in_voltageXraw with the corresponding channel value

$ cat /sys/bus/iio/devices/iio:device0/in_voltageX_raw

The following uses PIN10 as an example.

$ cat /sys/bus/iio/devices/iio:device0/in_voltage0_raw     // PIN10 is connected to 1.8V                                        
4082
$ cat /sys/bus/iio/devices/iio:device0/in_voltage0_raw    // PIN10 connects to GND
5

Convert the raw ADC value to Voltage:

Voltage = (value / 4096) * 1.8V