Light Switch + Fan Dimmer in One Board With ESP8266


16,380

7

15

I'am an Electronics student that really enjoy making new things from garbage, and DIY projects. I...

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.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Video Tutorial!

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

Step 2: Schematics, Materials and PCB:

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

Step 3: Code and Programming:

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.

Step 4: Ubidots Settings:

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.

Step 5: IFTTT Setup

  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

Step 6: Hardware Setup:

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.

Step 7: Testing It.

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.

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    15 Discussions

    0
    None
    diy_bloke

    14 days ago

    Your link to the code goes to so.e Spanish website that shows a review and asks me what I want to pay. No code in sight.
    Also, a triac might not be the best way to regulate an inductive load.
    It can be done but need plenty of filtering

    0
    None
    mcmchrisAnkurP12

    Answer 4 weeks ago

    Yes, it does. Do you know how to reduce it or fix it?

    1
    None
    ShashwatNmcmchris

    Reply 27 days ago

    You will have to implement a snubber circuit to take care of the humming.

    0
    None
    mcmchrisShashwatN

    Reply 23 days ago

    Yes, the diagram has it snubber circuit!

    0
    None
    FahadK6ShashwatN

    Reply 24 days ago

    What would the values of the components in the snubber circuit ,please?

    0
    None
    FahadK6

    Question 24 days ago

    Hi. In my country supply line is 230V/50Hz. Will that change the values of resistors and capacitors? Thank you.

    1 answer
    0
    None
    mcmchrisacmenw

    Answer 4 weeks ago

    Do not use R8. Let this place empty in the circuit because this resistor is duplicated by mistake.

    0
    None
    discostu956

    4 weeks ago

    Do you mind explaining what the ubidots and iftt sections are actually for? I'm assuming it's to control the device, but I'm not familiar with these types of things and only guessing

    2 replies
    0
    None
    mcmchrisdiscostu956

    Reply 4 weeks ago

    Yes, Ubidots it's the IoT platform to control your switch and dimmer through the internet. And the ifttt is to pair the Google Assistant with the device.

    0
    None
    nqtronix

    4 weeks ago

    The distance between high and low voltage is IMHO too small. If the buttons on the front panel are rated for mains voltage, it should be safe to use unless you use the reset button while connected to the mains voltage.

    I've attached a picture to illustrate my concern. The image is from Ken Shirrifs blog with more detailed explainations: http://www.righto.com/2016/03/counterfeit-macbook-...

    creepage.png
    1 reply
    0
    None
    mcmchrisnqtronix

    Reply 4 weeks ago

    You are right with the Gaps distance between high and low voltages, I've tried them for years that close and nothing had happened, but I know there are safety standards. Also, about the switches, they just switch 3,3v voltajes, the main voltajes are handle just by the Triacs. Thanks for the advices.