Simple test¶
Ensure your device works with this simple test.
1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4import time
5import board
6import busio
7import adafruit_ads1x15.ads1015 as ADS
8from adafruit_ads1x15.analog_in import AnalogIn
9
10# Create the I2C bus
11i2c = busio.I2C(board.SCL, board.SDA)
12
13# Create the ADC object using the I2C bus
14ads = ADS.ADS1015(i2c)
15
16# Create single-ended input on channel 0
17chan = AnalogIn(ads, ADS.P0)
18
19# Create differential input between channel 0 and 1
20# chan = AnalogIn(ads, ADS.P0, ADS.P1)
21
22print("{:>5}\t{:>5}".format("raw", "v"))
23
24while True:
25 print("{:>5}\t{:>5.3f}".format(chan.value, chan.voltage))
26 time.sleep(0.5)
1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4import time
5import board
6import busio
7import adafruit_ads1x15.ads1115 as ADS
8from adafruit_ads1x15.analog_in import AnalogIn
9
10# Create the I2C bus
11i2c = busio.I2C(board.SCL, board.SDA)
12
13# Create the ADC object using the I2C bus
14ads = ADS.ADS1115(i2c)
15# you can specify an I2C adress instead of the default 0x48
16# ads = ADS.ADS1115(i2c, address=0x49)
17
18# Create single-ended input on channel 0
19chan = AnalogIn(ads, ADS.P0)
20
21# Create differential input between channel 0 and 1
22# chan = AnalogIn(ads, ADS.P0, ADS.P1)
23
24print("{:>5}\t{:>5}".format("raw", "v"))
25
26while True:
27 print("{:>5}\t{:>5.3f}".format(chan.value, chan.voltage))
28 time.sleep(0.5)