Making a New Amazon Skill for The Echo

I was prompted to dive back into the Amazon Alexa Skill development by the new Alexa Hackster.io contest.

I quickly classified the development of Alexa Skills into two major categories. They don’t break them down this way, but it makes more sense to think of their development by the requirements of the developer and setup.

  1. Not user specific – Generic information and interactions available to everyone
  2. User specific – Needs information from the user like configurations, links to their devices, or specific user instances.

The non-user-specific Alexa skills are fairly simple to create and for this guide I will be creating one using Node.js in an Amazon Lambda function (their version of a cloud run process) combined with an Amazon Skill.

  1. Set up a new Amazon Lambda function (Needs to be in N.Virginia in the top right of your dashboard screen)
  2. Set up a new Amazon Skill
  3. Grab the Application Id from the newly created Amazon Skill and replace the part in the AlexaSkill.js file relating to the ApplicationId.
  4. Then upload the zip file to your Amazon Lambda function.
  5. Then define the Voice Interface using the two files in the speechAssets folder. (IntentSchema.json and SampleUtterances.txt)
  6. In your lambda function, go to the Event Sources tab, and add the “Alexa Skills Kit” Event source.
  7. Then copy your Amazon Lambda’s ARN (Amazon Resource Name) and past that into the Endpoint textbox in the Configurations Tab of your Alexa Skill – something like arn:aws:lambda-us-east-2:9081209381:function:hello-world

The user-specific Alexa skills require an endpoint that allows the user to login to your own authentication service. This in turn will require a web app and a database of stored information per user. Stay tuned for more information on how to make that happen.

At the end of my investigation of the non-user-specific Alexa skill, I created and deployed a Wind Reporting service to Alexa that allows me to use the Echo to find out what the current Wind conditions are in my city before I take my drone out for flights.

linea_2ec(0)_512

Check out the Hackster.io post for the Alexa Wind Reporting Service: https://www.hackster.io/anthony-ngu/alexa-wind-reporting-service-7aada2

Publishing an Alexa Skill

Some things to keep in mind if you are making your own Alexa Skill for global publishing.

  • You will need icons for your Alexa Skill
  • You will need to process the generic Help intent
  • You will need to process the generic Stop / Cancel intents

 

Creating the Smart Home Universal Remote

It’s been a while since I last made a smart home device, not because my home is fully automated or because there wasn’t a need for another device, but because I still live in a rented unit and didn’t want to to spend the time making and setting up custom devices that would need to be torn down in the future.

Well the other day I realized that I could build another home automation device without a long-term stationary placement requirement! Not too long ago I built voice integration into my smart home system using the Amazon Echo (check out the articles here). While this worked well for moments without ambient noise, it failed to work well during parties, while watching movies, or while listening to music on my sound system. Obviously I needed another way to interact with these smart home devices and the current method of pulling out a phone or tablet, unlocking it, then switching between apps just didn’t appeal to me. What I really wanted was a universal remote that could also talk to my smart home devices.

So I started designing and planning out the features that I would want in my smart home controller and it had to be wireless charged (because replacing batteries or being tethered to a wall is archaic). Here’s the requirements I came up with:

Essentially, the goal is to get it all placed inside of an enclosure like this:

universal-button

Here’s a video of the very early prototype’s functionality:

As well as a more in depth Hackster post:

https://www.hackster.io/anthony-ngu/universal-smart-home-remote-wirelessly-powered-896f3c

My Electric Longboard Build – BOM

While I was creating my first build and began to put my first working prototype together, I figured I would document my parts, their prices, and explain why I chose them. I’ve split up the BOM into two parts, the electric longboard components and the board components which are usable on their own for a normal longboard. I decided to go with a single motor design for my first build (it seems fairly trivial to add a second motor in the future) and so far it’s been handling pretty well on hills. The only downside is that sometimes if I lean all the way to the left, the right back wheel comes off the ground slightly and I lose the driving traction. For more info about the trade-offs, check out my previous post.

The way a typical electric longboard works is, you (the rider) use the transmitter to speed up or slow down. The transmitter interacts with a receiver that is hooked up to the ESC (Electronic Speed Controller) which interprets the signal and turns it into a motor signal. The ESC needs to be hooked up to the battery for power since the ESC is what drives the motor. The motor then turns a gear which is hooked up to a belt that will then turn another gear that is attached to your wheel. This is how your longboard will gain movement.

ElectricLongboardDiagram

 

Electric Longboard Components
$70 – 5065 170kV sensored brushless DIYElectricSkateboard motor with 8mm wide and 35mm long shaft
5065 designates the size of the motor and is a common size for electric longboards although they typically have a smaller shaft. 170kV designates the torque the motor can produce (the smaller the number the higher the torque, but the lesser it’s top speed).
motor
$25 – Wiiceiver – (Not needed if you are using the VESC)
 A way to control the input to the ESC coming from the wii nunchuck
wiiceiver
 Has a better feel and is less bulky than a traditional RC controller.wii-controller
$110 + $20 – VESC
I found someone with experience making them and bought one but it needed to be custome made and shipped to me. The extra $20 is because I had to solder on wires and 2200uf 63V capacitor myself.
PCB_Front-1024x683
I used this in the interim while I was waiting from my VESC to be made and shipped to me. With some configuration it turned out to work decently well. I was able to ride it on flat or a slight incline, but with less power and it would cut off if the motor started to draw too much power. 
mambamaxpro
They were a lot cheaper than the 6S1P 5000mah batteries and have decent power and capacity.
5S1PBatteries
DIYElectricSkateboard sells an aluminum part for the motor pulley and I figured that since it’s the part coming off the motor shaft and is only connected by two set screws, it makes sense to get this part made of aluminum to handle the stress.
FREE – 15mm width 36 tooth wheel pulley (3D-printed it myself)
Originally based off a 9mm pulley model, I had to add bigger holes for stronger screws and a couple other changes. I will link to the design I put together for this part once I’ve tested it and made it fit reliably.
OrangatangPulley
$10 – 8mm width 280mm length HTD5 belt
15mm width is better than the 8mm width belt due to it’s wider area and less likelihood of snapping, but an 8mm belt allows for some leeway in alignment.
$5 – 5x M5 x 70mm bolts + washers + nyloc nuts for the wheel mount
These come in a lot more usually than only 5, but it doesn’t hurt to have more just in case.
This works out well and is made of aluminum. This can be replaced with a cheaper non-adjustable mount, but I didn’t like the idea of welding on a mount to my longboard trucks and had not ability to do the welding.
MotorMount
Subtotal: $400

Board Components
I chose these due to the holes in the hub of the wheels that could hold screws in order to mount a gear through.
orangatang_kegel
Due to my choice of wheels, these had to be altered in order to fit them (I used a file to make a bit of room for the screws that hold the gear onto the wheel) If I were to do this again, I might try the Paris trucks since they are more symmetrical.
caliber2fifty
These are some of the better bearings and ride really smoothly.
bonesredsbearings
$100 – Board of your choice
Subtotal: $224

Total $510 with new wheels and trucks on an old longboard
Total $624 from scratch

Generating Icons and Splash Screens with Ionic

One of the issues I’ve always had with mobile development is needing to scale images to support the multiple icon sizes and splash screen sizes. While customized icons and splash screens for each device is a valuable asset for any application, I’ve always viewed it as this tiring and monotonous task that needs to get done for mobile development.

Enter the  ionic resources  command. Now that I’ve been doing more mobile development with the Ionic framework and Cordova, I realized that they’ve got a plethora of tools to make mobile development easier.

In an Ionic project there is a “resources” folder that contains icon.png  and splash.png along with android and ios folders. If you run  ionic resources  from the command line within the Ionic project, it will automatically take the icon.png and splash.png and scale them or crop them to fit the appropriate sizes.

