-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboard_smart_RF433Mhz.py
57 lines (48 loc) · 1.09 KB
/
board_smart_RF433Mhz.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#####################
try:
import cmd
machine.reset()
except:
pass
#####################
# mac Address: 5c:cf:7f:81:0f:b5
from webduino import *
from machine import Pin,I2C
from utime import ticks_us, ticks_diff
from array import array
from RFBtn import RFBtn
import time,os
gnd = Pin(16,Pin.OUT)
gnd.on()
def beep(t=1):
beep = Pin(14,Pin.OUT)
for i in range(t):
beep.off()
time.sleep(0.015)
beep.on()
time.sleep(0.005)
beep(2)
# wemos
wemos = Board('RF433Mhz')
wemos.connect("KingKit_2.4G","webduino")
# btn
btn1 = "5556565a5556"
btn2 = "5566959a5556"
btn3 = "5559565a5556"
btn4 = "555aa5aa5556"
btn315_blue = "659aaaaa5959"
btn315_red = "6559a6996959"
btn315_yellow = "556a6555a959"
def runCode(code):
if code == btn1 or code == btn2 or code == btn3 or code == btn4:
beep(1)
publishTopic = "wa5499/btn433"
print("start...",wemos.deviceId)
wemos.onMsg(publishTopic,runCode)
pin5 = Pin(5,Pin.IN)
beep(1)
while True:
data = RFBtn.listener(pin5,wemos.check)
print(data)
if(len(data)==12):
wemos.mqtt.pub(publishTopic,data)