Things used in this project

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

Code

Photon starter sketch source codeC/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

379434 2505719874906 2113020799 n
Ron Lisle
4 projects • 15 followers
Lives in an RV, and is turning it into an IoT showcase using Alexa, iOS, and particle.io. Professional iOS and Alexa developer.
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog