Author Topic: Alexa to Oak  (Read 518 times)

ceramiclover

  • Newbie
  • *
  • Posts: 1
Alexa to Oak
« on: March 12, 2017, 10:12:17 am »
My goal is to turn something on such as the lights in my apartment using Alexa.  If i can get a pin to go high or low on the oak, i can figure out the rest with a relay or optotriac.

I followed https://github.com/rlisle/alexaParticleBridge tutorial but I am stuck.

I created an alexa skill.  I have successfully opened it with alexa.  I tell her to turn it on.  She just responds with the word particle.

I am not sure what to program into the oak to for its input/output.  I do not understand what Alexa is communicating to the Oak.


This is the sample .ino oak code:
void setup() {
  Serial.begin(57600)
  Serial.println("ParticleExample started.")
 
  Particle.function("myFunction",myFunction);
}

void loop() {
  // put your main code here, to run repeatedly:

}

int myFunction(String command) {
    Serial.println("myFunction called.");
    // We don't need to return anything.
    // Just return an easy to recognize number for testing
    return 123;   
}


I tried to view serial monitor to see if it was registering any input, but Arduino just says "Oak Ready Board at COM1 is not available"


PeterF

  • Hero Member
  • *****
  • Posts: 794
Re: Alexa to Oak
« Reply #1 on: March 13, 2017, 08:12:41 pm »
So, stupid question first  ;) ... Are you connecting a USB to Serial adapter to the Oak? The microUSB port on the Oak is for power only.. there is no data link to the computer.

If not, and if delay of a second or two isn't an issue... have a look at using OakTerm and using the below statements instead of the Serial ones. Basically replace the Serial. bit on the print and println statements with Particle.  and change the Serial.begin(56700); to Particle.begin(); as there no need to specify a baud rate. All the prior serial messages will be magically sent over the internet to OakTerm, and you should be able to see what is happening. Failing that, you need to get yourself a 3.3v USB to serial converter, preferably based on a CH340 chip.

Code: [Select]
Particle.begin(); //the cloud equivalent of Serial.begin()
Particle.print("some_text");
Particle.println("some_more_text_and_new_line");

rkinnett

  • Newbie
  • *
  • Posts: 7
Re: Alexa to Oak
« Reply #2 on: March 18, 2017, 12:05:46 pm »
This is the basic topology for one-way Alexa-Oak integration:

Voice  --->  Alexa custom skill  --->  Lambda function  --->  Particle REST API  --->  Oak Particle function  --->  Relay

Your first and foremost task is to setup a basic sketch that exposes Particle functions to control an LED (for now, as surrogate for your relay) through the Particle cloud.  You could use this tutorial as a starting point, although you don't need a tri-color LED with three pins; simplify that sketch to toggle a single LED.  The key concept is setting up particle functions in your setup().  You can access the functions through OakTerm, the Particle mobile app, a custom html page, etc.  Get this working before you tinker any further with an Alexa skill and Lambda function. 

Later, you'll write a Lambda function as a middle man between your custom Alexa skill and the Particle cloud API.  The Lambda function generates http POST requests to Particle to call the functions on your Oak which you registered as Particle functions in your setup().

You might fight my garage door project to be a useful reference.

Good luck!  Please keep us posted on your progress.  Lots of people on here are happy to help.

EDIT:  welcome to the forum!





albertzerok

  • Newbie
  • *
  • Posts: 2