STEAM DISCOVERY LAB
  • About
  • Tools
  • Projects
  • Resources
  • About
  • Tools
  • Projects
  • Resources
Search

Amazon Alexa to EV3

Lesson Objectives:
  1. ​Students will control their EV3 robot using Amazon Alexa voice capabilities
  2. Students will understand the relationship between  
Materials:
  1. EV3 Lego Robotics Kit / legos
  2. Device with Amazon Alexa capabilities (ex. Echo, Echo Dot, Echo Spot, etc.)
  3. Laptop and WiFi connection
  4. USB
  5. Google account
  6. If This Then That (IFTTT) account
Let's get started!
This project utilizes the model seen below:
Picture
Using If This Then That (IFTTT)

*If you do not already have an IFTTT account, sign up using this link*
*If you have not already set up your Alexa device, follow the instructions here*

This project utilizes IFTTT to handle the data (your voice command) you wish to send to your EV3 robot. In a general sense, IFTTT is a service used to connect two web services using a trigger and action model. If something happens on the first service (the trigger), then do ___________ with the second service (the action).

How does IFTTT work for this project?

In this case, vocal commands to your Alexa device will trigger a word to appear in your specified Google Sheet. The phrases I say to my Alexa device (Echo Dot) specify the EV3 bot to move "forward," "back," or to "stop." These movement values will then be sent to your Google Sheet, and will eventually be pulled by LabView and handled appropriately (will discuss later).

Steps:
  1. Log into your IFTTT account then click on your profile at the top right corner. 
  2. Click "New Applet"
  3. Click on the blue "this"
  4. In the device search box, type in "Amazon Alexa"
  5. Click the blue box that says, "Say a specific phrase." When speaking to your device, you will say "Alexa trigger" + "forward" or "back" or "stop"
  6. For the phrase, type in "forward." This will be your trigger word. Set the trigger by clicking "Create Trigger"
  7. Now it's time to create your "That" (action). Click the blue "that" 
  8. On the "Choose Action Service" page, type "Google Sheets" into the search box
  9. Choose "Update cell in spreadsheet." You will be updating a single cell in your sheet with your movement word
  10. Once on the complete actions field, leave the "Drive folder path" blank - delete contents if not empty
  11. Log into your Google Drive account and create a new Google Sheet - its name does matter
  12. Set the Spreadsheet Name to the name you assigned your newly created Google Sheet
  13. For simplicity sake, assign the cell to A1 - the cell in top top left corner. The value of A1 will change depending on the trigger spoken to your alexa device.
  14. Since the trigger word is "forward," set the value to "forward."
  15. Click Create Action to complete your Applet
In order to create Applets for triggers like "back" and "stop," follow these steps once again.

Test it out
  • While in proximity to your Alexa device, say "Alexa trigger {directional word}"
    • If your Google Sheet's A1 value contains the appropriate directional word, then your IFTTT Applets run correctly
​Example:
Picture
"Alexa trigger forward"
Picture
Now that you have your Alexa device sending messages to your Google Sheet, it's time to move onto the LabView component of this project

What is LabView used for in this project?
  • LabView acts as the bridge between the spoken commands and your EV3 robot
  • LabView will query your Google Sheet's saved directional value and accordingly move your bot

How is this done? ​
  • The primary method of extracting data from your Google Sheets is through performing a GET request
    • Use an HTTP GET handler
      • ​The URL's structure derives from Google Sheet's API. 
      • We will be using the Basic Reading  interface, so your GET URL will look something like this: https://sheets.googleapis.com/v4/spreadsheets/spreadsheetId/values/Sheet1!A1
        • Your spreadsheetId, which identifies your specific Google Sheet, is found in the URL of your Sheet. For example, if your Sheet's URL is - https://docs.google.com/spreadsheets/d/123ABC/edit#gid=0 - then your ID would be "123ABC"
    • Use the URL you put together as the URL for your GET
    • The last component of the URL is your Google API App Key
      • Log into your Google API Console, in order to create an app key
        • Click on New Project at the top left corner of APIs and Services page from the link
          • Your project name is up to you and once created, click on your new project 
      • On the lefthand sidebar, choose Credentials
      • Under Create Credentials, choose API Key. This will be attached to the end of your GET URL from above, since it gives LabView security access to your Sheet
        • Let's say your generated API key is "56BS2J"
        • Your URL will now look something like this: https://docs.google.com/spreadsheets/d/123ABC/edit#gid=0?key=56BS2J
How did we set up our LabView code?  
Here is an example of how we connected Google Sheets to LabView and ultimately controlled our EV3 robot. However, you can structure your LabView code however you like!
​
googlesheets_to_ev3.vi
File Size: 58 kb
File Type: vi
Download File

Creating your EV3 Robot

This project utilizes Lego Mindstorms. Your model's design does not need to follow ours, but we will include instructions for our EV3 car below:

​
ev3-car-instructions.pdf
File Size: 9519 kb
File Type: pdf
Download File

Looking for more inspiration?
Lego Mindstorms Building Instructions and Program Descriptions
Picture
Picture
200 Boston Ave, Medford, MA 02155
steamdiscoverylab@gmail.com
Center for Engineering Education and Outreach
​Tufts University
About
Tools
Projects
Resources
​
Contact
LEGO®, the LEGO® logo, the Brick, MINDSTORMS®, and the Minifigure are trademarks of ©The LEGO® Group. On some parts of this site  you will get access to so-called “developer software”, which offers documentation on different ways to operate the LEGO® Education SPIKE™ Prime Hub and technology. Whatever use you make of the developer software, bear in mind that the results are not experiences that the LEGO Group endorses, is with or will be liable for. No rights in or to trademarks of the LEGO Group are implied or given, and you may not apply to or register any protection anywhere in the world for intellectual property or industrial rights or similar in respect of any developer software, derivative or other result achieved through its use. The developer software is made available “as is” and, to the extent possible, no warranties or representations are implied or given in relation to it by the LEGO Group. It’s your responsibility to ensure all uses that you make and enable others to make comply with all applicable laws and best practices. By accessing the developer software, you acknowledge that the terms and conditions set out above and in LEGO Education’s terms of use for SPIKE Prime apply.
  • About
  • Tools
  • Projects
  • Resources