Giter Site home page Giter Site logo

fotopretty / espdesklamp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kelexel/espdesklamp

0.0 2.0 0.0 271 KB

Control an addressable LED strip with an ESP8266 via a web browser or infrared remote control, or MQTT, or homekit.

License: GNU General Public License v3.0

HTML 4.27% JavaScript 8.07% Arduino 4.30% C++ 67.02% C 16.33%

espdesklamp's Introduction

ESP Desk Lamp

An ESP8266 and FastLED desk animated lamp with support for HTTP and Homekit (via) Homebridge

About

This is a humble rewrite of [FastLED + ESP8266 Web Server] by Jason Coon, using [ESPAsyncWebServer] and lots of Class refactoring.

The original code relied on the regular WebServer package for the ESP, which as you probably know, doesn't play really well if you query it too frequently...

The idea is to use [ESPAsyncWebServer] instead, which as the name implies, runs asynchronously and, in general, works pretty well.

It also includes [ColorWavesWithPalettes] by Mark Kriegsman

And bits of codes from many sources I (try to) reference in the code.

This is my first attempt at writing C++ code, so expect to find many mistakes... Incoherences... Stupidity...

Please, feel free to fork this project, make a PR, or open a ticket in the Issues section.

11/23/2016 - Rudolph Sand (Kelexel)

Features

  • Control one (or more ?) addressable LED strip(s) with an ESP8266 compatible board.
  • Uses [FastLED]
  • Works with [homebridge-better-http-rgb], so yes, this means Siri & Homekit support.
  • HTTP UI, borrowed, and adapted from the original [FastLED + ESP8266 Web Server] project, for now. I need to add debounce to click events, possibly use a more mobile centric JS/CSS FW, and of course, websockets <o/
  • 10 animations from the [FastLED DemoReel].
  • Built with [Platformio]: use Platformio to build and flash the esp8266
  • Set Power, Brightness, Speed, Hue, Palette, Pattern via an API running on [ESPAsyncWebServer] (async! yay!)

A crash course into C++, and Classes

  • Again, again, again, this is my first attempt at some C++ code. Some methods will probably be refactored.
  • This is a training exercise for me. Go from A to B, using the most elegant (hum...) route.
  • ESPWifiDriver is a class made to handle the basic network stack: act as an access point, or act as a wifi client, advertise the services using mDNS. It might become Singleton...
  • ESPFastLedDriver is a class made to handle the FastLED settings, animations, and palettes.
  • ESPWebDriver is a class made to handle HTTP requests, and invoke the ESPFastLedDriver accordingly. It might also become a Singleton
  • ESPIRDriver is garbage for now, and will probably remain that way until I get a proper IR Receiver module

Changelog:

  • v1.3

    • Fixed Wifi AP mode
  • v1.2

    • Found the reason for random crashes, and fixed it
    • Modified the html UI to fit my needs (it will do for now)
    • Tested on ESP-01 and NodeMCU v3 boards
  • v1.1

    • Added animations support
    • Still randomly crashes
  • v1.0

    • Initial release, contains ESPWifiDriver, ESPLedDriver, but no animations

Todo:

  • A massive code cleanup. This should happen soon.
  • Make ESPPixelBusDriver Class (probably using an ESPLedDriver abstract class), and let you chose which you prefer ;)
  • MQTT support via [async-mqtt-client]
  • IR support like, the original "FastLED + ESP8266 Web Server" project
  • ESPFastLedDriver::hexToRGB and ESPFastLedDriver::RGBToHex probably need a rewrite to improve conversion speed.
  • It crashes from time to time, not sure -yet- why.. #UPDATE: It doesn't crash anymore !
  • ESPWifiDriver works well (I think ?)
  • The ESPIRDriver is roughly a class, for now.

Install

Download Platformio from [here]

Note if you are using Atom already, I recommend you get their Atom based IDE..

Just know that it will break havoc on your regular Atom, and enable a (barely functional) platformio+platformio_cli+build plugins..

For some reason launching their Atom form works better.

Download the ESP8266 platform for platformio when asked to install a board

Install the following libraries using pio lib update

  • ESPAsyncTCP
  • ESPAsyncWebServer
  • FastLED
  • IRremoteESP8266
  • esp8266_mdns

You might want to edit ESPLedDriver.h to specify which PIN is hooked to the LEDs (see DATA_PIN). You might also want to edit the number of LEDs in the same file (see NUM_LEDS)

Edit platformio.ini, select, or add, your board in there.

Than build and flash.

Flash SPIFFS to esp8266:

Open a terminal in Platformio IDE.

Type: platformio run --target buildfs to build the filesystem image.

Type platformio run --target uploadfs to upload the image to the esp8266.

Note: I currently added the ESP-01 1M/512K flags in platformio.ini, aswell as the NodeMCU 4M/1M flags. You might want to adjust to your board, see Platformio docs: [uploading-files-to-file-system-spiffs] and [platform-espressif-customflash]

homebridge-better-http-rgb setup

Install homebridge following directions found at https://github.com/nfarina/homebridge

Install homebridge-better-http-rgb using npm install -g homebridge-better-http-rgb

In your .homebridge/config.conf file, add something like this (replacing 192.168.6.243 with your device's IP address):

"accessories": [
    {
      "accessory": "HTTP-RGB",
      "name": "Single Color Light",
      "http_method": "POST",
      "switch": {
        "status": "http://192.168.6.243/power",
        "powerOn": "http://192.168.6.243/power?value=1",
        "powerOff": "http://192.168.6.243/power?value=0"
      },
      "brightness": {
        "status": "http://192.168.6.243/brightness",
        "url": "http://192.168.6.243/brightness?value=%s"
      },
      "color": {
        "status": "http://192.168.6.243/color",
        "url": "http://192.168.6.243/color?value=%s",
        "brightness": false
      }
    }
  ]

Hardware

An ESP8266 development board, such as the [Adafruit HUZZAH ESP8266 Breakout], but smaller boards like the ESP-01 are supported.

Adafruit HUZZAH ESP8266 Breakout

Addressable LED strip, such as the [Adafruit NeoPixel Ring], or any FastLED supported strip:

Adafruit NeoPixel Ring

References

espdesklamp's People

Contributors

kelexel avatar

Watchers

James Cloos avatar Voravit Euavatanakorn avatar

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.