import sys import time from Adafruit import ADS1x15 adc = ADS1x15() ################ while True: v23 = adc.readADCDifferential23(4096, 128)*0.001 #voltage across resistance v01 = adc.readADCDifferential01(4096, 128)*0.001 #volage across thermistor Vt = v01 - v23 #voltage across thermistor I = v23/(10^5) #current Rt = Vt/I #resistance of thermistor print(Rt) print(I) time.sleep(1)
def signal_handler(signal, frame): print('You pressed Ctrl+C!') print(adc.getLastConversionResults() / 1000.0) adc.stopContinuousConversion() sys.exit(0) signal.signal(signal.SIGINT, signal_handler) # Print 'Press Ctrl+C to exit' ADS1015 = 0x00 # 12-bit ADC ADS1115 = 0x01 # 16-bit ADC # Initialise the ADC using the default mode (use default I2C address) # Set this to ADS1015 or ADS1115 depending on the ADC you are using! adc = ADS1x15(ic=ADS1015) # start comparator on channel 2 with a thresholdHigh=200mV and low=100mV # in traditional mode, non-latching, +/-1.024V and 250sps adc.startSingleEndedComparator(2, 200, 100, pga=1024, sps=250, activeLow=True, traditionalMode=True, latching=False, numReadings=1) while True: print(adc.getLastConversionResults() / 1000.0)