Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
HOW I GOT BACK
MY CODING MOJO!
Mark West
#iottechday
What	is	Mojo?
IoT Tech Day Coding Mojo slides.  Utrecht, April 2016
IoT Tech Day Coding Mojo slides.  Utrecht, April 2016
IoT Tech Day Coding Mojo slides.  Utrecht, April 2016
“Any	application	that	can	be	
written	in	JavaScript,	will	
eventually	be	written	in	
JavaScript”
James	Atwood	(founder,	 	stackoverflow.com)
IoT Tech Day Coding Mojo slides.  Utrecht, April 2016
IoT Tech Day Coding Mojo slides.  Utrecht, April 2016
NodeBot Rover
NodeBot Rover	Demo
https://vimeo.com/162426456
NodeBot Rover	Component	Overview
Hardware
Computer
Micro	
Controller
Camera
Chassis
Pan	&	Tilt
Software
Speech
Robot	
Control
Web	
Server
Integration
Other
The	Arduino Ecosystem
• MicroController platform.
• Many	different	Arduino
models.
• Open	Source	design.
• MicroControllers extensible	
via	“Shields”.
Putting	the Hardware	Together
IoT Tech Day Coding Mojo slides.  Utrecht, April 2016
IoT Tech Day Coding Mojo slides.  Utrecht, April 2016
IoT Tech Day Coding Mojo slides.  Utrecht, April 2016
Two Servos
for	Camera
Pan	&	Tilt
Servos wired
to	Arduino
Chassis
Raspberry PI	
In	Plastic Case
WIFI	Dongle
Raspberry PI	
Camera
Wired directly
to	the
Raspberry PI
Actuators
Sensors
Nervous System
Raspberry	PI	2Raspberry	PI	Cam
Arduberry Microcontroller Arduino Chassis Servo
Servo
Brain
NodeBot Rover	Hardware
Combining the Raspberry PI	&	Arduino
Raspberry PI
• Linux	PC.
• Supports	USB	peripherals.
• Programming.
ArduinoPlatform
• MicroController.
• Robust.
• Native	analogue support.
The	whole is	greater than the sum	of parts!
Actuators
Sensors
Nervous System
Raspberry	PI	2Raspberry	PI	Cam
Arduberry Microcontroller Arduino Chassis Servo
Servo
Brain
NodeBot Rover	Hardware
NodeBot Rover	Component	Overview
Hardware
Raspberry	
PI
Arduberry
(Arduino)
Pi	Cam
Zumo
Chassis
Servos
Software
Speech
Robot	
Control
Web	
Server
Integration
Other
Raspberry	PI	2
Arduberry
Servo
Software	Communication	across	
Hardware	Layers
Servo
Raspberry PI	 Chassis
JavaScriptPI Binary (Compiled C	/	C++)
The	NodeBots Movement
Source	:	nodebots.io
IoT Tech Day Coding Mojo slides.  Utrecht, April 2016
1. Maturity
2. Community
3. DSL
4. Portability
5. Open	Source
6. Node.js ecosystem
7. REPL
Benefits	of	using	Johnny-Five
Imports	J5	Dependancy
Adds LED	instance to	REPL
Declares LED	as	connected to	UNO	Pin	13
Blinks	LED	every 500	milliseconds
Code	block triggered by	UNO	”Ready”	Event
Initialises UNO
Johnny-Five	Code	Example
var five = require("johnny-five");
var myBoard = new five.Board();
myBoard.on("ready", function() {
var myLed = new five.Led(13);
myLed.blink(500);
this.repl.inject({
replLed: myLed
});
});
Johnny-Five	REPL	Demo
https://vimeo.com/134953425
Arduberry
Servo
Bridging	the	gap	with	Firmata
Servo
Raspberry PI	 Chassis
Johnny-Five
(Firmata Client)
Std.	Firmata
(Firmata Server)
JavaScriptPI Binary (Compiled C	/	C++)
IoT Tech Day Coding Mojo slides.  Utrecht, April 2016
Getting	Started	with	Johnny-Five
1. Buy	an	Arduino Experimenters	Kit.
2. Follow	the	tutorials	at	http://node-ardx.org.
3. Visit	http://johnny-five.io for	more	
information	and	inspiration.
NodeBot Rover	Component	Overview
Hardware
Raspberry	
PI
Arduberry
(Arduino)
Pi	Cam
Zumo
Chassis
Servos
Software
Speech
Johnny-
Five
Web	
Server
Integration
Other
Speech	Recognition	Requirements
Need	to	have
• Quality	and	speed	of	
speech	recognition.
• Free,	no	restrictions.
• Software	based.
• JavaScript.
Nice	to	have
• Speech	to	text.
• One	stop	service.
• Battle	tested.
IoT Tech Day Coding Mojo slides.  Utrecht, April 2016
IoT Tech Day Coding Mojo slides.  Utrecht, April 2016
Web	Speech	
API
(limited	to	Google	Chrome)
Web	Speech	API	:	Configuration
Web	Speech	API	:	Events
Web	Speech	API	:	Control
Speech	Demo
See	https://vimeo.com/162426456 for	an	
example	of	the	speech	recognition	in	progress.
Button	press	and	release	connected	to	
Web	Speech	API	start and	stop Control	
methods.
Continuous	dictation	switched	on,	to	avoid	
cutting	commands	short.	
Interim	results	switched	on	– shown	in	
green	text	(final	results	in	white).
Each	set	of	results	checked	for	uniqueness	
to	avoid	sending	duplicate	commands	to	
the	Robot.
Web	Speech	API	:	
Robot
NodeBot Rover	Component	Overview
Hardware
Raspberry	
PI
Arduberry
(Arduino)
Pi	Cam
Zumo
Chassis
Servos
Software
HTML5
Speech
Johnny-
Five
Web	
Server
Integration
Other
IoT Tech Day Coding Mojo slides.  Utrecht, April 2016
Node.js
Express	Web	
Server
(17	lines	of	code)
NodeBot Rover	Component	Overview
Hardware
Raspberry	
PI
Arduberry
(Arduino)
Pi	Cam
Zumo
Chassis
Servos
Software
Speech
Johnny-
Five
Express
Integration
Other
Johnny-Five	
Process
Express	
Process
Raspberry PI	2
WE
Browser
HTTPS
NodeBot
Rover
Hardware
Firmata
Johnny-Five	
Process
Express	
Process
Raspberry PI	2
WE
Browser
HTTPS
NodeBot
Rover
Hardware
Firmata
MQTT
Message	Broker
MQTT
MQTT	over	
WebSockets
Commands
Acknowledgements
MQTT.js
Client
MQTT.js
Client
Why Add a	Message	Broker?
• Seperation of
concerns.
• Isolate main
components for	
easier testing.
MQTT	– MQ	Telemetry Transport
• Internet of Things	connectivityprotocol.
• Designed to	be	lightweightwith a	small footprint and	little
overhead.
• Is	a	protocoland a	Pub-Sub	Message	Broker.
• Used	by	Facebook for	pushing updates to	mobile	clients.
Adding MQTT	to	the NodeBot Rover
Broker
• Public	MQTT	Broker
– ManyPublic	Brokers	exist.
– One	less	process to	run	on
RaspberryPI.
Client
• MQTT.js
– Provides an	MQTT	client
libraryfor	Node.js.
– Extremelysimple	to	use.
– Integrates seamlesslywith
Johnny-Five.
MQTT.js (Node.js)	Client	Example
MQTT	Over	WebSockets with MQTT.js
• MQTT.js is	a	Node.js package and	is	
meant for	use on the Server	Side.
• To	allow MQTT.js to	run	from	the
Browser,	we first	needed to	
”Browserify”	the MQTT	library.
• We could then access the
”Browserified”	MQTT	client library
from	the Browser.
• This	solution requires that your MQTT	
Broker	has	a	WebSocket endpoint.
MQTT	Over	WebSockets Demo
Demo	of	the	HiveMQ WebSocket Client
http://www.hivemq.com/demos/websocket-
client
NodeBot Rover	Component	Overview
Hardware
Raspberry	
PI
Arduberry
(Arduino)
Pi	Cam
Zumo
Chassis
Servos
Software
HTML5	
Speech
Johnny-
Five
Express
MQTT	&	
WebSocket
Other
Node.js Twitter Client
• Fully fledged Twitter Client:
– Asynchronous.
– Supports	REST	API	(read and	write)
– Supports	Streaming API	(eventsand	tweets).
• Requires developer credentials from	Twitter:
– Trivial	to	get hold	of.
Node.js Twitter	Client	REST	Example
Video	Streaming via	Motion
• Motion:	Software	Motion	Detector.
• Provides streaming video	with possibility to	create
snapshots.
• Good performance on the Raspberry PI.
• Potential side	project:	get Robot	to	follow moving objects?
IoT Tech Day Coding Mojo slides.  Utrecht, April 2016
NodeBot Rover	Component	Overview
Hardware
Raspberry	
PI
Arduberry
(Arduino)
Pi	Cam
Zumo
Chassis
Servos
Software
HTML5	
Speech
Johnny-
Five
Express
MQTT	&	
WebSocket
Twitter &
Motion
So	Did I	Get My	
Coding Mojo
Back?
IoT Tech Day Coding Mojo slides.  Utrecht, April 2016
Controlling	a	Parrot	Drone	with	
Motion	Detectors	and	JavaScript
https://vimeo.com/137264033
IoT Tech Day Coding Mojo slides.  Utrecht, April 2016
IoT Tech Day Coding Mojo slides.  Utrecht, April 2016
“please rate my talk in the offical
IoT Tech Day app”
@markawest

More Related Content

IoT Tech Day Coding Mojo slides. Utrecht, April 2016