Monsters, mailboxes and other nonsense

A presentation at Front-Trends 2017 in May 2017 in Warsaw, Poland by Niels Leenheer

Slide 1

Slide 1

monsters, mailboxes and other nonsense

Slide 2

Slide 2

Slide 3

Slide 3

a new home

Slide 4

Slide 4

Slide 5

Slide 5

Slide 6

Slide 6

Slide 7

Slide 7

10 meters

Slide 8

Slide 8

the house 
 of the future

Slide 9

Slide 9

Slide 10

Slide 10

433MHz

Slide 11

Slide 11

Slide 12

Slide 12

Slide 13

Slide 13

IoT is actually incredibly boring

Slide 14

Slide 14

raspberry pi with domoticz

Slide 15

Slide 15

Slide 16

Slide 16

chicken thermostat

Slide 17

Slide 17

brrrr!

Slide 18

Slide 18

kippenwaterdrinkbak (chicken water trough )

Slide 19

Slide 19

kippenwaterdrinkbakverwarmingselement (chicken water trough heater)

Slide 20

Slide 20

kippenwaterdrinkbakverwarmingselementschakelaar (chicken water trough heater switch)

Slide 21

Slide 21

kippenwaterdrinkbakverwarmingselementschakelaarthermometer (chicken water trough heater switch thermometer)

Slide 22

Slide 22

Slide 23

Slide 23

rfxcom

Slide 24

Slide 24

every 30 seconds a “ping” with the temperature

Slide 25

Slide 25

temperature below zero → turn on the heater

Slide 26

Slide 26

turn remote switch on

Slide 27

Slide 27

“It’s above 
 freezing, 
 water trough 
 heating 
 turned off”

Slide 28

Slide 28

The “S” in IoT stands for security

Slide 29

Slide 29

Slide 30

Slide 30

the fiery 
 witch kettle

Slide 31

Slide 31

Do-it-yourself IoT

Slide 32

Slide 32

brains (or microcontrollers)

Slide 33

Slide 33

Arduino Uno 
 ATmega238 
 16 Mhz 
 2 KB RAM 
 32 KB Flash

Slide 34

Slide 34

ESP-01 
 ESP 8266 
 80 Mhz 
 128 KB RAM 
 512 KB Flash 


Slide 35

Slide 35

NodeMCU 
 ESP 8266 
 80 Mhz 
 128 KB RAM 
 4 MB Flash 


Slide 36

Slide 36

NodeMCU

Slide 37

Slide 37

Neopixel 
 24 serial 
 connected 
 WS2812 RGB 
 LEDs

Slide 38

Slide 38

#include <Adafruit_NeoPixel.h> #define PIN D1

#define PIXELS
24 Adafruit_NeoPixel strip = Adafruit_NeoPixel (PIXELS, PIN, NEO_GRB + NEO_KHZ800 ); void

setup ( void ) {

strip. begin (); strip. setBrightness (255); strip. setPixelColor (0, strip. Color (0, 0, 255)); strip.show(); }

void

loop ( void ) {

}

Slide 39

Slide 39

int i = 0; void

setup ( void ) {

strip. begin (); strip. setBrightness (255); }

void

loop ( void ) {

i = (i + 1) % PIXELS; strip. setPixelColor (i % PIXELS, strip.Color(0, 0, 0)); strip. setPixelColor ((i + 1) % PIXELS, strip.Color(0, 0, 63)); strip. setPixelColor ((i + 2) % PIXELS, strip.Color(0, 0, 127)); strip. setPixelColor ((i + 3) % PIXELS, strip.Color(0, 0, 195)); strip. setPixelColor ((i + 4) % PIXELS, strip.Color(0, 0, 255)); strip.show();

delay (8); }

Slide 40

Slide 40

JavaScript? And C? 
 Kinda the same. Just about. 
 Not quite. No.

?!

Slide 41

Slide 41

IKEA SOMMAR 2017 lantern

Slide 42

Slide 42

Slide 43

Slide 43

Slide 44

Slide 44

Slide 45

Slide 45

Slide 46

Slide 46

WiFi must be very complicated…

Slide 47

Slide 47

const char * ssid = "........" ; const char * password = "........" ; ESP8266WebServer server(80); void

setup ( void ) {

WiFi.begin (ssid, password); while ( WiFi.status () != WL_CONNECTED) delay (500); server. on ( "/on" , { server. send (200, "text/plain" , "on" ); } ); server. on ( "/off" , { server. send (200, "text/plain" , "off" ); } ); server. begin (); }

void

loop ( void ) {

server. handleClient (); }

Slide 48

Slide 48

http://sparkle.local/api? command=power&status 
 command=power&on 
 command=power& off command=brightness&status 
 command=brightness& set=50 command=color&status 
 command=color& set=f34d0d

Slide 49

Slide 49

homebridge homebridge-better-http-rgb

Slide 50

Slide 50

siri

Slide 51

Slide 51

pixel monsters

Slide 52

