# Setup to gracefully catch ^C and exit def signal_handler(signal, frame): df.close() print >> sys.stderr, rawReadings print >> sys.stderr, '\n', average print >> sys.stderr,'\nExiting' sys.exit(0) signal.signal(signal.SIGINT, signal_handler) sys.path.append('../ABElectronics_Python_Libraries/ABElectronics_ADCPi') from ABElectronics_ADCPi import ADCPi # Initialise the ADC device using the default addresses and sample rate, change this value if you have changed the address selection jumpers # Sample rate can be 12,14, 16 or 18 adc = ADCPi(0x68, 0x69, 18) class RepeatedTimer(object): def __init__(self, interval, function, *args, **kwargs): self._timer = None self.interval = interval self.function = function self.args = args self.kwargs = kwargs self.is_running = False self.start() def _run(self): self.is_running = False self.start() self.function(*self.args, **self.kwargs)
#!/usr/bin/python from ABElectronics_ADCPi import ADCPi import time import datetime import os # Sample rate can be 12,14, 16 or 18 adc = ADCPi(0x6a, 0x6b, 12) x1 = 1 x2 = 1 x3 = 1 x4 = 1 x5 = 1 x6 = 1 x7 = 1 x8 = 1 #x1=x2=x3=1 y = 1.00 z = 1.00 rate = 0.01 # seconds samples = 1 # samples #print ("debug 2") for i in range(0, 1):
from ABElectronics_ADCPi import ADCPi import time import os # ================================================ # ABElectronics ADC Pi 8-Channel ADC demo # Version 1.0 Created 09/05/2014 # # Requires python smbus to be installed # run with: python demo-readvoltage.py # ================================================ # Initialise the ADC device using the default addresses and sample rate, change this value if you have changed the address selection jumpers # Sample rate can be 12,14, 16 or 18 adc = ADCPi(0x68, 0x69, 12) while (True): # clear the console os.system('clear') # read from adc channels and print to screen print ("Channel 1: %02f" % adc.readVoltage(1)) print ("Channel 2: %02f" % adc.readVoltage(2)) print ("Channel 3: %02f" % adc.readVoltage(3)) print ("Channel 4: %02f" % adc.readVoltage(4)) print ("Channel 5: %02f" % adc.readVoltage(5)) print ("Channel 6: %02f" % adc.readVoltage(6)) print ("Channel 7: %02f" % adc.readVoltage(7)) print ("Channel 8: %02f" % adc.readVoltage(8))
from ABElectronics_ADCPi import ADCPi import datetime import time # ================================================ # ABElectronics ADC Pi 8-Channel ADC data-logger demo # Version 1.0 Created 11/05/2014 # # Requires python smbus to be installed # run with: python demo-readvoltage.py # ================================================ # Initialise the ADC device using the default addresses and sample rate, change this value if you have changed the address selection jumpers # Sample rate can be 12,14, 16 or 18 adc = ADCPi(0x68, 0x69, 18) def writetofile(texttowrtite): f = open('adclog.txt', 'a') f.write(str(datetime.datetime.now()) + " " + texttowrtite) f.closed while (True): # read from adc channels and write to the log file writetofile ("Channel 1: %02f\n" % adc.readVoltage(1)) writetofile ("Channel 2: %02f\n" % adc.readVoltage(2)) writetofile ("Channel 3: %02f\n" % adc.readVoltage(3)) writetofile ("Channel 4: %02f\n" % adc.readVoltage(4)) writetofile ("Channel 5: %02f\n" % adc.readVoltage(5))
#!/usr/bin/python from ABElectronics_ADCPi import ADCPi import time import datetime import os # Sample rate can be 12,14, 16 or 18 adc = ADCPi(0x6a, 0x6b, 12) x1 = 769.0 / 12.91 x2 = 773.0 / 12.91 x3 = 768.0 / 12.91 x4 = 767.0 / 12.86 #x1=x2=x3=1 y = 1.00 z = 1.00 rate = 0.01 # seconds samples = 1 # samples #print ("debug 2") for i in range(0, 1): t = datetime.datetime.now().strftime('%s') v1 = 0 v2 = 0
#!/usr/bin/python from ABElectronics_ADCPi import ADCPi import time import datetime import os # Sample rate can be 12,14, 16 or 18 adc = ADCPi(0x68, 0x69, 12) x1 = 769.0 / 12.91 x2 = 773.0 / 12.91 x3 = 768.0 / 12.91 x4 = 767.0 / 12.86 #x1=x2=x3=1 y = 1.00 z = 1.00 rate = 0.01 # seconds samples = 1 # samples #print ("debug 2") for i in range(0, 1): t = datetime.datetime.now().strftime('%s') v1 = 0