Introduction: Voice Control of a Ceiling Fan With Alexa

In this Instructables, we will use a Particle Photon (Arduino compatible) microcontroller coupled with a 315MHz RF Transmitter to send commands to a Harbor Breeze ceiling fan. We will then learn how to use an Amazon Echo and Alexa to activate our fan using voice commands. The ultimate goal is to be able to turn on the fan by saying: "Alexa, trigger fan on".

Acknowledgments:

Reverse Engineer RF Remote Controller for IoT! by veggiebenz

RF 315/433 MHz Transmitter-receiver Module and Arduino by Mohannad Rawashdeh

Home Automation using Particle and Amazon Echo by Krishnaraj Varma

Step 1: You Will Need...

Step 2: Connecting the Photon to the RF Transmitter

The MX-FS-03V RF Transmitter module can be found in 2 frequencies, 315MHz and 433 MHz. I used the 315 MHz to match our ceiling fan frequency.

The RF module requires only 3 wires: GND, VCC and DATA. We will connect the GND pin to pin GND and VCC to VIN of the Photon. The signal pin DATA will be connected to D0 of the Photon.

Additionally, you will want to attach an antenna to the module to get better range. A 13cm (5") straight wire soldered to the ANT hole should do the trick.

Thanks to veggiebenz's Instructable, we are able to transmit RF commands to the fan by sending a pattern of 0s and 1s to the D0 pin configured as a digital output; no library is required.

Step 3: Software

We will assume that you have already gone through the steps to create your particle account and activate your photon device. In the rest of this Instructable, we will also assume that you named your Photon device "fantastic" (lame, I know). See the getting started link on the particle web site for more information on how to do this.

Open the Particle Build web site and login to you account. Create a new project by entering a title ("fantastic" in this example). Download the software and add the 3 files to your project (Hint: to create the fantypes.h and fantypes.cpp files, use the small + icon at the top right of the toolbar). I used the fantypes.h file to store the signal patterns and other constants.

Attachments

Step 4: Verify the Hardware

To verify that the Photon can now control your fan, let's create a new DO button using IFTTT's DO app (downloadable from your phone's app store). To create the recipe, click the "Recipe" icon at the bottom right of the screen, click the + sign, click the Channels tab, click the Particle icon, click Create a New Recipe, click Publish an event, call it FAN ON, select FanControl on "fantastic" for "Then Call" (Function Name) and enter "2" (or any preferred speed) for "With input (Function Input)".

Click the DO button to turn the fan on. The fan should turn on. Make sure you have attached or soldered a 13cm wire antenna to the RF module or you may have to bring the module in close proximity of the fan for this test.

Step 5: Alexa Voice Commands Via IFTTT

The simplest way to enable Alexa to control our particle device is to create an applet in IFTTT (If This Then That). IFTTT provides an Alexa Channel. Start the IFTTT app on your phone, click the "My Applets (used to be called recipes) and click the + icon at the top right of the screen to create a new applet. Select the Alexa channel (you will need to provide your Amazon credentials to allow IFTTT to communicate with Amazon) and choose the trigger "Say a specific phrase". Select a phrase such as "fan on" (use all lower case). The rest of the setup is similar to the DO button setup, where you select the Particle Channel for the THAT part of the applet.

That's all that is required. Try "Alexa, trigger fan on" to turn the fan on. Add other commands such as "fan off" or "light on" for additional functionality.

This is pretty much the easiest way to achieve voice control. In another Instructables, "Controlling your Photon device with SmartThings and Alexa", we will take a look at another method that involves SmartThings and that allows you to say "Alexa, turn on the fan" instead of the more awkward "Trigger fan on".

Arduino Contest 2016

Participated in the
Arduino Contest 2016