1 of 38

J On The Beach, Malaga�24. May 2018�Slides: bit.ly/iot-jotb2018

 Prototyping products for the_

 Internet of Things_� using JavaScript_

2 of 38

  • pronoun.is/he
  • 20+ years of experience�software developer, consultant, coach, mentor, and founder
  • clean code ✨⌨ & lean culture 🏢🔨 �Software Crafter: softwarecrafters.org
  • Senior R&D Engineer at Nordic Semiconductormoved to Trondheim, Norway in July 2017
  • Connects things to the Internet�serverlesss JavaScript on AWS, building nrfcloud.com
  • Twitter: @coderbyheart

3 of 38

 What qualifies me to talk about IoT + JavaScript?_

  • If you think you want to talk about something �you are passionate about�you are already a step further than 99%.
  • Write a proposal — 99.9% don’t.�See speaking.io for great resources on how to get started.
  • Submit to conferences that cover travel expenses #paytospeak�and have a good Code of Conduct.�If they don’t, ask why!
  • 2018.trondheimdc.no

You!

anything you want!

4 of 38

 Disclaimer_

JavaScript

is the best

programming language

5 of 38

 Give-a-way!_

 Tweet a picture of the talk to_ � @NordicTweets and @coderbyheart_� to win one of two limited edition Thingy:52!_

6 of 38

 Why developing IoT_� products matters ..._

7 of 38

 IoT will be really big_

8 of 38

 Key Growth Factors_

  • IIoT (Industrial IoT)
  • Smart Cities
  • Connected Health
  • Consumer: Connected Cars / Smart Utilities / Wearables

9 of 38

 2018 is different_

 LTE-m / NB-IoT is a Game Changer_

10 of 38

11 of 38

 No more Wifi hassle_

Set Up Your Dash Button Device

To get started with your Dash Button device, you’ll need the latest version of the Amazon app on your Android phone or iPhone.

To connect your Dash Button device to Wi-Fi and complete the setup process, you’ll need the latest version of the Amazon app for Android phone (running OS 4.1 or greater) or iPhone (running iOS 8.3 or greater). To learn more about the Amazon app, go to About the Amazon Shopping App.

Tip: You can download or update the Amazon app on your Android or iPhone mobile browser, go to Amazon app.

Tip: https://www.amazon.co.uk/getapp in your Android or iPhone mobile browser to download or update the Amazon app.

Make sure you use your Wi-Fi network, or the network you’d like to use to upload items to your cart, when registering Dash Button devices.

12 of 38

 No more Wifi hassle_

Register Your Dash Button Device

To set up and register your Dash Button device:

  1. Ensure Wi-Fi and Bluetooth are enabled on your phone.
  2. Open the Amazon app and sign in to your account if prompted.
  3. Tap the Menu icon within the Amazon app, and then select Your Account.
  4. Under Dash Devices, select Set up a new device. If prompted to choose a device type, select Dash Button.
  5. Read the terms and conditions. If you agree to them, tap Agree & Get Started.
  6. Follow the prompts to connect the dash button to Wi-Fi.
  7. Select the product you’d like to reorder with your Dash Button device.�Example: If you are setting up a Dash Button device for a brand of laundry detergent, you can select the scent and size of detergent you’d like during this step.
  8. Confirm your 1-Click shipping and payment information. Your Dash Button device uses this information each time you please an order.�Tip: To modify your 1-Click shipping and payment information, visit Manage Addresses and 1-Click Settings
  9. Tap Complete Setup to complete setup.

13 of 38

 Cellular IoT (LTE-m / NB-IoT)_

Connectivity Revolution: from LAN to WAN.

  • Longer battery life (up to 10 years)
  • Better coverage�(inside buildings / underground)
  • smaller module size
  • lower costs

14 of 38

 IoT?_

15 of 38

 Industrial IoT_

Mesh networks

16 of 38

 This is exciting..._

17 of 38

 … but also so much to learn._

18 of 38

 Prototype Products!_

  • customers expect cloud-connected products today
  • especially consumers, but business customers as well
  • today successfull companies are building �connected experiences, not just appliances
  • as developers we need to �develop smart devices that �integrate in complex business processes�and interact with each other

19 of 38

ONE DOES NOT SIMPLY

RUN JAVASCRIPT

ON AN EMBEDDED DEVICE

20 of 38

 Why not?_

21 of 38

22 of 38

23 of 38

 JavaScript increases velocity_

  • JavaScript is supported by the most platforms
  • great tooling and developer experience
  • shared knowledge across the entire stack
  • share tools, quality standards, metrics
  • developers can easier switch teams
  • remove separation between teams
    • PHP folks: backend
    • JavaScript folks: frontend

