{"id":21848928,"url":"https://github.com/ohand/leddimmermqtt","last_synced_at":"2026-04-10T04:53:16.583Z","repository":{"id":265012368,"uuid":"870853382","full_name":"ohAnd/LEDdimmerMQTT","owner":"ohAnd","description":"easy integration of a PWM driven LED driver for ESP8266/ ESP32/ESP32-S2 with mqtt connection and auto MQTT autodiscovery config","archived":false,"fork":false,"pushed_at":"2024-11-27T06:20:13.000Z","size":2092,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-26T12:41:30.621Z","etag":null,"topics":["arduino","esp32","esp32-s2","esp8266","led-driver","pwm","webupdate"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ohAnd.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-10T19:34:30.000Z","updated_at":"2024-11-27T06:17:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"e46ded88-d694-46ff-a328-293ce32fa34d","html_url":"https://github.com/ohAnd/LEDdimmerMQTT","commit_stats":null,"previous_names":["ohand/leddimmermqtt"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohAnd%2FLEDdimmerMQTT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohAnd%2FLEDdimmerMQTT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohAnd%2FLEDdimmerMQTT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohAnd%2FLEDdimmerMQTT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ohAnd","download_url":"https://codeload.github.com/ohAnd/LEDdimmerMQTT/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244842441,"owners_count":20519614,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","esp32","esp32-s2","esp8266","led-driver","pwm","webupdate"],"created_at":"2024-11-28T00:09:28.471Z","updated_at":"2025-12-30T20:51:55.387Z","avatar_url":"https://github.com/ohAnd.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LEDdimmerMQTT\n\n## Contents\n- [LEDdimmerMQTT](#leddimmermqtt)\n  - [Contents](#contents)\n  - [idea](#idea)\n  - [features](#features)\n  - [api](#api)\n    - [data - http://\\\u003cip\\_to\\_your\\_device\\\u003e/api/data.json](#data---httpip_to_your_deviceapidatajson)\n    - [info - http://\\\u003cip\\_to\\_your\\_device\\\u003e/api/info.json](#info---httpip_to_your_deviceapiinfojson)\n  - [MQTT integration/ configuration](#mqtt-integration-configuration)\n  - [installation](#installation)\n    - [hardware](#hardware)\n    - [first installation to the ESP device](#first-installation-to-the-esp-device)\n      - [example for ESP8266](#example-for-esp8266)\n      - [example for ESP32](#example-for-esp32)\n      - [first setup with access point](#first-setup-with-access-point)\n      - [return to factory mode](#return-to-factory-mode)\n    - [update](#update)\n  - [releases](#releases)\n    - [main](#main)\n    - [snapshot](#snapshot)\n  - [troubleshooting](#troubleshooting)\n  - [build environment](#build-environment)\n    - [platformio](#platformio)\n    - [hints for workflow](#hints-for-workflow)\n\n\n## idea\n\n- Easy integration of a PWM driven LED driver\n- after main setup it should be seamlessly integratable in existing smart home system e.g. HomeAssistant or openHAB via MQTT Autodiscovery/ AutoConfig\n- Extendable to more direct LED controls (currently limited to 5 pins/ PWM controlable driver)\n\n## features\n\n- LED settings\n  - steps = resolution of transitions at changing to a new target dimming value\n  - stepDelay = time in milli seconds to wait per stepsize\n  - used PIN (not usable PINs: ledPWMpin == 255 || ledPWMpin \u003c= 1 || ledPWMpin == 3 || (ledPWMpin \u003e= 6 \u0026\u0026 ledPWMpin \u003c= 11) || ledPWMpin == 24 || ledPWMpin \u003e= 34)\n- serving the read data per /api/data.json\n- serving own access point in factory mode for first setup\n- web application will be directly served by the system\n- settings of needed user data over the web app (stored in a json-file in local flash file system - extensions of user setup will not lead to breakable changes)\n  - select found local wifi and enter/ save the needed wifi password\n  - configurable data for MQTT settings incl. HomeAssistant AutoDiscovery\n  - advanced web config for all config parameter (http://IP_domain/config) - expert mode\n- manual OTA/ web Update via web ui (hint: only stable if the wifi connection is above ~ 50%)\n\n## api\n\n### data - http://\u003cip_to_your_device\u003e/api/data.json\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand to see json example\u003c/summary\u003e\n\n```json \n{\n  \"ntpStamp\": 1729431663,\n  \"starttime\": 1729431519,\n  \"leds\": [\n    {\n      \"mainSwitch\": 0,\n      \"dimValue\": 0,\n      \"dimValueTarget\": 0,\n      \"dimValueRaw\": 0,\n      \"dimValueStep\": 1,\n      \"dimValueStepDelay\": 5\n    },\n    {\n      \"mainSwitch\": 0,\n      \"dimValue\": 0,\n      \"dimValueTarget\": 0,\n      \"dimValueRaw\": 0,\n      \"dimValueStep\": 1,\n      \"dimValueStepDelay\": 4\n    }\n  ]\n}\n```\n\u003c/details\u003e\n\n### info - http://\u003cip_to_your_device\u003e/api/info.json\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand to see json example\u003c/summary\u003e\n\n```json \n{\n  \"chipid\": 12345678,\n  \"chipType\": \"ESP32\",\n  \"host\": \"LEDdimmerMQTT_12345678\",\n  \"initMode\": 0,\n  \"firmware\": {\n    \"version\": \"0.0.2\",\n    \"versiondate\": \"08.10.2024 - 09:19:48\",\n    \"versionServer\": \"checking\",\n    \"versiondateServer\": \"...\",\n    \"versionServerRelease\": \"checking\",\n    \"versiondateServerRelease\": \"...\",\n    \"selectedUpdateChannel\": \"0\",\n    \"updateAvailable\": 0\n  },\n \"ledSettings\": [\n    {\n      \"ledPWMpin\": 4,\n      \"dimValueStep\": 1,\n      \"dimValueStepDelay\": 5\n    },\n    {\n      \"ledPWMpin\": 5,\n      \"dimValueStep\": 1,\n      \"dimValueStepDelay\": 4\n    }\n  ],\n  \"mqttConnection\": {\n    \"mqttActive\": 1,\n    \"mqttIp\": \"homeassistant\",\n    \"mqttPort\": 1883,\n    \"mqttUseTLS\": 0,\n    \"mqttUser\": \"user\",\n    \"mqttPass\": \"pass\",\n    \"mqttMainTopic\": \"LEDdimmerMQTT_12345678\",\n    \"mqttHAautoDiscoveryON\": 1\n  },\n  \"wifiConnection\": {\n    \"wifiSsid\": \"privateWifi\",\n    \"wifiPassword\": \"privateWifiPass\",\n    \"rssiGW\": 80,\n    \"wifiScanIsRunning\": 0,\n    \"networkCount\": 0,\n    \"foundNetworks\": [\n      {\n        \"name\": \"Name1 Wlan\",\n        \"wifi\": 62,\n        \"rssi\": -69,\n        \"chan\": 1\n      },\n      {\n        \"name\": \"name2-wifi\",\n        \"wifi\": 48,\n        \"rssi\": -76,\n        \"chan\": 3\n      }\n    ]\n  }\n}\n```\n\u003c/details\u003e\n\n## MQTT integration/ configuration\n\n- set the IP to your MQTT broker\n- set the MQTT user and MQTT password\n- set the main topic e.g. 'LEDdimmerMQTT_12345678' for the pubished data (default: is `LEDdimmerMQTT_\u003cESP chip id\u003e` and has to be unique in your environment)\n\n- Home Assistant Auto Discovery\n  - you can set HomeAssistant Auto Discovery, if you want to auto configure the LEDdimmerMQTT for your HA installation \n  - switch to ON means - with every restart/ reconnection of the LEDdimmerMQTT the so called config messages will be published for HA and HA will configure (or update) all the given entities of LEDdimmerMQTT incl. the set value for PowerLimit\n  - switch to OFF means - all the config messages will be deleted and therefore the LEDdimmerMQTT will be removed from HA (base publishing of data will be remain the same, if MQTT is activated)\n  - detail note:\n    - if you use the default main topic e.g. `LEDdimmerMQTT_\u003cESP chip id\u003e` then config and state topic will be placed at the same standard HA auto discovery path, e.g.\n      - config: `homeassistant/light/LEDdimmerMQTT_12345678/led0/config`\n      - state: `homeassistant/light/LEDdimmerMQTT_12345678/led0/dimmer/state`\n      - set: `homeassistant/light/LEDdimmerMQTT_12345678/led0/dimmer/set`\n\n## installation\n### hardware\n- ESP8266/ ESP32/ ESP32-S2 (LOLIN_S2_MINI) based boards\n- GPIO 4 for PWM out to PWM driven DC regulator (e.g. https://www.amazon.de/dp/B0CBK7D1GD?ref=ppx_yo2ov_dt_b_fed_asin_title)\n\n### first installation to the ESP device\n#### example for ESP8266\n1. download the preferred release as binary (see below)\n2. [only once] flash the esp8266 board with the [esp download tool](https://www.espressif.com/en/support/download/other-tools)\n   1. choose bin file at address 0x0\n   2. SPI speed 40 MHz\n   3. SPI Mode QIO\n   4. select your COM port and baudrate = 921600\n   5. press start ;-)\n3. all further updates are done by [OTA](###-regarding-base-framework) or [webupdate](###-update)\n\nYou can also use the esptool.py as described shortly here https://github.com/ohAnd/dtuGateway/discussions/46#discussion-7106516 by @netzbasteln\n\n#### example for ESP32\nsee also https://github.com/ohAnd/dtuGateway/discussions/35#discussioncomment-10519821\n1. download the preferred release as binary (see below)\n2. [only once] flash the esp32 board with the [esp download tool](https://www.espressif.com/en/support/download/other-tools)\n   1. get the needed bin files (see at doc/esp32_factoryFlash)\n      1. [bootloader.bin](doc/esp32_factoryFlash/bootloader.bin) or pick ESP32_S2 files\n      2. [partions.bin](doc/esp32_factoryFlash/partitions.bin)  or pick ESP32_S2 files\n      3. [boot_app0.bin](doc/esp32_factoryFlash/boot_app0.bin) or pick ESP32_S2 files\n      4. current [release] or [snapshot]\n   2. select inside the flash tool the files 1.1 - 1.4 and set the following start adresses\n      1. bootloader.bin =\u003e 0x1000\n      2. partionions.bin =\u003e 0x8000\n      3. boot_app0.bin =\u003e 0xE000\n      4. firmware =\u003e 0x10000\n   3. SPI speed 40 MHz\n   5. SPI Mode QIO\n   6. select your COM port and baudrate = 921600\n   8. press start ;-)\n3. all further updates are done by [OTA](###-regarding-base-framework) or [webupdate](###-update)\n\n#### first setup with access point\n\n1. connect with the AP LEDdimmerMQTT_\u003cchipID\u003e (on smartphone sometimes you have to accept the connection explicitly with the knowledge there is no internet connectivity)\n2. open the website http://192.168.4.1 for the first configuration\n3. choose your wifi\n4. type in the wifi password - save\n5. in webfrontend setting your MQTT data -\u003e set the IP and port (e.g. 192.178.0.42:1883) of your mqtt broker and the user and passwort that your have for this instance\n\n#### return to factory mode\n1. connect your ESP with serial (115200 baud) in a COM terminal\n2. check if you receive some debug data from the device\n3. type in `resetToFactory 1`\n4. response of the device will be `reinitialize UserConfig data and reboot ...`\n5. after reboot the device starting again in AP mode for first setup\n\n### update\nVia the web ui you can select the firmware file and start the update process. Please use the right firmware file according to your processor ESP8266 / ESP32 / ESP32-S2.\n\n## releases\n### main\nlatest release - changes will documented by commit messages\nhttps://github.com/ohAnd/LEDdimmerMQTT/releases/latest\n\n(to be fair, the amount of downloads is the count of requests from the client to check for new firmware for the OTA update)\n\n![GitHub Downloads (all assets, latest release)](https://img.shields.io/github/downloads/ohand/LEDdimmerMQTT/latest/total)\n![GitHub (Pre-)Release Date](https://img.shields.io/github/release-date/ohand/LEDdimmerMQTT)\n![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/ohand/LEDdimmerMQTT/main_build.yml)\n\n### snapshot\nsnapshot with latest build\nhttps://github.com/ohAnd/LEDdimmerMQTT/releases/tag/snapshot\n\n![GitHub Downloads (all assets, specific tag)](https://img.shields.io/github/downloads/ohand/LEDdimmerMQTT/snapshot/total)\n![GitHub (Pre-)Release Date](https://img.shields.io/github/release-date-pre/ohand/LEDdimmerMQTT)\n![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/ohand/LEDdimmerMQTT/dev_build.yml)\n\n## troubleshooting\n\n- if the config file is corrupted due to whatever reason with unexpected behavior - connect with serial terminal and type in the command `resetToFactory 1` - the config file be rewritten with the default values\n- if in the first startup mode a wrong ssid/ password was entered, then also `resetToFactory 1` \n\n## build environment\n\nfully covered with github actions\n\nbuilding on push to develop and serving as a snapshot release with direct connection to the device - available updates will be locally checked and offered to the user for installation \n\nhint: \n\u003e For automatic versioning there is a file called ../include/buildnumber.txt expected. With the content \"localDev\" or versionnumber e.g. \"1.0.0\" in first line. (File is blocked by .gitignore for GitHub actions to run.)\n\n\n\n### platformio\n- https://docs.platformio.org/en/latest/core/installation/methods/installer-script.html#local-download-macos-linux-windows\n\n### hints for workflow\n- creating dev release (https://blog.derlin.ch/how-to-create-nightly-releases-with-github-actions)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohand%2Fleddimmermqtt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fohand%2Fleddimmermqtt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohand%2Fleddimmermqtt/lists"}