Software apps and online services
Hand tools and fabrication machines
First things first. Lets talk about the enclosure. I decided to use acrylic because of the following adavantages:
- its design is straight forword;
- Its transparency characteristic gives a pedagogical advantage, as you can more clearly explain what is behind the curtains;
The design is not very elaborated and thus not too complicated to reproduce.
I used 2 A4 (roughly the same size as Letter) sheets of 3 mm acrylic and another 2 sheets of the same material and size of 1 mm of thikness. The 3 mm plates will be to hold the electronics and motors, the 1 mm will be to add layer with printed paper, to personalize the robot.
As of the moment of the laser cutting process I still did not knew where exactly would mount the electronics, I made the holes for the mounting screws at a later time with a drill tool using mostly a 3 mm dril bit.
For the motors and the Amazon Echo Dot support, I bought two acrylic kits allready cutted.
The core o this project is an Arduino Mega 2560 board, mainly bacause it has a lot of input and output pins. Another advantage is its form factor and the availability of numerous shields. This turns prototyping easier and reduces considerably one of the main dificulties and complexities of projects of this kind: the wiring nigtmare.
For the Wifi, I selected a shield with Esp8266-12e. Once again to keep things simple, it was maintained the manufacturer firmware and the communication is made through the AT command library with the Arduino, thus consuming here one Arduino serial port.
Note: to keep free the Arduino USB serial port number 1 for debug purposes, it was bended the digital pins 0 and 1 (RX and TX) of the Esp8266 shield.
To setup the Esp8266, it was used a USB serial adapter and defined the following configuration:
- Serial baud speed;
- Wifi client mode;
- Wifi SSID and password;
This configuration is made once, for your particular environment, and is not necessary to change.
The other board used is a generic sensor shield. As it has lots of pins connections, it simplifies the process of connecting the servo motors.
In the car part we have the following components:
- 4 motors and wheels;
- 12V battery;
- LM298 motor driver;
- DC 12V to DC 5V 3A 15W step down power adapter;
- 3 HC-SR04 distance seonsors;
In the body is located the Arduino with the shields, and is the support for the servos that connect to the head and arms.
Besides the Arduino and its shields, the body has two Mosfet driver module IRF520 to turn on or off the USB devices that you can attach to the arms. And another two USB ports to power another two USB devices, namely the Amazon Echo Dot.
The coupling of the Alexa Echo Dot to the robot is made with magnets.
In the head we have 3 blue led matrix 8x8 with MAX7219 controller, that emulate the eyes and mouth. This give the robot the possibity represent some emotions.
At last minute, our robot got a pair of hears:
To give some handling robustness to this robot it was applied this simple tricks:
- Used cable ties;
- Used hot glue in the connectors of the jumper wires (after being sure that everythings was working as expected);
Before we go into the software development part, we need to decide which interactions we want our system to have. So lets define some vocabulary so that we can configure Arduino, Alexa, AWS Lambda and Thingspeak.
To start, these are some actions that our robot will be able to accomplish:
- Right arm: Point right ARM to front and activate attached USB;
- Left arm: Point left ARM to front and activate attached USB;
- Don't know: Raise shoulders;
- Say yes: Nod of the head;
- Say no: Shake the head;
I used a Thingspeak free acount. For the purpose of this project, the free account limit us to one interation each 15 seconds, but I consider this reasonable.
In Apps / TalkBack we create a New TalkBack. This enable us to have a queue of commands that Arduino can consume. We have to take note of the given TalkBack Id and API Key, as this will be needed in the next step, in the ThingHTTP.
Next we go to Apps / ThingHTTP and create one entry for each interaction we defined on the vocabulary.
For each ThingHTTP created we fill the following fields:
- URL: is the url of the previous TalkBack created
- Method: choose POST
- Content Type: application/x-www-form-urlencoded
- Host: api.thingspeak.com
- Body: api_key=<Your TalkBack API Key>&command_string=headYes
We will need, now, to create an Amazon AWS Lambda function to handle the intents of the just created Alexa Skill.
We wiil need to create another account, this time in the Amazon AWS platform.
To shorten this explanation, I suggest you to view the following tutorial on youtube that explains how to build an Amazon AWS Lambda do make an HTTP Get request (link) and grab its code repository at github (link).
After that, create a new AWS Lambda function based on the blueprint alexa-skill-kit-sdk-factskill with nodejs6.10.
We will end with the following screen, where we need to add and Alexa Skill Kit to the triggers list.
But, this is a catch 22, as for that you have first to create an Alexa skill, but for that you will need the code that apears in the top right of the previous screenshot, and has the format of: arn:aws:lambda:eu-west-1:xxxxxxxxxxxx:function:teste.
For this you will have to have an Amazon Alexa Skills Kit free account.
Go to Alexa Developer Console and create a new skill.
One of the requiered steps is to insert the previous reference to the aplication you create in AWS Platform.
In the interaction Model we will add the Intents that will trigger the ThingHTTP entries defined previously. And for each Intent we will add an Utterance accordingly:
Now back to the Lambda function, we will add the Alexa Skill Kit trigger.
Insert the Skill Id of the Alexa Skill you created previously.
Now if you done everything, you have on your computer one archive.zip. Which has the hability to make some HTTP Get requests, but we need to integrate the Alexa Skill kit SDK in that package.
So, on the console of AWS Amazon of your Lambda function, go to Action and select Export Function, in the next Message box, select Download depoyment package.
Now you have another zip, that is the package of the Lambda function you just created.
Unzip both files. Copy the contents of the folder "node- modules" (it should have 4 subfolders:.bin. alexa-sdk, i18next and i18next-sprintf-postprocessor) of your Lambda function to the folder with the same name of the archive folder.
Now re-zip the archive folder.
In the AWS console, choose upload a.zip file. Upload the Zip file you just created.
Now, in the editor of the function code, paste the code of the index.js that you can find attached to this project.
To simplify things, the Arduino code is devided in several.cpp files.
We have the main module, robot.ino where is the setup and loop functions. Than we have the following modules:
These files are attached to this project.