24 of 38

 Full Stack JavaScript: IoT Edition_

Cellular�(ARM)

Gateway�(BCM, ...)

BLE�(ARM, ESP)

Internet

BLE�(ARM, ESP)

25 of 38

 JavaScript on Embedded Hardware_

  • Moddable (GPL 3.0, LGPL 3.0, Apache 2.0, and CC BY 4.0)
    • ESP8266 (32-bit Tensilica Xtensa Diamond Standard 106Micro, 80 MHz)
  • Johnny-Five (MIT license)
    • Arduino (all models), Electric Imp, Beagle Bone, Intel Galileo & Edison, Linino One, Pinoccio, pcDuino3, Raspberry Pi, Particle/Spark Core & Photon, Tessel 2, TI Launchpad and more!
  • Zephyr.js (JerryScript)
    • Arduino 101 (32-bit Intel Curie, 32 MHz)
    • nRF52 (32-bit ARM Cortex M4-F, 64MHz)
    • FRDM-K64F (32-bit ARM Cortex M4F, 120 MHz)
    • STM32F4-Discovery (32-bit ARM Cortex-M4, 168 MHz)
    • OLIMEX-STM32-E407 (32-bit ARM Cortex-M4, 168 MHz)

26 of 38

 JavaScript on Embedded Hardware_

  • JerryScript / IoT.js: JS Foundation (Apache License 2.0)
    • STM32F4-Discovery (32-bit ARM Cortex-M4, 168 MHz)
    • Raspberry
      • Pi 2 (32-bit ARM Cortex-A, 900 MHz)
      • Pi 3 (64-bit ARM Cortex-A53 SoC, 1.4GHz)
    • Samsung ARTIK 053 (32-bit ARM Cortex R4, 320 MHz)
  • Other VMs for embedding JS

27 of 38

 Prototyping_� Cellular IoT products_� with Wifi_

28 of 38

 JavaScript on ESP8266: Espruino_

  • espruino.com
  • Open-Source Hardware and Software (CC BY-SA/MPLv2)
    • ARM Cortex M3, M4 (64-100 MHz)
  • Supports many third party hardware modules
  • Very nice Web-IDE allows for fast feedback cycles
  • Espruino Wifi (ARM Cortex M4, 100Mhz)
    • Micro USB, WiFi activity LED, Red and Green LEDs and General purpose Button
    • 512kB Flash, 128kB RAM
    • 21 GPIO pins: 20 PWM, 8 ADC, 1 USART, 3 SPI and 2 I2C (Arduino compatible)
  • Price: ~35 €

29 of 38

 JavaScript on embedded:_� the syntax you love!_

30 of 38

 Connecting ..._

31 of 38

 Meet the protocol for IoT: MQTT_

  • mqtt.org: very lightweight messaging protocol
  • current version: 3.1, next version: 5 (because 3.1 used int: 4)
    • Error codes, \o/
  • supported by all major cloud providers
    • scales to many devices (AWS: billions)
  • widely used
    • e.g. at Facebook for Messenger
  • very simple to use, implementations exist for all languages

32 of 38

 MQTT 1x1_

  • Device connects to Broker
    • unsecured … username:password … TLS v1.2 with certificates
  • Subscribe:
    • single topic, e.g. foo/bar/baz (don’t use leading slashes)
    • wildcards: foo/+/bar or foo/#
  • Publish
    • anything to a single topic (no wildcards)
    • data published is transparent to broker
    • QoS: At most once (0), At least once (1), Exactly once (2)
  • Test-Broker: test.mosquitto.org

33 of 38

 Did you know? _

  • AWS IoT: super-cheap websocket server
  • $1 / Million Messages
  • 10,000 devices, 15 minutes each hour for 30 days: $8.641

34 of 38

 MQTT vs HTTPs_

  • Performance
    • uses significantly less (50x) network packages1
    • much faster on high-latency networks (e.g. 93x faster on 3G)2
    • reduced power consumption (up to 20% less)3
  • Features not available in plain HTTPs
    • Assured delivery
    • Retained messages
    • Last will & testament
    • Multiple subscriptions ‘multiplexed’ over one connection

35 of 38

 Demo!_

36 of 38

 Source Code 

github.com/coderbyheart/iot-proto-js

  • NFC Reader to Slack
    • Espruino program
  • IoT Display
    • Espruino program
    • Serverless Stack for API Gateway and Lambda
    • API client

37 of 38

 Questions?_

P.S.: We are hiring! bit.ly/iot-trd

38 of 38

 Rate this talk!_