How to Build a Wi-Fi-Based Smart Light Dimmer or Fan Speed

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.

lilygo Official Store

Step 1: Compile the Firmware

Install the ESPHome add-on in Home Assistant to compile the firmware. The steps are as follows:

  1. In the Home Assistant, go to Settings > Add-Ons and click Add-On Store.
  2. Install the ESPHome add-on.
  3. Click Start and click on Open Web UI.
Open ESPHome Web UI - Smart Light Dimmer
Open ESPHome Web UI
  1. Click +New Device > Continue.
  2. Enter the device name (e.g. light-dimmer) and click Next.
  3. 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.
  4. Once done, click Skip.
  5. Find the light-dimmer device and click EDIT.
  6. Insert your Wi-Fi SSID and password:
  ssid: "MyWiFiName"
  password: "MyWIFiPassword"

Just below captive_portal:, paste the following code:

  - platform: ac_dimmer
    id: symphony_cooler
    gate_pin: D1
      number: D2
    min_power: 60%

  - platform: monochromatic
    output: symphony_cooler
    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:

Light dimmer circuit to control cooler
Smart Light Dimmer circuit to control cooler

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.

Download the wifi dimmer firmware
Download the wifi dimmer firmware

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.

keyestudio Official Store

  1. Connect the NodeMCU or D1 Mini board to your system using a micro-USB cable.
  2. Launch the ESPHome Flasher tool, click the refresh icon, and choose the “COM port”.
  3. Click “Browse” to select the firmware file, and then click “Flash ESP“.
  4. Wait for a few seconds. The firmware will be flashed, and the output or logs will start displaying in the ESPHome Flasher tool.
logs in esp home flasher tool after firmware flash
  1. 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.
light fan dimmer module online esphome home assistant
  1. Once everything is verified and working, you may disconnect the board.

Read More: How to Build a Big LED Pixel Display in 8 Steps

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.

Connect the Dimmer Module to NodeMCU or D1 Mini - Smart Light Dimmer
Connect Smart Light Dimmer
D1 Mini/NodeMCUDimmer Module
5V or VVCC

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.

connect ac socket line to the dimmer module and connect the load fan or light - Smart Light Dimmer

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.

dimmer module detected by the home assitant
dimmer module detected by the home assistant

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.

  1. 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.
  2. Choose “Area” and click “Finish“.
  3. Next, find the module in the ESPHome list under Settings > Devices & Services.
  4. Click on it (light-dimmer in our case).
  5. Click on the entity, and then click “Add to Dashboard“.
add the device to home assistant dashboard
  1. Choose a room and click NEXT > ADD TO DASHBOARD.
  2. 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).
adjust the connected load speed or brightness

You can also use the toggle control to switch the connected load on or off.

TSCINBUNY Official Store

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.

alias: Cooler
description: ''
  - platform: time
    at: '03:00:00'
condition: []
  - device_id: ffa25bd424ab6fc99a46286e8148ef5b
    domain: light
    entity_id: light.symphony_cooler
    type: brightness_decrease
  - type: turn_off
    device_id: ffa25bd424ab6fc99a46286e8148ef5b
    entity_id: light.symphony_pump
    domain: light
mode: single

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.

Oh hi there It’s nice to meet you.

Sign up to receive awesome content in your inbox, every month.

We don’t spam! Read our privacy policy for more info.

Leave a Reply

Your email address will not be published. Required fields are marked *