Go Down

Topic: IOT button to trigger Alexa Routine  (Read 800 times) previous topic - next topic

bedsingar

Hi all,

I've recently picked up a mkr1010 board for a project I'm building for my daughter.

Essentially she loves listening to specific playlists on the amazon echo in her room, but as she is only 2 isn't quite able to string together the correct sequence of words to get the right result for Alexa each time.

My plan is to build a board with photos on and buttons under each photo, hooked up to the arduino so that when a button is pushed it triggers an alexa routine.

I've seen other threads of people trying to do similar things, but there is no native capability for this yet so I am hacking around it.

I have got this working with one button by setting up a virtual switch in smart things, a web hook in IFTTT and then the properties in arduino cloud so that when the button is pressed on the arduino, it fires the webhook > IFTTT > turns on the virtual switch > triggers the alexa routine which in turn turns off the switch and plays the desired playlist on my selected device. - Very happy to get to this point.

However ... I now want to scale up and have multiple buttons, but have hit a problem in that the webhook in arduino cloud IDE seems to fire for all communications with the cloud service. I need a way of setting up 12 virtual switches, 12 IFTTT triggers / webhooks and then only firing the one relative to the button that has been pressed. (Unless these can be parameterised)

Can anybody point me in the direction of how I would add multiple webhooks to the IDE and indicate which to fire from the arduino code? - Or if not I assume that I can somehow send a post command from the arduino code. Examples I've found use enet rather than wifi. - Does anybody have an example of this for the MKR1010 please? - Assume I could then just fire a specific post command direct from the code.

Thanks in advance

 

bedsingar

I found a sample from the samples library that suggests I can use:

char server[] = "www.google.com";    // name address for Google (using DNS)
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
WiFiClient client;

void getrequest() {
  Serial.println("\nStarting get request...");
  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    Serial.println("connected to server");
    // Make a HTTP request:
    client.println("GET /search?q=arduino HTTP/1.1");
    client.println("Host: www.google.com");
    client.println("Connection: close");
    client.println();
  }


And a call to the getrequest() from the loop checking for a button press.

This gets as far as printing "connected to server" in the serial monitor but doesn't return any results.

The example only shows a GET, but I assume I could switch this for a POST ... but as I can't get the GET to work, not sure POST would work either. 

Go Up