Awesome Open Source
Awesome Open Source


This is an Arduino library to control electronic dimmable ballasts for fluorescent light tubes.

It works with ESP8266, Arduino UNO, Micro, MEGA, DUE and other compatible Arduino boards.

For description of API and application examples, please refer to documentation section. You will find there also description and graphs of state machine sequence, wave-forms of control signals as well as sample user interface in openHAB.

This library is a spin-off of project esp-lamp-in-sw written in C language. Check it out if you are not convinced with using C++ for embedded systems.

Warning: Hazardous Voltage!
Hazardous Voltage Warning Building and testing hardware for this project involves working with mains power that is dangerous to your life. Do not connect this project to the mains power without proper training and certification! Please read Safety Guidelines for High Voltage and/or Line Powered Equipment

Tested with


  • Switch the lamp on / off
  • Dim to specific light intensity
  • Read back on/off status and intensity
  • Calibrate


  • ESP8266 or other Arduino compatible board
  • Relay connected to one of outputs
  • Light sensor connected to one of analog inputs
  • Touch and dim lamp connected to the relay

Application Example

DimSwitch Application Example

Sample Control Screens

This library features example sketches and openHAB code to show options to control the lamp using:

  1. Arduino IDE Serial Monitor
  2. Web browser with simple HTML code
  3. OpenHAB with MQTT binding
  4. OpenHAB with HTTP binding

The last three option are presented on screen shoots below.

Web browser with simple HTML code openHAB with MQTT binding openHAB with HTTP binding
Web browser with simple HTML code openHAB with MQTT binding openHAB with HTTP binding


Feel free to contribute to the project in any way you like!

If you find any issues with code or descriptions please report them using Issues tab above.




Invite me to freshly squeezed orange juice.


Software for this project has been prepared thanks to great work of the following teams and individuals:


GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
c-plus-plus (17,952
arduino (723
arduino-library (133
esp8266-arduino (44
openhab (22

Find Open Source By Browsing 7,000 Topics Across 59 Categories