-
Notifications
You must be signed in to change notification settings - Fork 0
/
open.py
executable file
·35 lines (29 loc) · 891 Bytes
/
open.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import RPi.GPIO as GPIO
import time
import requests
import acceleration
import threading
def open_door(current_time):
open_thread = threading.Thread(target=open_door1(current_time))
acc_thread = threading.Thread(target=acceleration.plt_data)
open_thread.start()
acc_thread.start()
open_thread.join()
acc_thread.join()
def open_door1(current_time):
time_payload = '{{"open_time": "{}"}}'.format(str(current_time))
requests.post(url='https://demo.thingsboard.io/api/v1/rL2hzO7of5BN0jk1JMuX/telemetry', data=time_payload)
GPIO.setmode(GPIO.BCM)
tilt_pin = 27
GPIO.setup(tilt_pin, GPIO.OUT)
tilt = GPIO.PWM(tilt_pin, 50)
tilt.start(0)
time.sleep(0.2)
tilt.ChangeDutyCycle(12.5)
time.sleep(2)
tilt.ChangeDutyCycle(2.5)
time.sleep(2)
tilt.ChangeDutyCycle(0)
time.sleep(0.5)
tilt.stop()
# GPIO.cleanup()