Ron Lisle
Published © MIT

Alexa Controlled Photon Project Without Alexa Coding

The Patriot Alexa Smart Home Skill and IoT library allow you to voice control your Photon quickly and easily with no Alexa coding at all.

BeginnerFull instructions provided30 minutes7,618
Alexa Controlled Photon Project Without Alexa Coding

Things used in this project

Hardware components

Photon
Particle Photon
You'll need a Particle connected to your free Particle.io account.
×1
Echo Dot
Amazon Alexa Echo Dot
You can use an Amazon Echo, Tap, Dot, or the echosim.io Alexa simulator.
×1

Story

Read more

Code

Photon starter sketch source code

C/C++
Copy this code to Particle.io web IDE and flash it to your device.
/******************************************************************
Example starting point sketch for Patriot IoT library
This example uses the PatriotLight plugin library to control
the built-in blue LED only.
It is provided as a quick start for your own sketches.
http://www.github.com/rlisle/Patriot
Written by Ron Lisle
BSD license, check LICENSE for more information.
All text above must be included in any redistribution.
Changelog:
2017-10-29: Converted to version 2 of IoT and plugin libraries.
2017-03-28: Use fixed 'patriot' event name.
2017-03-24: Initial creation
******************************************************************/

#include <IoT.h>
#include <PatriotLight.h>

IoT *iot;

void setup() {
  iot = IoT::getInstance();
  iot->begin();

  // Create devices
  //Note: D7 is not a PWM pin, so it can only turn on or off
  //      The last 4th argument specifies this.
  //      The 3rd argument can be used to invert on/off.
  // Alexa will respond to "Alexa, turn L E D on" or "Alexa, turn off L E D"
  // You can change the name 'LED' to whatever you like, but it needs to be something
  // that Alexa can recognize.
  Light *light1 = new Light(D7, "LED", false, true);

  // Tell IoT about the devices you defined above
  iot->addDevice(light1);

  // The "behavior" defines additional commands that control things.
  // Note that the name of each device can be used to control it, so behaviors are
  //      not required unless you want to control more than one device with a commands.
  // Alexa will respond to "Alexa, turn photon on" or "Alexa, turn off photon"
  // You can change the word 'photon' to whatever you like, but it needs to be something
  // that Alexa can recognize. For now, use a single word.
  iot->addBehavior(new Behavior(light1, "photon", '>', 0, 100)); // On
  iot->addBehavior(new Behavior(light1, "photon", '=', 0, 0));   // Off
}

void loop() {
  iot->loop();
}

Credits

Ron Lisle

Ron Lisle

0 projects • 27 followers
Lives in an RV, and is turning it into an IoT showcase using Alexa, iOS, and particle.io. Professional iOS, Alexa and IoT developer.

Comments