If you just want to regenerate the icons or splash pages only, use these commands:

ionic resources --icon

ionic resources --splash

For more info check out the Ionic Blog post: http://blog.ionic.io/automating-icons-and-splash-screens/

 

Developing Mobile Apps with HTML/CSS/JS

I’ve always been interested in mobile application development and I learned Objective-C for iOS app development. However, as my web application development experience increased, I started to question the scalability of code for different mobile platforms (iOS, Android, and Windows). Developing separate applications for each platform with similar functionality but utilizing each platform’s separate SDKs and languages didn’t seem like the best method.

Because of this, I began to lose interest in native mobile development (Especially with the regular updates to the OS and slight changes that meant that I would have to keep updating the code for each new version) and I put off mobile development for web app development which could be scaled to work for mobile browsers using a blend of frameworks like BootstrapFoundation, AngularJS, and Node.js. Of course, making a mobile web app had some drawbacks. It loaded slower and would always need a connection to the internet in order to fetch the pages.

ionicview

That changed recently when I was re-introduced to Cordova and PhoneGap as well as the Ionic Framework. I had heard about Cordova when I was working with Objective-C but after a quick initial investigation, decided that it wasn’t for me due to the limited functionality in the earlier days. After a deeper dive this time, I’ve begun to see it as a platform that I can develop for.

It still uses HTML, CSS, and Javascript, but it’s a specialized project developed solely for mobile applications which allows for native app deployment rather than mobile website creation and can call the actual mobile platform’s SDK. It’s different than a webapp port, but it allows the web developer to use the same language (re-use big portions of code) and create hybrid applications for each platform that look like native applications and render through cached files.

Here is a great article about the history of Cordova & PhoneGap and the UI framework for them known as Ionic and here is an article about what the Ionic Framework is.

The biggest issue I reached early on was the need to talk to APIs and the CORS (Cross-Origin Resource Sharing) issue. Because some APIs don’t expect to be called client-side (which is what you code for in a Hybrid app), this causes some development pains. Rendering in the browser allows for fast iterative development and better debugging without having to rebuild each time, but will regularly throw the CORS issue in your face, while deploying to the phone will work perfectly fine but limit your debugging capabilities. To circumvent this, you need to open a new browser window with web security turned off (which is dangerous, so only use it for your application). More info on how to do this can be found here: http://superuser.com/questions/593726/is-it-possible-to-run-chrome-with-and-without-web-security-at-the-same-time

After that, I was in the free and clear and I’m starting more mobile development again.

Making an Electric Longboard

boosted-board image

Electric longboards have been taking off lately and gaining publicity through Kickstarter campaigns and tech sites like TechCrunch, Engadget, and Tested. The most popular commercial products come from Boosted, evolve, and Marbel. However the price for a consumer board is upwards of $1000!

Because of this price, there has also been a huge movement in DIY electric longboards and the most common designs take a regular longboard and RC Car electronics to create a custom electric longboard with swappable components. This was the route that I was interested in going since I already had a regular longboard and couldn’t justify spending over $1000 on a longboard that I could build myself for less than $600.

The first step in building your own electric longboard is of course research. I found a lot of great material on forums, instructables, custom sites and blogs, but the best resource was a forum dedicated to electric vehicles which had a specific section for electric skateboards and scooters known as Endless-Sphere. From here I was able to gain insight and chat with a bunch of similarly minded DIYers who had built or were building their own electric longboards. The most common designs were a single motor setup, dual rear setup, and dual diagonal setup.

What are the differences?

Single Motor

The cheapest option to build, it’s main use is for traveling on flat ground and it is lighter due to the one motor setup. It doesn’t have as great hill riding capabilities and could burn out with too many or too long of an incline ride.

Dual Rear

