Amine BENDAHMANE
PhD student on AI & Robotics
To improve the user's experience
import RPi.GPIO as GPIO
import urllib2
# init
lamp = 40
GPIO.setmode(GPIO.BOARD)
GPIO.setup(lamp, GPIO.OUT)
while True:
# get the lamp status from the server
status = urllib2.urlopen("http://udevcommunity.org/
uconf2-iot-test/get_lamp_status.php").read()
# Turn ligh ON/OFF according to the server response
if (status == '1') # ON
GPIO.output(lamp, 1)
elif (status == '0') # OFF
GPIO.output(lamp, 0)
while True:
# get the lamp status from the server
status = urllib2.urlopen("http://udevcommunity.com/uconf2-iot-test
/get_lamp_status.php").read()
if (status == '1'):
# Turn light ON
GPIO.output(lamp, 1)
now = datetime.datetime.now()
# Choose a suitable delay according to the current time and old data
predicted_delay = model.predict([now.hour])
time.sleep(predicted_delay)
# Turn light OFF
GPIO.output(lamp, 0)
status = urllib2.urlopen("http://udevcommunity.com/uconf2-iot-test
/change_lamp_status.php")
elif (status == '0')
GPIO.output(lamp, 0)
https://github.com/UdevCommunityDev/uconf2-smart-lamp
github.com/amineHorseman
bendahmane.amine@gmail.com