ADC V1.1 Unit

ADC V1.1 Unit is an A/D conversion module that utilizes the ADS1110 chip, a 16-bit self-calibrating analog-to-digital converter. It is designed with an I2C interface, offering convenient connectivity. The module offers conversion speeds of 8, 16, 32, and 128 samples per second (SPS), providing varying levels of accuracy at 16, 15, 14, and 12 bits of resolution respectively.

Support the following products:

ADCV11Unit

Micropython Example:

 1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
 2#
 3# SPDX-License-Identifier: MIT
 4
 5import os, sys, io
 6import M5
 7from M5 import *
 8from hardware import *
 9from unit import ADCV11Unit
10
11
12title0 = None
13label1 = None
14label0 = None
15i2c0 = None
16adc_v11_0 = None
17
18
19def setup():
20    global title0, label1, label0, i2c0, adc_v11_0
21
22    M5.begin()
23    Widgets.fillScreen(0x222222)
24    title0 = Widgets.Title(
25        "ADCV11Unit Core2 Example", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu18
26    )
27    label1 = Widgets.Label(
28        "ADC 16Bit Value:", 1, 130, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18
29    )
30    label0 = Widgets.Label("ADC Value:", 1, 91, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
31
32    i2c0 = I2C(0, scl=Pin(33), sda=Pin(32), freq=100000)
33    adc_v11_0 = ADCV11Unit(i2c0)
34    adc_v11_0.set_sample_rate(0x00)
35    adc_v11_0.set_mode(0x00)
36    adc_v11_0.start_single_conversion()
37    adc_v11_0.set_gain(0x00)
38
39
40def loop():
41    global title0, label1, label0, i2c0, adc_v11_0
42    M5.update()
43    label0.setText(str((str("ADC Value:") + str((adc_v11_0.get_voltage())))))
44    label1.setText(str((str("ADC 16Bit Value:") + str((adc_v11_0.get_adc_raw_value())))))
45
46
47if __name__ == "__main__":
48    try:
49        setup()
50        while True:
51            loop()
52    except (Exception, KeyboardInterrupt) as e:
53        try:
54            from utility import print_error_msg
55
56            print_error_msg(e)
57        except ImportError:
58            print("please update to latest firmware")

UIFLOW2 Example:

example.png

adcv11_core2_example.m5f2

class ADCV11Unit

Constructors

class ADCV11Unit(i2c)

Initialize the ADCV11Unit with an I2C or PAHUBUnit interface.

Parameters:

i2c – The I2C or PAHUBUnit instance used for communication.

UIFLOW2:

init.png

Methods

ADCV11Unit.get_voltage()

Get the measured voltage from the ADC V1.1 Unit.

Returns:

The measured voltage value, rounded to two decimal places.

UIFLOW2:

get_voltage.png

ADCV11Unit.set_gain(gain)

Set the gain configuration for the ADC.

Parameters:

gain – The gain value to configure.

UIFLOW2:

set_gain.png

ADCV11Unit.set_sample_rate(rate)

Configure the ADC’s sampling rate.

Parameters:

rate – The sample rate to set.

UIFLOW2:

set_sample_rate.png

ADCV11Unit.set_mode(mode)

Set the ADC’s operating mode.

Parameters:

mode – The mode to configure, e.g., continuous or single conversion.

UIFLOW2:

set_mode.png

ADCV11Unit.set_config()

Update the ADC configuration register with the current settings.

ADCV11Unit.get_adc_raw_value()

Read the raw ADC value.

UIFLOW2:

get_adc_raw_value.png