You can remotely regulate the fan speed, light brightness, or any other connected AC load using a Wi-Fi-based smart light dimmer or fan speed controller. Even though you may purchase smart light dimmers and fan controllers, they are sometimes pricey, require registration, and work best with an internet connection. This might be unreliable and not work if the network connection is bad or the internet isn’t accessible.
To overcome this, you may create a DIY smart dimmer switch using an ESP8266-based board that operates on the local network and does not require the internet or your personal information to work.
Things You Will Need
- An ESP8266 board, such as NodeMCU or D1 Mini.
- Home Assistant server running on Raspberry Pi
- A dimmer module, You may buy a RobotDyn dimmer module or build a DIY one that works with Arduino and ESP8266.
- DuPont wires.
- A micro-USB cable.
To create a DIY dimmer module to regulate your light or fan brightness and fan speed, after you have gathered the required components, follow these steps to connect them.
Step 1: Compile the Firmware
Install the ESPHome add-on in Home Assistant to compile the firmware. The steps are as follows:
- In the Home Assistant, go to Settings > Add-Ons and click Add-On Store.
- Install the ESPHome add-on.
- Click Start and click on Open Web UI.
- Click +New Device > Continue.
- Enter the device name (e.g. light-dimmer) and click Next.
- Choose the board from the options. If you are using a NodeMCU, select ESP8266. For D1 Mini, click Pick specific board and select Wemos D1 and Wemos D1 mini. Click Next.
- Once done, click Skip.
- Find the light-dimmer device and click EDIT.
- Insert your Wi-Fi SSID and password:
wifi: ssid: "MyWiFiName" password: "MyWIFiPassword"
Just below captive_portal:, paste the following code:
- platform: ac_dimmer
- platform: monochromatic
name: Symphony Cooler
You may alter the ID and name to match the device you wish to control. We are using this dimmer to control the speed of a Symphony cooling fan. The cooler reacts to or starts at a minimum of 60% on the slider, so the min_power: is maintained at 60%. You may delete it or change the value based on how your device responds. The code should look something like this:
After that, click Save > Install. Choose Plug into this computer and then wait for the compilation to complete. This might take up to ten minutes.
Step 2: Flash the Firmware
Download the ESPHome Flasher tool on your Windows or Mac system and follow these steps to flash the firmware we created in the previous step on our D1 Mini or NodeMCU.
- Connect the NodeMCU or D1 Mini board to your system using a micro-USB cable.
- Launch the ESPHome Flasher tool, click the refresh icon, and choose the “COM port”.
- Click “Browse” to select the firmware file, and then click “Flash ESP“.
- Wait for a few seconds. The firmware will be flashed, and the output or logs will start displaying in the ESPHome Flasher tool.
- The device will connect to the Wi-Fi network. Once this is done, go back to ESPHome in Home Assistant and check that the smart light dimmer is showing ONLINE. You may click on LOGS to check the logs and the IP address assigned to the board.
- Once everything is verified and working, you may disconnect the board.
Step 3: Connect the Dimmer Module to NodeMCU or D1 Mini
Refer to the diagram and connections table below to connect the RobotDyn dimmer module to your D1 Mini or NodeMCU board.
|D1 Mini/NodeMCU||Dimmer Module|
|5V or V||VCC|
Furthermore, connect your fan or light bulb to the load terminals and the AC input to the AC-In terminals of the dimmer module. For instance, you may connect the two wires leading to the fan or light bulb to the AC IN and then the fan or light bulb to the LOAD terminals.
Step 4: Add Controls to Home Assistant
After everything is connected, you may turn the AC power on and also switch on the D1 Mini power supply. Go to Settings > Devices and Services in your Home Assistant. On the Integrations tab, your dimmer module ought to appear by default. Click on Configure.
TIP: If the device is not found, you may return to ESPHome, click on LOGS under the Light – Dimmer, and take note of the IP address. Click Add Integrations under Settings > Devices. Choose ESPHome, paste the IP address, then click Connect.
- Click “SUBMIT“. You may need to enter the encryption key (you can find it in the light-dimmer YAML code). Paste the key and click “SUBMIT” again.
- Choose “Area” and click “Finish“.
- Next, find the module in the ESPHome list under Settings > Devices & Services.
- Click on it (light-dimmer in our case).
- Click on the entity, and then click “Add to Dashboard“.
- Choose a room and click NEXT > ADD TO DASHBOARD.
- To open the dimmer control, go to the room name slider in the Overview menu and click. You may control the linked load speed (fan or motor) or brightness with this slider (lamp).
You can also use the toggle control to switch the connected load on or off.
TIP: Make sure you don't connect any load greater than 500–1000 W (based on the TRIAC used). A DIY zero-cross dimmer module using a BTA41 may be used to control loads up to 4000W with a suitable table heat sink if you need to control larger loads.
Step 5: Set Up Automation
Setting up automation in Home Assistant is simple and may help you use your gadgets more efficiently, increasing their lifespan. Following is an example of automation you may set up where the cooling fan speed goes down from 100% (for when you go to sleep) to 80% by 3:00 AM as the temperature declines.
- platform: time
- device_id: ffa25bd424ab6fc99a46286e8148ef5b
- type: turn_off
Similarly, you may use automation to switch on the connected light(s) at 80% brightness at 7:00 PM, decrease it to 50% or lower (depending on your requirements) at midnight, and switch them off in the morning. Based on your requirements, you may set this to run on certain days or every day.
In your living room, kitchen, or bedroom, you may install them to control multiple lights and set automation to set the mood. For example, when you switch on your smart TV, the lights will control multiple lights and set automation to set the mood. For example, when you switch on your smart TV, the lights will dim automatically and the brightness will rise compared to when the TV is off. You can also detect room presence to automate the smart dimmer switch. The possibilities with Home Assistant are boundless.
To control up to four loads, you may also buy these dimmer modules in dual- or quad-channel versions. If you need to control more than four distinct loads, you may buy additional modules or construct a DIY load dimmer module and add as many channels as you want. Just one pin of the D1 Mini or NodeMCU is used for detecting zero-cross; the rest may be used to control the load.
Save Energy to Save Money
The smart dimmer device we have designed may help you save energy, reduce your electricity costs, and preserve fossil fuels. You may set up an automation in Home Assistant to automatically raise and decrease the bulb brightness (or fan speed), or switch it on and off based on the time of day or as per your preferences. It is predicted that regular lowering of your lights by 20–30% will easily reduce your electricity expenditures by 30% or more.