name: inverse class: center, middle, inverse layout: true .header[.floatleft[.teal[Christopher Biggs] — Javascript Rules My Life].floatright[.teal[@unixbigot ].logo[@accelerando_au]]] .footer[.floatleft[CampJS Aug 2017]] --- name: callout class: center, middle, italic layout: true .header[.floatleft[.teal[Christopher Biggs] — Javascript Rules My Life].floatright[.teal[@unixbigot ].logo[@accelerando_au]]] .footer[.floatleft[CampJS Aug 2017]] --- layout: true class: bulletsh4 .header[.floatleft[.teal[Christopher Biggs] — Javascript Rules My Life].floatright[.teal[@unixbigot ].logo[@accelerando_au]]] .footer[.floatleft[CampJS Aug 2017]] --- template: inverse # Javascript Rules My Life ## IoT with Javascript from Chip to Cloud .bottom.right[ Christopher Biggs, .logo[Accelerando Consulting]
@unixbigot .logo[@accelerando_au] ] --- layout: true template: callout .header[.floatleft[.teal[Christopher Biggs] — Javascript Rules My Life].floatright[.teal[@unixbigot ].logo[@accelerando_au]]] .footer[.floatleft[CampJS Aug 2017]] .crumb[ # Agenda ] --- # The internet of things is a globe-spanning organism ??? * First I will define the IoT and why I quit my day job * Then I'll look at platforms from the bottom up * Along the way I'll stop to give advice on tools --- # Primitive Cells - sensors and indicators ??? Not very evolved yet. Primitive pits, coloured spots. --- # Muscles - Actuators and Appliances ??? A heckload of things that you can control now, or retrofit. Lights, tvs, hvac, appliances, security. --- # Nerves - Edge computing ??? Control the world on two dollars a year --- # Brains - Dataflow and rule engines ??? Unlike tetrapods, As many tiers as you like --- # Aliens - Siri Barada Niktu! ??? Whole exosystems out there where people are the aliens. --- layout: true template: callout .header[.floatleft[.teal[Christopher Biggs] — Javascript Rules My Life].floatright[.teal[@unixbigot ].logo[@accelerando_au]]] .footer[.floatleft[CampJS Aug 2017]] .crumb[ # Agenda # IoT+Me ] --- template: inverse # IoT and Me ??? * I want explain what excites me. * Rosie the robot - Inside out --- # Always with the gadgets ??? * 5th age - Orders of magnitude * Not stopping --- # It's gonna be the future, soon ??? * We do things to computers. * IoTs do things to/for us. * Conserve attention, extend reach --- # It's yaks all the way down ??? * What can IoT do for me? * What's a drag * Pre-mobile social * So many things to do --- layout: true template: callout .header[.floatleft[.teal[Christopher Biggs] — Javascript Rules My Life].floatright[.teal[@unixbigot ].logo[@accelerando_au]]] .footer[.floatleft[CampJS Aug 2017]] .crumb[ # Agenda # IoT+Me # Sensors ] --- template:inverse # Sensors and Indicators - the Cells of IoT ??? Very lowest level - one bit of information, in a variety of different ways. Light, pressure, contact, temperature, sound, magnetism, gravity, vapours. Motors, lights, beepers. If you put enough lights together its a screen. --- class: left .fig60[ ![37 kinds of one bit sensor](one-bit-sensors.jpg)] .spacedown[ # 37 sensors for $10] ??? Here's a bag of 37 different one bit sensors that costs about ten bucks. If you're very lucky your bag might come with some instructions that tells you which one is which. --- # No code ??? In many cases you can just plug these together to do simple things - maybe you want a light in the kitchen when you've left the garage door open. Until the 1990s this was "electronics" for most purposes. But that's not what we're here for. --- layout: true template: callout .header[.floatleft[.teal[Christopher Biggs] — Javascript Rules My Life].floatright[.teal[@unixbigot ].logo[@accelerando_au]]] .footer[.floatleft[CampJS Aug 2017]] .crumb[ # Agenda # IoT+Me # Sensors # Microcontrollers ] --- template: inverse # Microcontrollers ## You had **one** job ??? Nowadays we use microcontrollers costing a few bucks to replace bespoke circuits. --- .fig80[ ![Microcontrollers](microcontrollers.jpg)] .spacedown[ # Single-board computers] ??? A microcontroller is a whole computer - processing, memory, mass storage, IO shrunk down to a single chip. They get programmed once and and do that one simple job for the rest of their lives. I'll come back to those later. --- # A supercomputer in every kitchen ??? At a certain level of complexity there's a fuzzy border Thank those Newfangled Radio Telephones, and Cable TV. Huge volumes of chips literally more powerful than an 80s supercomputer. Side effect: powerful computers for a case of beer. I mean VB. --- # Almost no code ??? It used to be common to say that programming was a doomed craft, that computers would improve to the point where ordinary people can get them to do many tasks by connecting boxes or just speaking. Well, while we were sleeping it happened. --- layout: true template: callout .header[.floatleft[.teal[Christopher Biggs] — Javascript Rules My Life].floatright[.teal[@unixbigot ].logo[@accelerando_au]]] .footer[.floatleft[CampJS Aug 2017]] .crumb[ # Agenda # IoT+Me # Sensors # Microcontrollers # Node-RED ] --- template: inverse # Tinkerlude 1: Node-RED ??? * A project of the IBM Emerging technology group * Visual system for wiring the internet of things * Flow based data processing * Integrated dashboarding * Javascript (duh) --- .fig80[ ![Front door flow](nodered-frontdoor.png)] .spacedown[ # Open Sesame] ??? * an example to give you flavour * all the key concepts - inputs, messages, formatting, outputs * Node library at left * Tab bar at top * Deploy Button * Orange==Javascript --- .fig30[![](blynk_dashboard_home.png) ] .fig30[![](ui_dashboard_home.png) ] .spacedown[ #Dashboard Awesomesauce] ??? Monitor environment, security, power usage Control lighting, ventilation, blinds etc Web and App control panels (incl mobile) --- # Select **nodes** from palette ??? So whats the process. Nodes are npm modules. Nodes take an input, and produce one or more outputs. --- # Connect nodes into **flows** ??? Flows programs. Save as JSON, organise into libraries --- # **Messages** travel through networks ??? A message is a json object, typically a topic and a payload. External message systems as senders or recipients. Input nodes - events or timers --- .fig80[ ![slack](slack_hooks.png)] .spacedown[ # A **lot** of nodes.] ??? * 800+ node modules. * Inputs output obs. * Messages, databases * Signal processing * Social Media- --- layout: true template: callout .header[.floatleft[.teal[Christopher Biggs] — Javascript Rules My Life].floatright[.teal[@unixbigot ].logo[@accelerando_au]]] .footer[.floatleft[CampJS Aug 2017]] .crumb[ # Agenda # IoT+Me # Sensors # Node-RED # Appliances ] --- layout: true template: callout .header[.floatleft[.teal[Christopher Biggs] — Javascript Rules My Life].floatright[.teal[@unixbigot ].logo[@accelerando_au]]] .footer[.floatleft[CampJS Aug 2017]] .crumb[ # Agenda # IoT+Me # Sensors # Microcontrollers # Node-RED # Appliances ] --- template: inverse # Appliances - multicellular organisms ??? Our increasingly strained analogy --- # Smart appliances will be ubiquitous ## ...but ??? So what's the big deal about node-red Samsung at CES Everything will be a computer --- ## The future is an app list scrolling under a human thumb # Forever ??? One app per lightbulb Node-red to the rescue A visual tool for wiring the internet of things --- .fig50[ ![](esp32.png)] .spacedown[ # But her wires...] ??? But about those wires. Maybe you want to spend your beer money on beer instead of wire. I bet you drink too much coffee, too. So lets look at coffee-class computers with built in wifi. Created for lightbulbs. Beloved of hackers. --- layout: true template: callout .header[.floatleft[.teal[Christopher Biggs] — Javascript Rules My Life].floatright[.teal[@unixbigot ].logo[@accelerando_au]]] .footer[.floatleft[CampJS Aug 2017]] .crumb[ # Agenda # IoT+Me # Sensors # Node-RED ] --- layout: true template: callout .header[.floatleft[.teal[Christopher Biggs] — Javascript Rules My Life].floatright[.teal[@unixbigot ].logo[@accelerando_au]]] .footer[.floatleft[CampJS Aug 2017]] .crumb[ # Agenda # IoT+Me # Sensors # Microcontrollers # Node-RED # Appliances # Mongoose OS ] --- template: inverse # Tinkerlude 2: Mongoose OS ??? Lots of choices for microcontrollers. Java was created for toasters but doesn't. Javascript on the other hand. --- .fig80[ ![](mos1.gif)] .spacedown[ # Enter the Mongoose (OS)] ??? * Supports four different CPUs * Simple real time OS with internet * Toolchain on Linux, MacOS, Windows * Web IDE, plus command-line tools * Integrated with AWS and Google IoT * Code in C --- # IoT in Javascript ??? or Javascript --- # IoT in Javascript ## (but not as we know it) ??? * Micro Javascript * An ES6 subset * a very small subset! 25k FLASH, 1k RAM. * No standard library, but * Dead easy calls to the MOS C stdlib * Lots of javascript objects that wrap popular IoT blocks --- class:left # Familiar looking code .hugecode[ ```javascript Timer.set(1000, true, function(arg) { let now = ffi('unsigned long mg_time()')(); let topic = Cfg.get('device.id') + '/event/close'; let message = JSON.stringify({ time: now }); }, null); ``` ] ??? Objects, callbacks --- # Sorry, no promises ??? No promises But lots of other goodness. --- # Cut the 90/90 rule in half ??? As we know the first 90% takes the first 90% of the time... Device setup, Field updates, Key enrolment, API framework, Message services, Library managment, Log viewing --- # "We have both kinds" ??? Really rare to have a nice IDE **and** good CLI tools. --- # Two click enrol in AWS and Google IoT ## (or one command) ??? Mongoose is moving fast. New features every week. Talks to Google over their google pubsub Talks to AWS IoT (also standard MQTT). AWS is MQTT with a twist. What happens if your device is offline. --- # Cloud-hosted rules engine ??? When a message with TOPIC A (and PAYLOAD B) arrives, do ACTION C --- # What if I don't want that? ??? Node red. --- # What can rules do? ??? * Database inserts * Push notifications * Re-queue * S3 operations * Lambda functions --- layout: true template: callout .header[.floatleft[.teal[Christopher Biggs] — Javascript Rules My Life].floatright[.teal[@unixbigot ].logo[@accelerando_au]]] .footer[.floatleft[CampJS Aug 2017]] .crumb[ # Agenda # IoT+Me # Sensors # Microcontrollers # Node-RED # Appliances # Mongoose OS # Serverless ] --- template: inverse # Tinkerlude 3: Serverless Framework ??? Lambda is amazon's FAAS. No server cost, your code is deployed and scaled at need. Pay per-call - good when devices often idle. 1M free calls/y forever* --- # Save time letting someone else handle the servers ## Spend it lost in AWS instead ??? The promise of serverless computing is relieving the hassle. Unfortunately AWS. --- # So outsource your no servers ??? The solution to not having any servers is to outsource not having any servers. --- # Serverless.com ## A simple cross platform FAAS tool ??? Code in a bunch of languages. Incl JS Deploy to a bunch of platforms. I've only used AWS + JS --- # ...with a complex ecosystem ??? Compiles a simple config down to a cloud-formation stack, which orchestrates setup of the AWS services. Lots of plugins --- # One-shot deploy ??? User interface (in ELM), REST api, IOT rule actions, all in one chunk Automate it push-to-play --- .fig60[ ![Slacker Toast](slacker_toast.jpg)] .spacedown[ # Slacker toast ## (or tweety toaster)] ??? Lets you do things like this Device talks uses mongoose-OS to talk to AWS AWS posts to slack or twitter. --- ![Stop Traffic](traffic_lights.jpg) .spacedown[ # Stop traffic] ??? Or this A slack message filter hits a webhook in your Lambda Lambda updates IoT shadow Device changes state --- # Documentation could be better ??? Moving fast, not all plugins work. Documentation presumes you understand the underlying platform well --- # Testing is tricky ??? * So here are some tricks It can be time-consuming to test, so separate your functions into testable parts, wrapped in platform cruft. Mocha plugin, generates tests. --- # One more thing ??? Greengrass brings lambda to your raspberry pi ("edge computing") Whoops turns out the cloud doesnt' solve everything. --- layout: true template: callout .header[.floatleft[.teal[Christopher Biggs] — Javascript Rules My Life].floatright[.teal[@unixbigot ].logo[@accelerando_au]]] .footer[.floatleft[CampJS Aug 2017]] .crumb[ # Agenda # IoT+Me # Sensors # Microcontrollers # Node-RED # Appliances # Mongoose OS # Serverless # Voice ] --- template: inverse # War of the Walled ## (gardens, that is) ??? Last thing I want to talk about is the home frameworks. You want to be able to control your home from your phone, or your Fine if you have all new kit --- # Amazon Echo / Alexa ## direct api support, lots of Node-RED bridges ??? Make your non-amazon gear alexa-capable. Develop IoT rules that invoke or respond to alexa. Alexa not on sale here, but job ads for strine speakers --- # Google Home / OK Google ## Official nodeJS API ??? Some APIs closed, but just last month a coder worked out how to plumb google home to NodeRED. On sale in AU last month. --- # Apple Homekit / Siri ## Closed protocol, reverse-engineered Homebridge app ??? In the apple world the news is good. Their ecosystem contains support for bridges that proxy homekit protocol to non-homekit devices. Protocol reversed oss bridge Control anything, including mongoose apps doing mqtt. Hey Siri, Turn off the damn tv. No hub needed. Voice hub November. --- layout: true template: callout .header[.floatleft[.teal[Christopher Biggs] — Javascript Rules My Life].floatright[.teal[@unixbigot ].logo[@accelerando_au]]] .footer[.floatleft[CampJS Aug 2017]] .crumb[ # Agenda # IoT+Me # Sensors # Microcontrollers # Node-RED # Appliances # Mongoose OS # Serverless # Voice # Coda ] --- template: inverse # Recap ## Node-RED, Mongoose OS, Serverless, Homebridge ??? Node-RED - control almost anything Mongoose-OS - tiny edge computing devices Serverless - Low(er) pain Lambda Homebridge - smuggle your legacy or homebrew devices into the walled garden --- .fig70[ ![Electronics for dogs](electronics_for_dogs.gif)] .spacedown[ # What now? ] ??? * Remember, on the internet. If dogs can do it * Ones and zeros are red wire black wire * It's pretty much Lego bricks with wires --- .fig60[ ![Starter kit](iot_starter_kit.jpg)] .spacedown[ # Take Chances, Make mistakes ## (Eat mints) ] ??? * Do you like mints? * Don't panic, read blog.unixbigot.id.au --- template: inverse # I have opinions. ## Ask me about your IoT, DevOps and Big Data hassles ??? I have opinions. Expensive to dispose of, please take some. --- # Accelerando.com.au seeking Elmist, et.al ??? I run a really full stack team. Chips to cloud. Virtual company. Is that you? --- class: bulletsh4, left, tight .left[ ## Resources, Questions #### Article (and shopping list): [IoT For Absolute Beginners](http://blog.unixbigot.id.au/2016/09/iot-for-absolute-beginners.html) #### Related talks - [http://christopher.biggs.id.au/#talks](http://christopher.biggs.id.au/#talks) - [IoT for Slackers](http://christopher.biggs.id.au/talk/2016-10-05-iot-for-slackers-yowconnected/) - [Control your home with Homebridge](http://christopher.biggs.id.au/talk/2016-12-03-homebridge-brisjs/) - [IoT in 2min with Mongoose OS](http://christopher.biggs.id.au/talk/2017-07-02-iot-in-two-minutes/) #### Me - Christopher Biggs - Twitter: .blue[@unixbigot] - Email: .blue[christopher@biggs.id.au] - Slides, and getting my advice: http://christopher.biggs.id.au/ - Accelerando Consulting - IoT, DevOps, Big Data - https://accelerando.com.au/ ] ??? Thanks for coming along today, I'm happy to take questions in the few moments remaining and I'm here all weekend if you want to have a longer chat, or take a closer look at some gadgets. Over to you. --- class: bulletsh4, left .left[ ## Suppliers * China (cheap but slow) - [AliExpress.com](http://aliexpress.com) - See the shopping lists on [my blog](http://blog.unixbigot.id.au/2016/09/iot-for-absolute-beginners.html) * Australia - [Little Bird Electronics](http://littlebirdelectronics.com.au) - [Tronixlabs](http://tronixlabs.com.au) * USA - [Adafruit](http://adafruit.com) - [FriedCircuits](https://www.tindie.com/products/FriedCircuits/nodemcu/) ]