Git Product home page Git Product logo

led-strip's Introduction

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"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.