- Printed circuit board.
- WeMos D1 mini compatible board.
- Three TN0610N3-G.
- 5V LED strip.
- Push button
- TSOP38238
- The device is not finished yet. E.g. infrared receiver is not functioning. Also, communication protocol is subject to change.
- You have to short-circuit the diode between VBUS and +5V because it can not take enough current.
- Build with PlatformIO.
- Hold the WPS button on your router and then hold the WPS button on the device for a second. The built-in LED will light once the device is connected to Wi-Fi and IP address is obtained.
- Use Android app to discover and control the device.
Device registers itself in mDNS under a default name of ESP_XXXXXX
where XXXXXX
is the chip number:
$ dns-sd -B _smart-home._udp
Browsing for _smart-home._udp
DATE: ---Tue 16 Jan 2018---
20:11:17.202 ...STARTING...
Timestamp A/R Flags if Domain Service Type Instance Name
20:11:17.430 Add 2 7 local. _smart-home._udp. ESP_380D93
At application level the device uses JSON over UDP. Entire message must be сontained within one datagram.
The following example demonstrates how the communication is done:
In [18]: import socket
In [19]: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
In [20]: s.sendto(b'{"t": "PING"}', ('ESP_380D93.local', 5555))
Out[20]: 16
In [21]: print(s.recv(1000).decode())
The device may send a state update in response. State update contains a device identifier and fields which should be updated on a remote side:
{
"ms": 1110940,
"id": "ESP_380D93",
"t": "MULTICOLOR_LIGHTING",
"name": "ESP_380D93",
"r": 1,
"g": 1,
"b": 1,
"on": true
}
Used to discover a device. The device will send its entire current state in response.
{
"t": "PING"
}
Set a static lighting color.
{
"t": "SET_COLOR",
"r": 1.0,
"g": 0.5,
"b": 0.5
}
Turn on lighting.
{
"t": "TURN_ON"
}
Turn off lighting.
{
"t": "TURN_OFF"
}