Physical Node.JS

Physical Node.JS
Keith Chester
[email protected]
[email protected]
@thekeithchester
Why Node.JS for hardware and IoT
• Can easily tie multiple networks together
• Event oriented infrastructure which means…
• Programming makes sense! If this then that
• One-off functionality is easy to code and host
with services like AWS Lambda
Node.JS future on hardware
Chakra by Microsoft
• Node will be making itself more engine agnostic to not be
beholden to V8
• Chakra, one such engine, is open sourced by Microsoft
• Chakra on ARM processors is priority by Microsoft,
promising high performance node.js on ARM
Three methods of control
• Direct control
• Connected control
• Indirect control / orchestration
Assuming Direct Control
CHIP
•
$9
•
Built-in WiFi and BLE
•
1GHz ARM
•
512mb RAM
•
4gb on-board storage
BeagleBone Black / Green
•
$55 / $40
•
1GHz
•
512mb RAM
•
4gb on-board storage
•
65 GPIO pins an ADC, 8 PWM pins, 4
UARTs, quadrature encoder hardware
•
2 Programmable Realtime Units (PRU)
Espruino
•
$25
•
No connectivity after detachment
•
Can be added via other
boards
Tessel 2
•
$35
•
48 MHz processor
•
64mB RAM
•
32mb on-board memory
•
Built in wifi
•
Plug and play modules
Raspberry Pi
•
$5 - $35
•
1 GHz
•
512 Mb RAM
•
No built in connectivty, but can be
added easily
•
No built in storage
Intel Edison
•
$50
•
$500 MHz Intel processer +
100MHz microcontroller
•
Probably need a breakout
•
For product development
•
Built in WiFi, BLE, memory
Fusion Gun and Nerf War
Pros
Cons
• Highest processing power
• Cost per individual
unit/device is high
• Direct code to physical
reaction
• Not real time
• Self-contained – one device,
one board
• Low level processing can be
difficult
• Limited component count
on each item
Connected Control
Serial port / USB
WiFi
BLE
Connection
Firmata firmware
installed
Johnny 5
• Firmata turns the device into a dumb pipe. Johnny 5 commands
Firmata, querying for IO status, sensor values, or outputs
• Several prebuilt modules for Johnny 5 make connecting common
modules such as servos or some sensors plug and play
The Toys
Arduinos
Sky’s the limit
ESP8266 module + dev boards
Particle Photon
Redbear
Wifi + BLE
Boards
Lightblue Bean
nRF51822 Dev Board
Barbot
Pros
• Still have the processing
power of a more powerful
host machine
• You can offload key timing
requirements onto firmata
(such as for servo/PWM)
• Still have full access to
network/internet
• Host can control multiple
Cons
• Not real time
• Response to stimulus slower
as it requires stimuli
• If the host dies, the Firmata
device continues what it
was doing. For example our barbot poured one
helluva shot
Orchestration
• The device runs separate code that
communicates over network (ie WiFi or RF) to
the host
• The node server only needs to control what
high level behaviors it expects from the
device, as well as data that needs to be shared
Example Projects
Pros
• Devices can be unaware of
each other and can be
added / removed on the fly
• Most freedom in tying
various devices and
languages/frameworks
together
• Most secure! Harder to run
arbitrary commands on
hardware
Cons
• Real time response = safer
and better motor control
• Response to stimulus slower
as it requires stimuli
• Multiple code bases
• Need to design and
program for disconnection
from the orchestration
network
MQTT
Super efficient low memory pub-sub messaging great for IoT
/topic/message
/topic/+/message
/topic/#/message
-22
Sensor
Smart Thermostat
Broker
Phone app
Packages
•
•
•
– The core module that implements
simple MQTT
– full MQTT broker (can be standalone)
- multi-transport broker – opens
REST HTTP, CoAPP, and MQTT protocols
Go start building!
THANKS!