Slide 52

Prolight 12W ceiling lamp

Slide 53

Slide 53

Slide 54

Slide 54

Neopixel 
 64 serial 
 connected 
 WS2812 RGB 
 LEDs

Slide 55

Slide 55

Slide 56

Slide 56

SD card Storage of monsters Buzzer Beeps for notifications Lightsensitive resistor Night-mode

Slide 57

Slide 57

Slide 58

Slide 58

Slide 59

Slide 59

Slide 60

Slide 60

Slide 61

Slide 61

Slide 62

Slide 62

Slide 63

Slide 63

Slide 64

Slide 64

Slide 65

Slide 65

are you kidding? yeah that's fine can I take it with me on a plane?

Slide 66

Slide 66

Slide 67

Slide 67

progressive 
 web app

Slide 68

Slide 68

http://pixel.local

Slide 69

Slide 69

http://pixel.local

Slide 70

Slide 70

Slide 71

Slide 71

editor.addEventListener('touchstart', handleTouch); editor.addEventListener('touchmove', handleTouch); function handleTouch(e) {

for (var i = 0; i < e.changedTouches.length; i++) 

{

    let elem = document.elementFromPoint( 
        e.changedTouches[i].pageX, 
        e.changedTouches[i].pageY 
    ); 
     
    if (elem.tagName && elem.tagName == 'TD' && 


 editor.contains(elem)) 


{

        drawPixel(elem); 
    

}

}

e.preventDefault(); 

}

Slide 72

Slide 72

editor.addEventListener('touchstart', handleTouch); editor.addEventListener('touchmove', handleTouch); function handleTouch(e) {

for (var i = 0; i < e.changedTouches.length; i++) 

{

    let elem = document.elementFromPoint( 
        e.changedTouches[i].pageX, 
        e.changedTouches[i].pageY 
    ); 
     
    if (elem.tagName && elem.tagName == 'TD' && 


 editor.contains(elem)) 


{

        drawPixel(elem); 
    

}

}

e.preventDefault(); 

}

Slide 73

Slide 73

let socket = new WebSocket( "ws://" + window.location.host + "/ws" ); function drawPixel(elem) {

if (elem.dataset.color != currentColor) 

{

    elem.dataset.color = currentColor; 
    elem.style.backgroundColor = '#' + currentColor; 
    socket.send(JSON.stringify(

{

        command:    "draw",  
        x:          elem.dataset.x,  
        y:          elem.dataset.y,  
        color:      currentColor  
    

} ));

}

}

Slide 74

Slide 74

let socket = new WebSocket( "ws://" + window.location.host + "/ws" ); function drawPixel(elem) {

if (elem.dataset.color != currentColor) 

{

    elem.dataset.color = currentColor; 
    elem.style.backgroundColor = '#' + currentColor; 
    socket.send(JSON.stringify(

{

        command:    "draw",  
        x:          elem.dataset.x,  
        y:          elem.dataset.y,  
        color:      currentColor  
    

} ));

}

}

Slide 75

Slide 75

{ 
 "command": "draw", 
 "x": 5, 
 "y": 5, 
 "color": "ffffff" 
 }

Slide 76

Slide 76

{ 
 "command": "draw", 
 "x": 5, 
 "y": 5, 
 "color": "ffffff" 
 }

Slide 77

Slide 77

Slide 78

Slide 78

Slide 79

Slide 79

Slide 80

Slide 80

socket.onmessage = function(msg) {

let data = JSON.parse(msg.data); 
if (data.command == "draw")  

{

    let elem = document.querySelector( 
        'td[data-x=' + data.x + ']' + 


 ' [data-y=' + data.y + ']' );

    elem.dataset.color = data.color; 
    elem.style.backgroundColor = '#' + data.color 

} ;

}

}

Slide 81

Slide 81

socket.onmessage = function(msg) {

let data = JSON.parse(msg.data); 
if (data.command == "draw")  

{

    let elem = document.querySelector( 
        'td[data-x=' + data.x + ']' + 


 ' [data-y=' + data.y + ']' );

    elem.dataset.color = data.color; 
    elem.style.backgroundColor = '#' + data.color 

} ;

}

}

Slide 82

Slide 82

demo

Slide 83

Slide 83

the mystery 
 of the 
 haunted mailbox

Slide 84

Slide 84

   mail      box

Slide 85

Slide 85

magnetic contact

Slide 86

Slide 86

when the mailbox opens it sends a signal

Slide 87

Slide 87

http://pixel.local/api?command=notify&icon=mailbox

Slide 88

Slide 88

Slide 89

Slide 89

Slide 90

Slide 90

Slide 91

Slide 91

solution #1 combine the 
 magnetic contact 
 with a motion sensor?

Slide 92

Slide 92

solution #2 turn off the 
 magnetic contact with 
 strong westerly winds?

Slide 93

Slide 93

solution #3

Slide 94

Slide 94

Slide 95

Slide 95

thanks! questions? 
 
 @html5test