Controlling the light brightness or fan speed is often done using a regulator found in switchboards. But can you control them using a smartphone? Yes. Although it’s possible, there are hardly any IoT devices capable of performing such tasks, let alone multiple IoT projects to choose from.
So today, you will learn to make a wireless IoT device that can control the speed of a fan motor and adjust the brightness of light via a useful IoT project. This feature can also be used in factories for wirelessly controlling AC appliances including elevators and conveyor belts.
Let’s start our project by shopping for the following components.
![](https://www.electronicsforu.com/wp-contents/uploads/2022/03/iot-aclighrdimmee.png)
![](https://www.electronicsforu.com/wp-contents/uploads/2022/03/IMG_13642.jpg)
Bill Of Material
Coding
You will need an Arduino IDE for programming the ESP 12F. By default, Arduino IDE does not have a set-up for ESP board. Therefore, you will need to do it manually. You can check this article on how to manually set up an ESP 12F board to Arduino IDE.Now, create a UI dashboard for controlling the motor speed or light brightness over the WiFi network. For this, use the ESP dashboard library to create a dashboard with a slider button ranging from minimum to maximum.
In the code, include the library for ESP WiFi and dashboard. Then set the SSID and password of your WiFi network. After this, create a setup function where you can start the serial port and set the baud rate. This is followed by initialising the pin mode for the LED using which you can control the light brightness (that is optically coupled with the AC circuit).
Next, create a loop function. Check the value of the slider button and assign the value of slider button to the PWM output of the LED pin so that the LED brightness changes according to the slider present in the UI (that was created using the ESP library).
![](https://www.electronicsforu.com/wp-contents/uploads/2022/03/code2-1.png)
Connection
Connect the components as shown in the circuit diagram. Couple the two electrically isolated circuits, that is, AC triac circuit and ESP lights. By coupling them using LDR and LED, whenever the LED brightness will change, the LDR resistance will fall and change the characteristics of AC appliances such as fan and light bulbs. All this will happen wirelessly over a WiFi network.
![](https://www.electronicsforu.com/wp-contents/uploads/2022/03/circuit.png)
Testing
Power the ESP device with a 3.3V battery adaptor. Then power the AC circuit and connect the smartphone to the WiFi network. Then scan and search its IP address in the browser. You will get the UI with a slider button. Move the slider from minimum to maximum that will change the fan speed and brightness of the lightbulb.
![](https://www.electronicsforu.com/wp-contents/uploads/2022/03/Screenshot_20220308-202338-214x500.png)