Skip to content
This repository was archived by the owner on Sep 30, 2019. It is now read-only.

Bug fix: signed differential sample values are ignored in ADS1015 (12 bi... #115

Merged
merged 1 commit into from
Apr 1, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Adafruit_ADS1x15/Adafruit_ADS1x15.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,11 @@ def readADCDifferential(self, chP=0, chN=1, pga=6144, sps=250):
result = self.i2c.readList(self.__ADS1015_REG_POINTER_CONVERT, 2)
if (self.ic == self.__IC_ADS1015):
# Shift right 4 bits for the 12-bit ADS1015 and convert to mV
return ( ((result[0] << 8) | (result[1] & 0xFF)) >> 4 )*pga/2048.0
val = ((result[0] << 8) | (result[1] & 0xFF)) >> 4
# (Take signed values into account as well)
if val >> 11:
val = val - 0xfff
return val*pga/2048.0
else:
# Return a mV value for the ADS1115
# (Take signed values into account as well)
Expand Down