Beispiel #1
0
def pump_override(identifier,gpio_pins):
	water_levelRead_new.readLevel()
	if globalVals.waterLevel != -1 and globalVals.waterLevel < globalVals.waterLevelThreshold:
		GPIO.output(gpio_pins[0], GPIO.LOW)
		GPIO.output(gpio_pins[1], GPIO.HIGH)
		GPIO.output(gpio_pins[2], GPIO.HIGH)
		GPIO.output(gpio_pins[3], GPIO.HIGH)

		if not(globalVals.isSent):
			message = client.messages.create(to="+16177635155", from_="+18572541957", body="pGnome Alert: please refill the water in the rain barrel.")
			globalVals.isSent = True

		globalVals.pumpOn = False
		print "turning pump off"
		print "pump_override"
Beispiel #2
0
def data_water_collect(identifier, txt=''):
	unlock_db("myDBfile.sqlite3")
	#connect to the local database#
	myDatabase = sqlite3.connect("myDBfile.sqlite3", check_same_thread=False)
	cur = myDatabase.cursor()
	water = water_levelRead_new.readLevel()
	print "current water level reading: ", water

	if water != -1:
		while True:
			try:
				if row_water_count(cur)[0] == 0:
					insert_water_db(cur, water)
				else:
					update_water_db(cur, water)
				break
			except Exception:
				unlock_db("myDBfile.sqlite3")
			
		try:
			myDatabase.commit()
			myDatabase.close()
		except Exception:
			myDatabase.rollback()

	print "data_water_collect"