Skip to content
Permalink
484d4cde0e
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
22 lines (17 sloc) 745 Bytes
#!/usr/bin/env python3
# This script reads an analog voltage on channel 0 on an ADS1115 and outputs
# an integer value that corresponds to this voltage.
# https://cdn-shop.adafruit.com/datasheets/ads1115.pdf
# $ sudo apt-get install python3 python3-pip python-dev python-smbus
# $ sudo pip3 install smbus Adafruit-Blinka adafruit-circuitpython-ads1x15
import time
import board
import busio
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn
i2c = busio.I2C(board.SCL, board.SDA) # Create the I2C bus
ads = ADS.ADS1115(i2c) # Create the ADC object using the I2C bus
chan = AnalogIn(ads, ADS.P0) # Create single-ended input on channel 0
while True:
print("{:>5.3f}".format(chan.voltage))
time.sleep(0.1)