Code Monkey home page Code Monkey logo

mqtt-ledstrip's Introduction

HomeBridge-MQTT LED-Strip

forthebadge

A code for ESP8266 microcontroller to control LED Strip via homebridge-mqtt plugin for homebridge which can contron LED Strip from iOS Devices. Implemented from https://github.com/ArnieX/esp8266_dimmer_mqtt

gif https://www.youtube.com/watch?v=2EnSU2nZBkw

Functions

  • Turn on/off
  • Brightness control
  • Manual control with momentary push button.

Prerequisites

  • MQTT Broker (I use Mosquitto)
  • Homebridge-mqtt plugin installed on homebridge

Hardware

I duplicate DIY Dimmer module circuit from https://github.com/ArnieX/esp8266_dimmer_mqtt but I added momentary push button and connected it to D3 and ground (No pull-up resistor needed because I uses built-in pull-up) It control 12V LED Strip using PWM Signal that generated from ESP8266 which can control brightness of the LED Strip Please visit original project link for schematic. Note : Controlling LED from this circuit is invert, 100% PWM Duty cycle is off, 0% duty cycle is full brightness. (You can change invert setting with ISINVERT boolean parameter)

Add accessories to Homebridge-mqtt plugin

According to homebride-mqtt plugin, you can add accessories for LED-Strip to homebridge by sending message(payload) to topic below.

  • topic
homebridge/to/add
  • payload
{
    "name": "LED Strip",
    "service_name": "led_strip",
    "service": "Lightbulb",
    "Brightness": "default"
  }

Usage

  1. Install homebridge-mqtt plugin to your homebridge instance and add accessories to it using topic and payload above.
  2. Feel free to edit source file to suits your requirements and don't forget to change your mqtt server ip to match yours (Mine is 192.168.1.120)
  3. Install dependencies
  • WiFiManager
  • PubSubClient
  • ESP8266wifi
  1. Flash main.cpp to your microcontroller. You can use Aruino IDE or PlatformIO
  2. For the first time, you'll need to connect to your Wifi. First, ESP8266 will create wifi named "ESP8266 LED_Light", connect to it using password 12345678, you'll see login redirect to wifi config page(if not, enter 192.168.4.1 in browser), connect to your wifi.
  3. If everything works, your ESP8266 should followed the command from HomeBridge.

Tested on

  • NodeMCU
  • Wemos D1 Mini

Known bugs

  • Manual light control won't work with LED fade effect because it takes sometime to finished and it blocked main loop, PubSubCilent will not subscribe to topic if main loop was blocked too long.

If you got any problem or suggestions, don't hesitate to contact me, enjoy!

mqtt-ledstrip's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mqtt-ledstrip's Issues

i didnot understand

hi thank you for all this but can you help me
I have homebridge on my rasspberry pi 3 model b+ and i have installed a plugin for camera and edited a file json and it working well
now I have made this i have make the esp8266 with the sketch and i have installed mosquitto
just installed it i didnot any thing with mosquitto and i have edit json with this :
{
"platform": "mqtt",
"url":mqtt://192.168.1.118"
}
and i tested it in json web site and it true, Now
Q: do ihave to edit any thing to mosquitto ??!!
and why it dosnot work
can you expline for me please how to make it from zero if i have homebridge installed and working and i haven't mqtt server ? can you answer please thank you U R awsome man

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.