Pages

Wednesday, January 15, 2020

Getting started with Serverless and Alexa development



(Image Credit/Source: Amazon Blog)

More and more I see myself tinkering around with serverless development.

To get started, I had to decide what I was going to use for development, so I started with installing node.js.

Node.js is available for multiple operating systems and can be downloaded here.

Once I downloaded node.js, I used npm to install serverless, e.g.:

npm install -g serverless

I set up my credentials using the following command:

serverless config credentials --provider aws --key AKexampleKey --secret wJalrexampleSecret

You can also install the ask (Alexa Skills Kit) cli using npm:

npm install -g ask-cli

As I plan on doing Alexa skill development, I need to associate my AWS profile with my Alexa development profile.  Excellent documentation provided by AWS can be found here.

I initialized the ask cli with the AWS account (using a key and secret set up previously):

ask init --aws-setup

I then associate the Amazon Developer account with the ask cli:

ask init

We can now start to create our Alexa skill and any associated Lambda functions that would be called as part of the skill, e.g.: ask new and ask deploy.



Wednesday, January 1, 2020

re:invent 2019 - IoTanium by Onica: Connecting

If you've been following along in the IoTanium journey, I was able to unbox and assemble my IoTanium Dev Kit.  I will be following the additional setup instructions and verifying that everything works in the online IoTanium documentation.

So the first thing I did was to power up and connect the dev kit to a USB power supply.  The keyboard USB on my mac keyboard was able to successfully power the device, so I just went with that.


I then cloned their preview repository by executing: git clone -b preview https://github.com/onicagroup/iotanium.git

Now that I have a copy of the repo on my hard drive, I first connected to the wifi of the IoTanium dev kit and then opened up iotanium/webrepl/webrepl.html from the downloaded repository.

There's a password for both the wifi and establishing a connection to it.  Please review the online IoTanium documentation for what that password is (link above).


The IoTanium device actually uses MicroPython, which seems to be use in other IoT devices like the BBC micro:bit.  While the micro:bit is advertised for students, I believe it could be useful for anyone wanting to learn Python programming for microcontrollers.

At any rate, I need to configure the IoTanium Dev Kit to connect to my home network, which is done via the iotanium_cfg.json file (file is located in the iotanium/ folder).  A quick "vi" to update the config and upload the config file to the dev kit and a click of the Disconnect / Connect button along with reconnecting to my home network and I was successfully connected via my home network instead of the IoTanium wifi.  This now allows the IoTanium Dev Kit to get "online" - e.g. to AWS and other services.




Now that the dev kit can reach the Internet - it's time to configure a connection to AWS.  Heading over to AWS console, I navigate to IoT Core.


Once at AWS IoT, I click on Secure then Certificates to generate new certificates.


I click on "Create Certificates" using the "One-click certificate creation".  Advanced IoT shops may manage their own certificates and simply upload a CSR.


You will get a notification that the certificates are created.  Download "A certificate for this thing" and "A private key".  You can download "A public key" and the Amazon Root CA key as well if needed for your implementation. (I did not as I'm just following the instructions and testing the dev kit out.)


You will need to create a policy, e.g. define what a device with this certificate can do so click on the "Create new policy" button.


Add the authorization to publish and connect to iot.




Don't forget to attach the newly created policy to the certificate that you created previously if AWS doesn't attach it automatically as part of the certificate creation process.  This is a step that I see people commonly missing in IoT lab exercises.

I also make a note of my endpoint that I'll be sending to.



I modified the hello_world.py file (located in the /iotanium folder) with my endpoint, uploaded the python file and the certificate / key and then I ran the program.


Ouch.  Failure.  It seems like the program was sending a message every 5 seconds.  I noticed that the performance of the ESP32 microcontroller is a bit slow (e.g. when I type something into the web terminal page, it sometimes "lags").  So I adjusted the message send rate in hello_world.py from 5 seconds to 15 seconds and success!


Over in AWS Console, subscribe to the topic 'iotanium'.


The messages successfully showed up in the Test console.


Stay tuned for my next blog post where I take a closer look at the dev board and start connecting some electronics to it.

-brian

Note: I am not being compensated by Onica / Rackspace for this blog post, nor does this post constitute an endorsement of this product by me or my employer.  I share my experiences in the hopes of educating and informing others about Internet of Things (IoT).

re:invent 2019 - IoTanium by Onica: Unboxing and Assembly

I attended re:Invent 2019 at Las Vegas, NV and one of the vendors, Onica, had a chance to win their IoTanium Dev Kit by (1) making motions and capturing that motion; (2) upload the captured motion to a ML algorithm to (3) generate a model with the captured motion and associate that with movement and action to then (4) play a game and make motions / actions that would move an avatar in the game.

So after 3 tries, I finally completed the exercise.  I was most likely not consistent in my motions and it was hard for the model to understand what I was trying to accomplish.  But I did it! :)

As a result, I received a t-shirt and their IoTanium Dev Kit.  I thought in this post I'd capture the unboxing of the Dev Kit and then in subsequent blog posts, show some projects that can be completed with this Dev Kit.

The Dev Kit comes in a basic black box, filled with parts and electronic bits for assembly.


Upon opening the box, I am greeted immediately with instructions for construction.  You will need a Phillips screwdriver to complete the assembly.


Two main pouches are in the box, one with the microcontroller dev board and the breakout board, the other with a breadboard, screws, risers and some electronics.


Here we have the microcontroller (ESP32) and the breakout board.  The goal with Onica providing this dev kit is that it adds an easy way to connect sensors and other external devices to the ESP32.  And then the breakout board enables simple connectivity to a breadboard (shown later).


From the 2nd parts bag I removed the risers and the screws that will be used to assemble the two boards.


Always check to make sure that you have a correct inventory when assembling something (saves from frustration later - in this case all the pieces were there).



I used the female riser along with a screw and attached it to the dev board.  Note that the pins will need to be on the bottom (for connectivity to the breakout board).


Completed assembly of the female risers and the associated screws.


Completed assembly of the dev board (flipped over) to show how the pins will be inserted into the breakout board.


Connecting the dev board to the breakout board.  It takes a firm push to have the pins seated.


Then I took the remaining 4 male risers and screwed the boards together.


Completed assembly of the dev board and breakout board.


Take the time to make sure the pins are lined up with each of the sockets in the breadboard.  I had one pin that was slightly bent so I had move it to the correct spot and then I was able to successfully push the breakout board pins into the breadboard.



Completed assembly and then I opened the electronics bag to see what I would be working with from a project standpoint.


This completes the unboxing and assembly of the Onica IoTanium Dev Kit.

Stay tuned for my next blog post where I connect the dev board to AWS IoT.  Future posts will include a walkthrough of the features of the dev board, connecting electronics to the board and discussing potential applications.

-brian

Note: I am not being compensated by Onica / Rackspace for this blog post, nor does this post constitute an endorsement of this product by me or my employer.  I share my experiences in the hopes of educating and informing others about Internet of Things (IoT).