Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 35 lines (26 sloc) 995 Bytes
# Distributed with a free-will license.
# Use it any way you want, profit or free, provided it fits in the licenses of its associated works.
# ADS1115
# This code is designed to work with the ADS1115_I2CADC I2C Mini Module available from
import smbus
import time
# Get I2C bus
bus = smbus.SMBus(1)
# ADS1115 address, 0x48(72)
# Select configuration register, 0x01(01)
# 0x8483(33923) AINP = AIN0 and AINN = AIN1, +/- 2.048V
# Continuous conversion mode, 128SPS
data = [0x84,0x83]
bus.write_i2c_block_data(0x48, 0x01, data)
# ADS1115 address, 0x48(72)
# Read data back from 0x00(00), 2 bytes
# raw_adc MSB, raw_adc LSB
data = bus.read_i2c_block_data(0x48, 0x00, 2)
# Convert the data
raw_adc = data[0] * 256 + data[1]
if raw_adc > 32767:
raw_adc -= 65535
# Output data to screen
print "Digital Value of Analog Input : %d" %raw_adc
You can’t perform that action at this time.