예제 #1
0
def performSensing(interval): # interval: sec
	global sensingData, sensingTimer

	sensingTimer = threading.Timer(interval, performSensing, args=[interval])
	sensingTimer.start()
	print('Start sensing timer')

	removeEventDetect(Enter_Exit_Button_Pin)
	if DISPLAY_TYPE == 0:
		clearSensingStopNotice()
	# EC sensing
	if digital_ec_meter.detectDigitalEc():	
		ec = digital_ec_meter.readDigitalEc()
		ec = float(ec)
		ec = (float)('%.2f' %ec)	
		sensingData['ec'] = ec
	# pH sensing	
	if digital_ph_meter.detectDigitalPh():
		ph = digital_ph_meter.readDigitalPh()
		ph = float(ph)
		ph = (float)('%.2f' %ph)
		sensingData['ph'] = ph
	# Air temperature and humidity sensing
	if am2315.detectAM2315():
		(temp, humi) = am2315.readTempHumi()
		temp = (float)('%.2f' %temp)
		humi = (float)('%.2f' %humi)
		sensingData['airTemp'] = temp
		sensingData['humidity'] = humi
	# Liquid temperature sensing
	if ds18B20.detectDS18B20():
		liqTemp = ds18B20.readDS18B20()
		liqTemp = (float)('%.2f' %liqTemp)
		sensingData['liquidTemp'] = liqTemp

	print(sensingData)	
	displaySensingResult()
	if DISPLAY_TYPE == 0:
		displaySensingStopNotice()
	addEventDetect(Enter_Exit_Button_Pin)
예제 #2
0
# Test code
#======================================================================================================
if __name__ == '__main__':
    print('Digital pH Meter Test')

    if detectDigitalPh():
        getDeviceInfo()
        while (True):
            print('0:Read, 1: Set temperature 2: Calibrate pH meter')
            i = input('Input:')
            n = int(i)

            if n == 0:
                print('Press Ctrl+C to exit')
                while (True):
                    try:
                        ph = readDigitalPh()
                        print("pH: %s" % ph)
                        time.sleep(2)
                    except KeyboardInterrupt:
                        print('\n')
                        break
            elif n == 1:
                if ds18B20.detectDS18B20():
                    liqTemp = ds18B20.readDS18B20()
                else:
                    liqTemp = 25  # default temp
                setTemperature(liqTemp)
            else:
                calibrateDigitalPh()