This costs more than the single motor setup, and creates a size restraint on the motors since you can’t use two 63mm motors with a traditional truck. However, it allows you to ride faster, tackle more hills with less stress on the motors, and have a back-up motor in case one fails.

Dual Diagonal

Some people prefer this build over the Dual Rear because it spreads out the motorized wheels in order to give better coverage over uneven ground. The cost and performance should be relatively the same as a dual rear, but you are able to use two bigger motors for this build since you don’t have the size constraint of mounting two motors on one truck.

What do you need to build your own electric longboard?

Longboard Components

  • $20 and up – Longboard deck (there are plenty of options here, whatever floats your boat)
  • $60 – Longboard wheels (preferrably with some sort of hub that you can interface a motor pulley with, common choices are ABEC 11 Flywheels and Orangatang Kegels)
  • $50 -Longboard trucks (your choice, but I prefer the Caliber trucks since they come with decent bushings and are great stable)

Mechanical Components

  • $50 to 100 – Motor mount (Can be bought for a couple types of trucks, or made yourself and welded onto your mount or clamped)
  • $10 – Motor pulley (Can be bought for 9mm or 15mm wide belt with varying teeth. Recommended teeth are 12T, 14T, and 15T)
  • $10 – Wheel pulley (This will depend on your wheel. You can make one yourself using a CNC machine and aluminum, or you can buy one for certain types of wheels. Recommended 36T)
  • $10 – HTD5 belt (after you figure out the spacing and mounting, you’ll want to measure and buy this to fit perfectly)

Electrical Components

  • $70 – Motors (The general rule of thumb is to use a Brushless DC Outrunner motor with over 1000W and below 300 KV)
  • $110 – ESC (Electronic speed controller which determines how fast the motor should spin. Check out the VESC that is being developed specifically for electric longboards)
  • $60 – Batteries (LiPo batteries are the most common, and these are commonly used)
  • $35 – Controller (Some people used a generic RC car controller, but I went the Wiiceiver route and a Wireless Wii Nunchuck)

Total: $565 with quality parts!

Starting Development with Amazon Echo

Here’s a simple guide on how to create a Node.js app hosted in Azure that will handle your Amazon Echo‘s API calls.

amazon-echo

  1. You will want to download and install Node.js if you haven’t already.
  2. Download the code from the repository here.
  3. Create an Azure account if you haven’t already and create a new web app.
  4. Using FTP, Git, or whichever method you would like, get the code into the location for your new azure web app.
  5. Join the Amazon Developer program for the Echo and create a new Echo app. (Note: In order to use this while in development on your Echo, the account needs to be the same one that the Echo is linked to)
  6. In your App information tab:
    1. Fill out your “App Name”. This will act as your official app name.
    2. Fill out your “Spoken Name”. You will want this to be short and simple to say in order to give it the easiest time to recognize.
    3. Give your “App Version” which will need to match the info you hand back through the API.
    4. Give your “App Endpoint” which will be your Azure webapp’s URL + the api endpoint. (Example: “https://echotest.azurewebsites.net/api/echo”)
  7. In your Interaction Model:
    1. Fill out your “Intent Schema”. The intent is the name of the function, slots are parameters, and the type when “literal” will give you back the speech-to-text recognized word. More info on this here.
    2. Fill out your “Spoken Utterances”. They should be tab separated between the intent and the sample phrases. Something interesting to note is that they suggest that you provide a sample for every number of literal device phrases from min to max. (In my case from 1-3 words, thus the repetitions.) It also does not like it when you have multiple of the same literals anywhere in the file.. More info on this here.
  8. After this, set your app to be ready for testing and you are on your way!
  9. Call Alexa with your Spoken Name by saying “Alexa, open {YourSpokenAppNameHere}”
  10. Now you can say the commands that you’ve designated in both your Nodejs web app and your Amazon app declarations for your response!

If you want to make it your own, you will need to modify the Node.js back-end to respond according to the requests that you allow while also altering your intent schema and spoken utterances.