Light Switch + Fan Dimmer in One Board With ESP8266

by mcmchris in Circuits > Arduino

27788 Views, 133 Favorites, 0 Comments

Light Switch + Fan Dimmer in One Board With ESP8266

IMG_20190905_175112.jpg

In this tutorial you are going to learn how to build your own light switch and fan dimmer in just one board with the microcontroller and WiFi module ESP8266.

This is a great project for IoT.

Cautions:

This circuit handles AC main voltages, so be careful.

Extra: I posted here a video tutorial that shows you the whole process.

Video Tutorial!

¿Cómo automatizar tu habitación con Arduino? | Dimmer e Interruptor WiFi | Luz y ventilador

If you are a visual learner, here you have a complete tutorial of tu set up and build the device.

Schematics, Materials and PCB:

WiFi Dimmer Diagrama.png
2019.09.10-21.07.png
2019.09.10-20.23.png
2019.09.10-20.24.png
IMG_20190905_175112.jpg

Here you have an image of the schematics with the conections and the result of the PCB build by PCBGOGO.

Click HERE for the Gerber file of the PCB design so you can order yours on PCBGOGO.

Materials:

  • 1x ESP8266 (ESP-01)
  • ESP8266 Programmer
  • 7x 1k ohm Resistores 1/4W
  • 4x 470 ohm Resistores 1/2W
  • 2x Triacs BTA16 o BTA24
  • 2x MOC3010 (Opto Triacs)
  • 1x Hi-Link 3.3v power supply
  • 1x Optoacoplador H11AA
  • 2x 33 kohm Resistores 1W
  • 2x Terminal Blocks 2 pin
  • 1x 100 ohm Resistor
  • 3x 100nf 400v Capacitor
  • 2x Push Button

Code and Programming:

2019.09.10-20.24_02.png
2019.09.10-20.24_01.png
2019.09.10-20.39_01.png
2019.09.10-20.40.png
2019.09.10-20.39_02.png
2019.09.10-20.40_01.png

It's time to program your ESP module and setup everything.

  1. Connect the ESP Programmer to your PC
  2. Connect your ESP8266 to theProgrammer.

Here you can Download the Code and Libraries.

  1. Select the board: Generic ESP8266 Module
  2. Select the right COM port.
  3. Fill the Blanks (Ubidots TOKEN, WiFi SSID, WiFI PASS).
  4. Click on Upload button.
  5. You should be ready to test.

Ubidots Settings:

2019.09.11-19.32.png
2019.09.10-20.40_02.png
2019.09.10-20.40_02.png
2019.09.10-20.41.png
2019.09.10-20.41_01.png
2019.09.10-20.41_02.png
2019.09.10-20.42_01.png
2019.09.10-20.42.png
2019.09.10-20.43_02.png
2019.09.10-20.44.png
2019.09.10-20.44_01.png

First of all we need an Ubidots account, Click Here to create yours for free.

  1. Create a Device called dimmer.
  2. Create two variables bombillo and ventilador.
  3. Click on Data and create a new Dashboard called as you want.
  4. Add two widgets a button and slider associated to the device and variable.
  5. Resize your widgets and that's it.

IFTTT Setup

2019.09.10-20.44_02.png
2019.09.10-20.45.png
2019.09.10-20.45_01.png
2019.09.10-20.46.png
2019.09.10-20.46_01.png
2019.09.10-20.46_03.png
2019.09.10-20.46_04.png
2019.09.10-20.47_01.png
2019.09.10-20.47.png
2019.09.10-20.49.png
2019.09.10-20.48_01.png
2019.09.10-20.50.png
2019.09.10-20.48_02.png

  1. Create an IFTTT.com account.
  2. Click on Get more and then click on +.
  3. Click on IF+ and search for Google Assistant.
  4. Click on Say a simple phrase / number.
  5. Define your phrase and response.
  6. Click on That+ and search for WebHooks.
  7. Fill the blanks:

URL: http://industrial.api.ubidots.com/api/v1.6/device...

Method: POST

Content Type: application/json

Body: {"ventilador":0} // Repeat for Off, and the Fan speed.

8. Finish

Hardware Setup:

2019.09.10-20.51_01.png
2019.09.10-20.52.png
2019.09.10-20.52_01.png

Define the Terminal block terminals, Line, Neutral, Bulb and Vent. (L,N,B,V)

  • Break out the current supply. (For security)
  • Connect every wire on it place.
  • Put everything into the metal box.
  • The Blue button is the Light on and off button.
  • The Red button is Reset.

Testing It.

2019.09.10-20.52_02.png
2019.09.10-20.52_03.png
2019.09.10-20.53.png
2019.09.10-20.53_01.png

After everything is in place correctly, turn on the supply of your house and test.

Just need to say "Ok, Google" and the statements you had stablished and ready, or just go to Ubidots App on your phone or PC and swipe the slider and push the button.