Giter Site home page Giter Site logo

master-dimmer's Introduction

master-dimmer

The ESP8266 sends PWMs to control led strips, either using wifi or serial commands.

The code works (although no wifi, but i might have fried that because it should).

It currently only controls one led strip on the D7 pin, and applies the state, brightness, and transition time parameters specified in JSON format.

Make sure to change the default values in settings.h .

Json examples:

{ "state": "ON" }

{ "state": "ON" , "brightness": 600}

{ "state": "ON" "brightness": 600, "transition" : { "preset": "AUTO" }}

{ "state": "ON" "transition" : { "preset": "CLOCK", "TimeMs": 2000 }}

{ "state": "ON" "brightness": 600, "transition" : { "preset": "CLOCK", "TimeMs": 2000 }}

This is my first github project and more an experiment than something else, so please be patient and show forgiveness :)

The code was first based on @corbanmailloux work (https://github.com/corbanmailloux/esp-mqtt-rgb-led), but i only kept the wifi part in the end.

TODO:

  • Apply coding rules
  • Add light sensor code (sensor connected on the analog input)
  • Add ntp clock usage
  • Add pattern code
  • update JSON commands for other lamps

Warning

Do NOT try to connect your led strip on D7, you need a mosfet that can work with 3.3V level, or any kind of mosfet driver that will take that voltage level.

I will publish the schematics when i have tested it enough. For now it seems to work pretty well and does not heat, but be extra careful when assembling and trying it; remember this circuit can command tens of amps, which can easily start a fire. If your AC/DC converter is badly wired, it could also kill you, so if you do not know for sure what you are doing, please ask someone who does to do the assembling and testing for you.

Your mileage may vary, i will not take any responsibility if you end up frying something.

master-dimmer's People

Contributors

cyrille-g avatar

Stargazers

Christian W. avatar  avatar

Watchers

 avatar

master-dimmer's Issues

Add dimming vs time system

time is provided by NTP, now we need to generate scenarii based on time when a command is issued.

use these settings vars.
gConfAutoDimStartHour // "time to start dimming" hour. Dimming will start from now.
gConfHourOfInflexion // "pitch blackest time of your night" hour. The closer to this hour, the dimmer the light.
gConfAutoDimStopHour // "time to stop dimming" hour. Dimming will be back to normal at that time.
gConfMaxDimmedBrightness // this brightness is achieved at gConfHourOfInflexion
gConfMaxDimmedTransitionTime // this time will be used at gConfHourOfInflexion

Step 1: linear interpolation
Step 2: cosinus interpolation

Implement OTA updates

Now that the system is up and running, getting the chip out to flash it is a problem.

computing scenario while one is executing gives bad result

scenario generation is based on the current brightness and computes a target brightness. This causes a problem when a scenario is already executing:

either the executing scenario and everything in the scenario queue has to be trashed, and we can use current brightness,
or we need to use the last queued (or the executing scenario if there are none) target brightness as a starting point.

Wifi does not connect on startup

This may be a local router issue or a fried board as the code seems to be quite standard on that.

My wifi router gives the ESP an IP address and can ping it when the ESP starts, yet the ESP is stuck in the setup / setup_wifi() call, with wifi.status() always reporting WL_DISCONNECTED.

Webbased logging system needed

Since the esp is now away from the computer, looking at what it is currently doing or what it was doing is hard.

Add a log message queue and send it on demand on the webserver.

Add unit testing framework

The software is currently not unit tested. It will use mmurdock system, as soon as it works with esp8266

wrong json parsing on the transition item

root[transition] is supposed to return something not null when the item has subitems. It currently returns null. It could be a bug from the parser or a wrong usage, either way do not test for root[transition]

Add a "JSON command queue" to implement complex scenarii dimming

The current system works by trying to reach the target brightness in a given transition time using linear interpolation. When a JSON command is received, waiting and brightness steps for the whole process are computed.

add a command queue so locally generated commands gets pushed in and executed. This will allow complex scenarii by interpolating short linear sequences.

Serial and wifi MQTT commands should clear the queue once they have been processed, before the result of their processing is pushed in the queue.

Add remote debug capability

The system currently has a small serial debug utility, which is not enough and a problem since it needs to be connected.

Add the possibility to toggle each output independantly (with value for PWM), and to inject MQTT data.

Add support for the second hardware board

Change pinout init to reflect the new board

Pinout is as follow:
D0: led strip pwm 1
D1: enable (TC4469 "B" channel, set to low to enable TC4469 output)
D2: led strip pwm 4
D3: power supply 12V on demand
D4: not used
D5: led strip pwm 2
D6: led strip pwm 3
D7: not used
D8: not used

add NTP client code

NTP is needed in the ledstrip controler, so it will drive light depending on time

Set up the MQTT system to command 4 lights

only 1 light strip is controlled now.

Update so 4 of them can be controlled:

  • add 3 queues
  • update available topics from "light/topic/state" to:
    light/corridor/
    light/toilet/
    light/bedroom/
    light/diningroom/

Problems on tokenizing

when parsing the topic, strtok destroys the topic. Make a backup before parsing.
when parsing a topic, the system will never find the room in the list.

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.