Internet of things

JaxNode User Group June 2014
By David Fekke

Upcoming events

Code on the Beach in August

Nush

Node Users Social Hour

JSCONF recap

  • Lots of Javascript and Node topics
  • 3 tracks
  • One breakout day
  • Lots of creators and inventors were there
  • Run by Chris Williams of Node Source,
    inventor of Node-Serial
  • Companies presenting included Google, Facebook, Microsoft, Fidelity, Bithound, Mozilla, Paypal, Twilio and Sauce Labs

DISCLAIMER

  • Please recite the following oath with the presenter
  • If I _state_your_name_ electrocute myself after trying to replicate something from this presentation, I swear that neither I nor any loved ones or members of my extended family will sue this presenter pursuant to all Federal, state and local laws, including those in international and intergalactic jurisdictions.   

IoT

  • Internet of Things
  • This is about wanting to program hardware
  • The components for building your own hardware has become very inexpensive
  • Getting to the point where almost any device can have its own IP address

The internet is everywhere

  • Desktop Computers
  • Mobile devices
  • Smart watches
  • Wi-Fi enabled microcontrollers
  • Thermostats, Nest
  • Refrigerators, (SAMSUNG)

Microcontrollers

  • Not computers
  • Write programs as firmware
  • Some come with Wi-Fi
  • Inputs and outputs
  • Digital and Analog
  • Not enough power to stream video or audio
  • Wire up servos, lights, sensors, speakers and cameras
  • Power robots

Arduino


  • Introduced in 2005
  • Connect to USB
  • 12 Digital pins, 6 Analog
  • All kinds of shield modules
  • Firmware written in C, C++

Spark Core


  • Wi-Fi chip built-in
  • ARM processor
  • Always connected cloud service
  • Web based IDE, C and C++
  • New node compatible firmware

ESPrUINO


  • Introduced in 2013
  • Javascript based microcontroller
  • Does not run V8 or node
  • Does not have Wi-Fi, but can be added
  • 72Mhz ARM microcontroller with
    256KB of Flash memory and 48KB of RAM

Tessel


  • Released June 2014 supposedly
  • Runs Node code
  • Has modules, reduces the need to solder or breadboard
  • Wi-Fi CC3000 built into board
  • Modules include Servo interface, GPS, GPRS, Bluetooth, accelerometer, climate, camera, infrared and SD Card reader

Netduino


  • Modeled after Arduino
  • Runs .NET code
  • .NET micro framework
  • Can use this with Linux and Mac OS X

Raspberry PI


  • Full computer with ARM processor
  • Runs different versions of Linux
  • HDMI output, 2 USB ports, Ethernet
  • GPIO digital ports, no analog ports
  • Model a/b, 256 and 512 MB RAM
  • Runs Node.js

Many others

  • Most boards and standard firmware are open source
  • Many knockoffs of the Arduino, ATMega chip
  • ARM Microprocessors are becoming common
  • Common to see these on Kickstarter
  •  Intel Edison SoC will run Node.js 70 pins

Arduino code

  • Requires void setup() and void loop() methods
// Pin 13 has an LED connected on most Arduino boards. // give it a name: int led = 13; // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. pinMode(led, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }


Johnny-five

  • Rick Waldrons framework for controlling microcontrollers
  • Pre-built modules for different boards, buttons, gyros, IR, Led, motor, pin, relay, sensor, servo, sonar and steppers
var five = require("johnny-five"), 
                board = new five.Board();

            board.on("ready", function() {

            var servo = new five.Servo({
                pin: 12, 
                type: "continuous"
            });

            // Clockwise, top speed.
            servo.cw(1);
            });

JS Language support

  • Many languages supported through tethering
  • Firmware usually written C
  • Chris WIlliams created Node-serial
  • Many NPM modules written for interfacing with controllers
  • Johnny-five written by Rick Waldron
  • Cylon.js also popular
  • Arduinos will use Standard Firmata firmware
  • Spark Cores will use Voodoo firmware
  • Tessels support Node natively through Lua

Why use javascript

  • Most microcontrollers run inside of a run loop
  • Requires break and interrupt logic
  • Difficult to do more than one thing at a time
  • Javascript is more accessible than  C or C++
  • Javascript is asynchronous, and can do multiple things at the same time inside of a single thread
  • Javascript is the best language for programming robots
  • NPM libraries make programming different kinds of hardware easy

electrical engineering for dummies

  • V = I R
  • Voltage = Current x Resistance
  • Albert Einstein said that the fact that this equation is so simple, it was proof that there was a God
  • 5 Volts considered standard voltage for most electronics
  • There is a push to make 3.3 Volts the standard
  • Check the tolerance of your microcontroller, some will go as high as 12 or 15 Volts
  • If you burn something out, these things are cheap
  • Test your circuits on a breadboard, then solder 
  • Check max amps, and find correct resister
  • Please unplug from a power source while wiring

Breadboard


hopefully this demo won't
make your HEAD Explode




Questions

?

Contact me

  • David Fekke
  • email me at David Fekke at gmail dot com
  • On Skype as my first name and last name as one word
  • Twitter @davidfekke and @jaxnode
  • Thanks for coming out tonight
  • Once again, please don't electrocute yourself and sue me