Skip to content
This repository has been archived by the owner on Jul 27, 2018. It is now read-only.

eigenein/led-strip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESP8266-based LED strip controller

Assembled device

Device picture

Parts

Notes

  • 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.

Getting started

  • 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 discovery

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

Communication

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
}

Ping

Used to discover a device. The device will send its entire current state in response.

{
    "t": "PING"
}

SET_COLOR

Set a static lighting color.

{
    "t": "SET_COLOR",
    "r": 1.0,
    "g": 0.5,
    "b": 0.5
}

TURN_ON

Turn on lighting.

{
    "t": "TURN_ON"
}

TURN_OFF

Turn off lighting.

{
    "t": "TURN_OFF"
}