Saturday, June 4, 2016

NodeBots Day-1: Getting the Environment Ready - Windows

For our "NodeBots Day" activity we are going to follow the "Johnny-Five" guide.  I feel that there is enough material to get the meetup started.  Johnny-Five is a JavaScript Robotics and Internet of Things (IoT) platform.

Pre Requisites

To be able to run the exercises we need:
  1. Install Node.js and NPM.
  2. Install Johnny-Five
  3. Arduino Software IDE
  4. Optionally install a Code Editor
    1. Visual Studio Code is excellent:  recommended over Notepad++, Notepad and even Sublime
      1. Visual Studio Code has a GIT dependency therefore you will need to install Git on your station.  Install Git Bash...  you'll love it!
  5. You might need to install Python and make sure it is included in the path in the case of Windows OS

Quickly

What is Node?  It is a server side platform built on Google's Chrome JavaScript engine (V8 Engine).  As we advance in our journey you will be exposed to other fantastic things that we can do with Node including:
  • Asynchronous
  • Event Driven
  • Very fast!
  • Single thread but it is very scalable
  • It is open source!
To install Nodejs, follow the link provided in this note and select the appropriate version for your system.  If you are using the Window installer make sure that you select to include NPM.  'npm' is the Nodejs package manager and we are going to install required modules using it.

What is Johnny-Five?
As previously mentioned; it is a JavaScript Robotic and IoT development platform.  Its is community based, open source.

Once you have installed Node with npm you can install Johnny-Five.  On my git bash window it looks like this:


Great!  We are almost there!  Next we need to install the Arduino IDE.

Do I really need the Arduino Software?
Well, no.  If you do not have an Arduino board you do not really need the software and instead you could run the Nodebot-Workshop, which provides a "stubbed" Arduino board for testing each workshop challenge...  but we have boards, and we are going to have these boards around so, you can do either!

Taking the path of the real thing requires a bit more work.  We need a protocol to communicate with the board.  Arduino provide this software and it is called "StandardFirmataPlus".


O load the firmata you need to go "File > Examples > Firmata > StandardFirmataPlus".  Once the firmata loads you need to upload it to the board by clicking the "upload" arrow.  This might not work.  I am not sure why this error is "out there".



To get rid of it you need to open the header file "SerialFirmata.h" and go to line 31 and comment the include "#include "



Save the file and upload again.  It should work now.  If it does not then write a comment here and we'll work it out together.

You are almost there!

Why do I need Python installed? 
We need Python because there are a few modules that need to be built for the specific platform.  We might not need it right away, but we will for sure.

Which programming language are we going to be using?  Can I use C for Arduino?
We are using Node, which is JavaScript.  Yes you are right, you could use a C like language for Arduino but in our meetup we are doing Node.

How do I know that I am ready to "go"?  How do I know that everything is ready?
That is a good question and it will depend on a variety of factors including:

  • Operating System
  • Version of Node
  • Version or Arduino and firmware
The classic "Hello World" for the board is the "Blink-Blink" program:


Testing "Blink-Blink"

Assume your board is ready to go.


and you try to run your code after loading the firmata and...  what!?


This was difficult to troubleshoot.  The solution to this "bug" is to explicitly indicate that the Arduino board, in my case, was connected to port COM4 and this was indicated passing a configuration object into the Board construction function.


Run again and smile!  You are on your way.  This is actually documented by Johnny-Five.  What johnny-Five says is that the platform will try to determine the port, however, the port could also be explicitly set, like we did above. 

We are going to make sure that every one can run this exercise on the available boards.

I will document this same setup for Ubuntu in a part 2.  I will add references to this note a little later, but I will publish it now so some of your can get going.

In our meetings we will try to cover as much as possible the examples posted by the Johnny-Five guide.

References



No comments:

Post a Comment

A1 Repo: Simple Pagination for WCF Service Operation

It is never a good idea to paginate on the client.  This post is about a simple pagination for a WCF service operation.  For this work I nee...