def includeParticleSensor(): spi=spidev.SpiDev() spi.open(0,0) spi.mode=1 spi.max_speed_hz=500000 alphasense=OPCN2(spi) alphasense.on()
def setUp(self): self.spi = spidev.SpiDev() self.spi.open(0, 0) self.spi.mode = 1 self.spi.max_speed_hz = 500000 self.alpha = OPCN2(self.spi)
# Read channel 0 in single-ended mode using the settings above # To read channel 3 in single-ended mode, +/- 1.024V, 860 sps use: # volts = adc.readADCSingleEnded(3, 1024, 860) #INSTANTIATING EVERYTHING obj = HTU21D() gpsp = GpsPoller() gpsp.start() spi=spidev.SpiDev() spi.open(0,0) spi.mode=1 spi.max_speed_hz=500000 alphasense= OPCN2(spi) alphasense.on() Time = str(gpsd.utc) Time1=None sleep (0.1) def getReadings(): numberOfSensors=4 volts=[] for i in range(2*numberOfSensors): if i<=3: volts.append(adc.readADCSingleEnded(i, gains[0], sps) / 1000) #print (volts[i]) else: volts.append(adc2.readADCSingleEnded(i-4, gains[0], sps) / 1000) #print (volts[i])
# for debugging #log.addHandler(logging.StreamHandler()) # for urbanova rundir = '/run/aqnet/opcn2/' try: os.makedirs(rundir) except OSError: if not osp.isdir(rundir): raise spi = spidev.SpiDev() spi.open(0, 0) spi.mode = 1 spi.max_speed_hz = 500000 opc = OPCN2(spi) opc.on() import atexit @atexit.register def cleanup(): opc.off() while True: try: data = opc.histogram() now = time.time()