Domoticz Controlled RGB LED strip

Development of a Domoticz controlled ESP8266 RGB LED Strip Dimmer

Introduction

Main purpose of this project is to create a WiFi controlled RGB lamp and integrate it into the Domoticz ecosystem. This is a learning oriented project for myself not a production-ready one.

Secondary goal is to use free and/or Open Source Software whenever is possible.

The source code and documentation is available in my Github repository here:

System overview

Client circuit

Captive portal

Why Domoticz

  • Good documentation with lot of examples
  • Tons of ready-made sensors and actuators
  • Active development (yearly stable major versions)
  • Easy setup (unpack, setup and run as a service)
  • MQTT capable => custom sensors with small effort (see the running External Pi Temperature script below)

Example custom script (cputemp2domoticz)

Send the DS3121's temparature sensor's value to Domoticz in every REFRESH=5 secs using basic Unix commands. The sensor index in Domoticz is 1 in this example.

#!/bin/bash

export MQTTHOST=localhost; 
export TEMP_IDX=1; 
export REFRESH=5

while true; do
  echo '{"idx": '${TEMP_IDX}',"nvalue": 0.00, "svalue":"'$(sensors -u| grep temp1_input| \
  cut -d\  -f4)'"}' | mosquitto_pub -h $MQTTHOST -u xxxx -P yyyyy -t 'domoticz/in' -l  
  sleep ${REFRESH}
done

Run it as a "soft-daemon"

#!/bin/bash
export SCREENNAME="scriptedDomoticz"

for scriptname in *2domoticz; do 
    echo "Starting ${scriptname} in a detached screen..."
    screen -dmS ${SCREENNAME} ./${scriptname}
done    

Used Tools and external libraries

  • Json Assistant: https://arduinojson.org/v5/assistant
  • Mosquitto MQTT server and CLI tools
  • Flooplanner: https://floorplanner.com
  • Arduino IDE v1.8.10 with 3rd-party ESP8266 devtools
  • Marp - Markdown based presentation generator with built-in server and file watcher
  • Drawing.io for diagram creation
  • Fritzing for BreadBoard sketching
  • Eagle for schematic and PCB design (coming soon)

Problems and solutions

  • Chrome has JS cache -> IP has been changed but there was no HTTP error message just a Domoticz-like page with "Offline" message comes from the cache -> solution: check the IP address after a router reboot :)
  • FPSTR is not working properly with ESP8266 2.4.1-> use F("") (inline PROGMEM strings ) instead
  • Domoticz's Dimmer MQTT packet is bigger than 400 bytes, PubSubClient has a 128 bytes buffer -> Increase buffer size to 512 bytes in PubSubClient.h
  • PWM resolution is too small. Only 10 level per color component is possible which means 10x10x10=1000 different colors. -> Possible solution: usage of ESP8266 SDK without Arduino. Not tested, needs complete rewrite and a different toolchain usage.

Improvement ideas

  • Use MQTT-SN instead of TCP based MQTT
    • smaller energy footprint,
    • longer battery operation time for future projects,
    • exmaple usages with pros: ToF sensors, environmental sensors, PIR motion detectors
  • Add a backup AP possibility
  • Add MQTT bridging possibility (for larger environments and distant sensors)
  • GeoFencing with OwnTracks and OwnTracks recorder and a VPS

Future improvement ideas

  • Integrate more sensors (light levels, door contacts, external temperature sensors)
  • Simulate the dawn in my room :)
  • Custom dashboard with Node-Red
  • Try MyDomoticz.com the publicly available Domoticz Hub for integrate private Domoticz instances into a publicly available Cloud based solution
  • Use certificate based MQTT connection
  • MAC address filtering for the RPi AP
  • HTTPS connection for the Domoticz instance (Let's encrypt or self-signed)
  • Use Realtek's PADI DevKit instead of ESP8266 due to not fully open source of ESP8266

Additional information sources

Domoticz HTTP GET format examples

  • Domoticz format for a Temperature+Humidity+HumidityStatus sensor (SparkFun_Si7021_Breakout): /json.htm?type=command&param=udevice&idx=IDX&nvalue=0&svalue=TEMP;HUM;HUM_STAT

Other custom firmware and solutions

Interesting projects

Comments