Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Monsters, brievenbussen en andere onzin @ Domot...

Niels Leenheer
September 05, 2017

Monsters, brievenbussen en andere onzin @ DomoticaGrunn

Tegenwoordig kun je allerlei ‘Internet of Things’ apparaten in de winkel kopen. Hue lampen, Sonos speakers en nog veel, veel meer. Aan en uit zetten van lampen met een app is een leuk nieuwtje, maar niet zo praktisch en wordt al snel saai. Als developer en all-round geek vind ik het leuk om te spelen met nieuwe technologie, maar ook vooral om te kijken hoe alles werkt onder de motorkap en dingen te bedenken die net even niet mogelijk zijn met de app van de fabrikant.

Deze presentatie gaat over het combineren van sensoren, switches en displays met verschillende technologieën om problemen op de lossen die eigenlijk helemaal niet zo belangrijk zijn. Veel belangrijker, om gewoon lol te hebben met IoT en gewoon geeky dingen maken. Deze presentatie bevat monsters, veel monsters.

Niels Leenheer

September 05, 2017
Tweet

More Decks by Niels Leenheer

Other Decks in Technology

Transcript

  1. #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) { }
  2. 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); }
  3. 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(); }
  4. ?

  5. 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(); }
  6. 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(); }
  7. 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 })); } }
  8. 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 })); } }
  9. 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 }; } }
  10. 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 }; } }
  11. De was is klaar! De was is klaar! De was

    is klaar! De was is klaar!
  12. De was is klaar! De was is klaar! De was

    is klaar! De was is klaar!
  13. commandArray = {} if (uservariables['WasmachineBezig'] == 2) then s =

    uservariables_lastupdate['WasmachineBezig'] lastUpdate = os.time{ year=string.sub(s, 1, 4), month=string.sub(s, 6, 7), day=string.sub(s, 9, 10), hour=string.sub(s, 12, 13), min=string.sub(s, 15, 16), sec=string.sub(s, 18, 19) } difference = os.difftime (os.time(), lastUpdate) if (difference > 300) then commandArray['Variable:WasmachineBezig'] = '0' commandArray['OpenURL'] = 'pixel.local/api?command=notify&icon=shirt' end end return commandArray