how to electrocute yourself using the internet
DESCRIPTION
A talk about the Internet of things, Arduino and JavaScript frameworks including BreakoutJS and Johnny-FiveTRANSCRIPT
HOW TO ELECTROCUTEYOURSELF USING
THE INTERNET
ALEX ROCHE
@ALEXHACKED
Tom Scott being Electrocuted as part of a PayPal charity hack.(http://www.youtube.com/embed/j_74elSiI7E)
Matt, of SI Digital, being shocked.
WHAT I'M GOING TO BE TALKING ABOUTInternet of Things
Arduino
Johnny Five
BreakoutJS
- Kevin Ashton
Today computers—and, therefore, the Internet—are almost whollydependent on human beings for information ... The problem is, people
have limited time, attention and accuracy—all of which means theyare not very good at capturing data about things in the real world ...We're physical, and so is our environment ... Ideas and information
are important, but things matter much more.
Yet today's information technology is so dependent on dataoriginated by people that our computers know more about ideas thanthings. If we had computers that knew everything there was to know
about things—using data they gathered without any help from us—wewould be able to track and count everything.
XIVELYCloud Based Service
Users send JSON, XML or CSV to a RESTful API
Amalgamates data from around the world and stores it
Data is also accessible through AJAX requests
WHAT CAN YOU USE THE INTERNET OFTHINGS FOR?
MONITORING AN ENVIRONMENTModerating the temperature in your house
Making sure you're not being broken in to
REACTING TO DATA FROM AN ENVIRONMENTPrinting out the news every morning
Flashing a light when someone enters a room ...
... on the other side of the world
BERG'S LITTLE PRINTER
PHILIPS HUE LIGHTS
MAKE THE COSMPulls from Xively based on a user defined search term
Data is updated in real time
User can use the data provided to trigger sounds
STRAVA
Gathers data about your surrounding area
Transfers this data to a server which aggregates
Server reacts to the data you post
ARDUINO
WHAT IS AN ARDUINO?Open Source
Microcontroller board with addressable GPIO pins
Various form factors depending on need
Communicates with electronics using GPIO pins
GUH-PEE-OH WHAT?General Purpose Input and Output
Can be used to receive and transmit current to electroniccomponents
Can also be used to pass messages to serial input
Are how the Microcontroller talks to the outside world
PINS ON THE ARDUINONormal pins which can be set high or low
Analogue and PWM Pins
Analogue pins which can read values between 0 and 1023
PWM Pins can be set to values between 0 and 255
WARNINGWINDOWS USERS
You will have to bypass windows security to install drivers for theArduino.
Drivers are unsigned by Arduino
As such, you will need to disable Driver Signature Checking
S.H.I.E.L.D.S.Not a comic law enforcement agency (in this case)
Add on to an Arduino which extends functionality
Can be stacked, but some care does need to be taken
S.H.I.E.L.D. REQUIREMENTSPlugs to the non-GPIO pins need to reach all shields.
Each shield will have outputs which need to be left unconnectedto.
Outputs to the Arduino need to be unique.
PROGRAMMING AN ARDUINOBreaks down in to two main types
Code that is compiled to C / C++ and uploaded to themicrocontroller
Code that communicates with the board and issues commands
BREAKOUT JS; WHAT?Javascript based framework
Can be ran in a web page
Needs Arduino to be connected to a computer
Needs a server to run on your computer
Resulting web page can be connected to from any device on thelocal network
BREAKOUT JS; HOW?Install the Firmata firmware
Open the file located in the Breakout zip in the firmware folder
Upload it to the board using any compatible IDE
BREAKOUT JS; INSTALLING THE SERVERDepends on which server you want to install; Java or Node
USING THE JAVA SERVERUnzip the folder relevant to your Operating System
MacOS, Linux, Windows x32 & x64
Run the resulting Executable
USING THE NODE SERVERInstall NodeJS
Navigate to the node_server folder in command line
Run “npm install” to install all dependencies
“node server.js” starts the server
WHAT THE API LOOKS LIKEClasses for most things you would connect to an Arduino
Mixed in amongst normal Javascript and HTML
BO and JSUTILS namespacing
BO.I2CBase, BO.IOBoard, BO.IOBoardEvent, BO.PhysicalInputBase,BO.Pin, BO.PinEvent, BO.WSocketEvent, BO.WSocketWrapper,
BO.custom.ID12RFIDReader, BO.custom.RFIDEvent,BO.filters.Convolution, BO.filters.FilterBase, BO.filters.Scaler,
BO.filters.TriggerPoint, BO.generators.GeneratorBase,BO.generators.GeneratorEvent, BO.generators.Oscillator,
BO.io.AccelerometerADXL345, BO.io.AccelerometerEvent,BO.io.AnalogAccelerometer, BO.io.BiColorLED, BO.io.BlinkM,
BO.io.Button, BO.io.ButtonEvent, BO.io.CompassEvent,BO.io.CompassHMC6352, BO.io.DCMotor, BO.io.GyroEvent,BO.io.GyroITG3200, BO.io.LED, BO.io.MagnetometerEvent,
BO.io.MagnetometerHMC5883, BO.io.PotEvent, BO.io.Potentiometer,BO.io.RGBLED, BO.io.Servo, BO.io.SoftPot, BO.io.SoftPotEvent,
BO.io.Stepper, JSUTILS.Event, JSUTILS.EventDispatcher,JSUTILS.SignalScope, JSUTILS.Timer, JSUTILS.TimerEvent
HELLO WORLD EXAMPLEvar IOBoard = BO.IOBoard;var IOBoardEvent = BO.IOBoardEvent;var LED = BO.io.LED;var Button = BO.io.Button;var ButtonEvent = BO.io.ButtonEvent;var host = window.location.hostname;// if the file is opened locally, set the host to "localhost"if (window.location.protocol.indexOf("file:") === 0) { host = "localhost";}var arduino = new IOBoard(host, 8887); arduino.addEventListener(IOBoardEvent.READY, onReady);
function onReady(event) { // Remove the event listener because it is no longer needed arduino.removeEventListener(IOBoardEvent.READY, onReady); var led = new LED(arduino, arduino.getDigitalPin(11)); button = new Button(arduino, arduino.getDigitalPin(2)); button.addEventListener(ButtonEvent.PRESS, onPress); button.addEventListener(ButtonEvent.RELEASE, onRelease); $('#btnLeft').on('click', turnLedOff); $('#btnRight').on('click', turnLedOn); }
HELLO WORLD EXAMPLEfunction turnLedOn(evt) { // Turn the LED on led.on();}
function turnLedOff(evt) { // Turn the LED off led.off(); }
function onPress(evt) { // get a reference to the button object that fired the event var btn = evt.target; $('#state').html("Button " + btn.pinNumber + " state: Pressed");}
function onRelease(evt) { // get a reference to the button object that fired the event var btn = evt.target; $('#state').html("Button " + btn.pinNumber + " state: Released");}
CONNECTING TO THE INTERNET WITH BREAKOUTJSBreakoutJS runs in a web page
Treat it like any other Javascript Library
XMLHttpRequest() is something you can use
Or jQuery.ajax() if you prefer!
No extra shields needed to extend functionality
WHAT WOULD YOU USE BREAKOUTJS FOR?Large scale hacks which need monitoring
Systems which you can adjust over an internal network
Setting the colour of lights using a colour picker
Monitoring the heating and adjusting a thermostat
Deciding which person to administer an electrical shock to
JOHNNY FIVE
JOHNNY FIVE; WHAT?NodeJS based framework
Needs the Arduino connected to the computer running JohnnyFive
JOHNNY FIVE; HOW?Upload the "StandardFirmata" Arduino example to your Arduino
Install NodeJS
Pick a directorynpm install johnny-five
WHAT DOES THE API LOOK LIKE?Creating instances of hardware objects and passing initiation
propertiesvar servo = new five.Servo(10);
servo.min(), servo.max(), servo.center(), move(deg), sweep(deg)
HELLO WORLD EXAMPLEvar five = require("johnny-five"), button, led, litBool;var board = new five.Board();board.on("ready", function() {//Once the board is ready and the callback fires, your code goes here! litBool = false; led = five.Led(13); button = new five.Button(8);
button.on("down", function() { if(litBool == false){ led.off(); }else{ led.on(); } litBool = !litBool; });
button.on("hold", function() { led.strobe(); });});
CONNECTING TO THE INTERNET WITH JOHNNY FIVEJohnny Five is just a Node package
Treat it like any other Node Library
Connecting to API's is the same as you normally would withNodeJS
No extra shields needed either!
WHAT WOULD YOU USE JOHNNY FIVE FOR?Autonomously monitoring and adjusting
Inteligently regulating an aquarium
Building a little robot to intelligently avoid walls
Letting twitter decide who to administer a shock to
The Internet of Things is already here!
No concrete definition; make it your own
We can take part with (relative) ease
BreakoutJS : Watch and control your environment
Johnny Five : Control your environment with AI
THANK YOU!I'VE BEEN;
ALEX ROCHE
@ALEXHACKED