When comes to selecting a perfect controller for your project there are numerous technical features to consider and also non technical issues such as cost, lifetime, etc. Microcontroller Assist is here to help.
To get start, just say "Alexa, ask Microcontroller Assist
". Microcontroller Assist will step you thru a list of 10 steps to choose a perfect microcontroller for your next project.
Just say "next
" or "continue
" to go to the next step.
You can 'bookmark' the current step by saying "save the step
" so that you can continue at a later time. To get back to the step where it was left off, just say "load the last step
".
- Create a directory call
Chip
.
- Create
chip_helper.js
,database_helper.js
,index.js
andpackage.json
files from the respective codes included in the code section below.
- With nodejs and npm installed, run "
npm install
" in theChip
directory to install required packages specified in thepackage.json
file. You will find a new directorynode_modules
created.
- Select all the files and directory, then create a zip file call Chip.zip. Keep this zip file as it will be used in the next step.
- Login to the AWS Console and click on the Lambda link. Note: ensure you are in N. Virginia (us-east) or you won't be able to use Alexa with Lambda.
- Click on the Create a Lambda Function or Get Started Now button.
- Skip the blueprint
- Name the Lambda Function "Chip".
- Select the runtime as
Node.js 4.3
- Select Code entry type as "Upload a .ZIP file" and then upload the .zip file to the Lambda
- Keep the Handler as
index.handler
.
- Create a
Basic with DynamoDB role
and click create.
- Leave the Advanced settings as the defaults.
- Click "Next" and review the settings then click "Create Function"
- Click the "Event Sources" tab and select "Add event source"
- Set the Event Source type as
Alexa Skills kit
and Enable it now. Click Submit.
- Copy the ARN from the top right to be used later in the Alexa Skill Setup
Note: If you encounter lambda upload problem (refer to screen captures below), try AWS CLI. Use this command to upload the lambda zip file:
aws lambda update-function-code --function-name chip --zip-file fileb://chip.zip
- Go to the Alexa Console and click Add a New Skill.
- Set "Microcontroller Assist" as the skill name and "microcontroller assist" as the invocation name, this is what is used to activate your skill. For example you would say: "Alexa, ask Microcontroller Assist."
- Copy the Intent Schema from the Intent Schema included in the code section below.
- Copy the Sample Utterances from the Sample Utterances included in the code section below. Click Next.
- Select the Lambda ARN for the skill Endpoint and paste the ARN copied from
Setup lambda skill
above. Click Next.
- You are now able to start testing your sample skill! You should be able to go to the Echo webpage and see your skill enabled.
- In order to test it, try to say some of the Sample Utterances from the Examples section below.
- Your skill is now saved and once you are finished testing you can continue to publish your skill.
You can manually test a Lambda function in the Lambda console by sending sample JSON events formatted in the same way as requests sent by Alexa. You can also send events to a Lambda function using the AWS CLI.
- In the Function list, click the function name to open the details for the function.
- Click the Test button. If this is the first time you have tested the function, the Input sample event dialog box is displayed.
- From the Sample event template list, select one of the sample Alexa requests. You can send one of these requests as is, or use it as a starting point to test different intent and slot values.
- Choose Submit.
Once you have configured a test event, clicking Test sends that same request. To configure a different event, click Actions and then Configure sample event.
After the function runs, the Execution result section shows the response returned by the function, in JSON format.
The Execution logs section shows any log messages generated by the code.
To ease debugging, you can access to the lambda log in two ways:
- From the execution result (see diagram above), click the (log) link, or
- Click the Monitoring tab, then select View Logs in CloudWatch
You can do simple testing using the Service Simulator displayed on the Test page in the developer portal. The Service Simulator lets you type in utterances, then see both the JSON request sent to your service, and the JSON response returned by your service. You can also play back the response to hear how Alexa speaks the response.
- When entering an utterance to test, only use alphabetic characters, spaces, periods, or apostrophes. If the utterance needs to include numbers, write them out as words (“one” instead of “1”).
- Once the JSON response sent by your service is displayed, click Listen (or the play icon) below the response to hear the response in Alexa’s voice.
To publish, you need to submit the app for certification by completing the Publishing Information and Privacy & Compliant forms.
The following two diagrams show the voice experience using the Microcontroller Assist skill.
This skill is made based on a series of tutorials created by Big Nerd Range. The tutorial starts with setting up a local development environment for building and testing Alexa Skill app. With the environment setup, I can build and test a Alexa Skill app within my PC. This project is using alexa-app as a framework to build the Microcontroller Assist skill, and alexa-app-server will provide an environment to test interacting with the skill locally.
Alexa Skill app's intents are implemented using the node.js module called alexa-app. The intent schema are generated based on some javascript codes, like:
skillService.intent('saveChipIntent', { ... });
At the same time, the utterances are generated with some codes similar to the following:
'utterances': ['{load|resume} {|a|the} {|last} step']
alexa-app-server hosts a web app which is a composite of lambda test console and Alexa Skill's service simulator, but without the speech service.
ChipHelper
(chip_helper.js)
is a javascript object which stores all the steps used by the Microcontroller Assist.
function ChipHelper(obj) {
this.currentStep = 0;
this.steps = [{
prompt: 'Alexa Microcontroller Assist helps you to choose a perfect microcontroller for your project. When you are ready say next.'
}, {
prompt: 'Step 1: Prepare the block diagram of hardware interface. This is the most important and primary action required before going to choose your controller. Make a simple block diagram listing all the hardware interface you are about to use in your project. There are two types of interfaces commonly available. The first one is communication interface where you need to look over the the peripherals such as I2C , SPI, UART and so on. The second one is Digital inputs or analog to digital inputs where you need to look over the ADC feature of your controller. These hardware interfaces will also help to decide the number of pins you need to dedicate for it.'
}, {
prompt: 'Step 2: Analyse the software architecture. Analyzing the software architecture can help you to design the system with much precision and avoid possibility of errors. Note down the requirements such as frequency of operation, time required to execute instructions, complexity of algorithm you about to use in your system and so on. This analysis will reveal how much processing power will be needed for your system, whether you go for a simple or robust controller.'
}, {
prompt: 'Step 3: Requirement of memory. Memory plays a very critical part in any Microcontroller and you have to determine the memory requirements by your system. You should always make sure that your controller doesn\'t run out of space and also leave some room for future development. The software architecture and hardware requirements will give you a idea how much of the Flash and RAM needed by application.'
}, ...
And database_helper.js
has all the DynomoDB database helper functions for creating table, store current step and load the last step.
ChipHelper.prototype.createChipTable = function() {
return dynasty.describe(CHIP_DATA_TABLE_NAME)
.catch(function(error) {
return dynasty.create(CHIP_DATA_TABLE_NAME, {
key_schema: {
hash: ['userId', 'string']
}
});
});
};
ChipHelper.prototype.storeChipData = function(userId, chipData) {
return chipTable().insert({
userId: userId,
data: chipData
}).catch(function(error) {
console.log("storeChipData -> " + error);
});
};
Link to Microcontroller AssistClick here to check out the skill
Comments