IOT Essential Oil Diffuser

Intro: IOT Essential Oil Diffuser

I was recently given an essential oils diffuser as a gift. The little gadget is super fun and super simple. Push the button to turn it on, push the button to turn it off.

I thought I could make it a little more interesting by being able to turn it on using voice control. In this guide I will show you how to make any device with a simple push button on off switch voice controlled. Let’s get started!

Step 1: How It Works

Before we dive in to actually making the project lets go over how it works. The goal is to make the diffuser think that its power button is being pushed. We do that by creating a short across the switch terminals. To achieve this the circuit uses an optocoupler. An optocoupler is simply an led and a photoresistor. When the led (left) is not powered the photocell (right) does not let current pass through. If we power the led the photoresistor lets current flow.

I decided to use a optocoupler because it allows the microcontrollers 3.3V GPIO pins to be electrically isolated from the 5V the diffuser uses. If you tried to hook the GPIO pins directly to the diffuser you would risk the 5V potential of the diffuser frying the microcontroller.

So all we need to do to trick the diffuser into thinking the buttons is pressed is power the optocoupler for a brief period, shorting the power buttons connections.

Step 2: Gather the Components

This project has a dead simple build and total cost should be no more than $10.

What you need

I have included amazon links for the parts I used. If you are patient and can wait for shipping from China you can usually find better deals on components through ebay.

Step 3: Create the Control Board

Solder all the components to the project board and make the required connections. Don't make any connections to the diffuser yet. For those connections I used a 10" piece of ribbon cable I had lying around but a set of 4 wires will do just as well.

Step 4: Disassemble the Diffuser

My diffuser comes in two parts there is the lid and the actual diffuser unit on the bottom. The goal is to locate where the power button is connected. My power button is in the bottom of the unit so I started by removing the 4 screws holding the unit together. Once these screws were removed I was able to separate the base and see what was inside.

Once inside I could see a fan, a pcb for the power jack, and a pcb for the power button. This is where we want to investigate next.


Step 5: Solder Wires to the Push Button Terminals

Once you locate the power button use the continuity setting on your multimeter to find witch two contacts are connected when the button is pushed. Drill a hole through the bottom of the diffuser to feed the wires through. Then solder the two wires from the optocoupler in the schematic to these two terminals.

Step 6: Connect Power

In my case my diffuser runs on USB. So there is a 5V source I can tap into right in the package. Your's maybe slightly different. The Vin pin of the ESP-12E has its own 3.3V voltage regulator that has a max input voltage of 20V so driving it with 5V works just fine. Make sure to check the voltage of your diffuser and the rated voltage of your regulator before proceeding. Once you have confirmed that the voltage is safe, solder the two power wires from your board to the input jack of the diffuser.

Step 7: Reassemble the Diffuser

Once everything is wired up close up your diffuser and make sure the manual button press still works. I decided to give myself enough length to let the board dangle over the edge of the bookshelf I keep it on. If your diffuser is bigger you may be able to hide the entire unit directly in the base.

Step 8: Download the Code

The code is available on github: IOT Diffuser

The code for this project was adapted from @DqwertyC with his fantastic guide on ESP8266 VOICE CONTROL WITH GOOGLE ASSISTANT AND ADAFRUIT IO

Follow dqwertyC's guide for setup instructions, code installation, and backend setup.

Step 9: Tweaking the Code

After setup is complete the two sections of code you may need to tweak are lines 58-60 and 64-69. This is the code that turns the diffuser on and off. This completely depends on how your diffuser works.

ON

My diffuser requires one button push to turn it on. These three lines mimic one button push.

digitalWrite(4, HIGH);

delay(100);

digitalWrite(4, LOW);

OFF

My diffuser requires two button pushes to turn it off. I used a for loop to do this.

for(int i = 0; i < 2; i++) {

digitalWrite(4, HIGH);

delay(100);

digitalWrite(4, LOW);

delay(500); //extra delay between presses.

}

Step 10: Taking It Further

A diffuser is just one use case for this project. This project can be adapted to fit pretty much any device that has a mechanical on off push button. It could also be easily adapted to work with Alexa. So get creative and connect more random stuff to the internet!

Share

    Recommendations

    • Metalworking Contest

      Metalworking Contest
    • Audio Contest 2018

      Audio Contest 2018
    • Fix It! Contest

      Fix It! Contest

    Discussions

    0
    None
    tomatoskins

    26 days ago

    Great way to make your diffuser work for you!