Publicidad

Easy IoT with JavaScript

Open Source & Community Strategist
13 de Mar de 2018
Publicidad

Más contenido relacionado

Publicidad
Publicidad

Easy IoT with JavaScript

  1. Samsung Open Source Group 1 #CampOSV #InOut2018 Easy IoT with Javascript Philippe Coval Samsung Open Source Group / SRUK philippe.coval@osg.samsung.com Using FLOSS: Node.js, IoT.js, W3C and more #CampOSV Hackathon #InOut2018, Rennes <2018-03-13>
  2. Samsung Open Source Group 2 #CampOSV #InOut2018 $ who am i ● Philippe Coval from Samsung OSG – Belongs to SRUK team, based in Rennes, France – Interests: Libre Soft/Hard/ware, IoT, DIY... – Communities: Tizen, IoTivity, Automotive, Yocto... – Ask me for help online: https://wiki.tizen.org/wiki/User:Pcoval
  3. Samsung Open Source Group 3 #CampOSV #InOut2018 What is Internet of Things ? ● Any thing: – Computers, desktop, laptop, servers ● Cars are 4 wheeled computers – “Smart” personal/shared product ● TV, Mobile, Wearable, Home – Embedded systems – Low cost constrained devices ● Micro controllers ● dummy connected sensor ? ● That can be connected to : – Other things (using IP) – Or Internet ? (through a gateway) ● New word for embedded ? – Scale is really different ! ● What matters: ● Connectivity → Security ● Low Cost → Ubiquitous ● Power → Performance ● Openness → OS/Applications/Services ● Interoperability →IoT not silos!
  4. Samsung Open Source Group 4 #CampOSV #InOut2018 JavaScript history ● Hi level interpreted programming language – was influenced by Self (Smalltalk) and Scheme ● Invented in 1995 then shipped into: – Netscape 2.0 Web browser then Enterprise Server ● Standardized in 1997 – by European Computer Manufacturers Association (ECMA) ● JSON: JavaScript object model introduced in 2000 (vs XML) ● Massive adoption by Web Community and more: – 2009: NodeJS, CommonJS, 2011: WebGL NaCL, 2017: WebAssembly
  5. Samsung Open Source Group 5 #CampOSV #InOut2018 Motivations for JavaScript for IoT ● JavaScript is everywhere! – Many web developers → Many application developers ● Easy leaning curve, Faster and Lower cost of development: – Standardized and established communities ● Node.JS is the leading JavaScript runtime (based on V8 engine) – NPM repo over 500K modules ● JS Interpreter can fit even into constrained devices – Embedded devs to focus more on platforms than apps
  6. Samsung Open Source Group 6 “The secret of getting ahead is getting started.” ~ Mark Twain
  7. Samsung Open Source Group 7 #CampOSV #InOut2018 IoT Platforms, supporting JavaScript ? ● No OS (Baremetal): Optimal, low portability, slow and costly – Usually in C or Assembly ● Full featured OS? Like GNU/Linux (or derived Tizen) – Standard APIs: POSIX, Huge community: distros, packages... ● but more resource consuming: Memory, Power (on battery?), slower to boot ● Or dedicated platforms for constrained devices: – JerryScript engine featured in: IoT.js, Zephyr.js (on Linux or Zephyr kernel), RIOT ● Tizen:RT is supporting IoT.js (based on NuttX kernel) – Others JS: ducktape, Espruino, MuJS, tiny-js, v7/mjs, quad-wheel ● Alternatives: Johnny Five, CyclonJS, Ruff, Micro Python or many RTOS
  8. Samsung Open Source Group 8 #CampOSV #InOut2018 Installing IoT.js runtime ● Rebuild for OS/Hardware: – https://github.com/Samsung/iotjs/ ● Or install for Raspberry Pi 0+ – download .deb package – https://dl.bintray.com/rzr/ ● Write hello world & run it: Hello IoT.js { "env": { //... "IOTJS_ENV": "", "IOTJS_EXTRA_MODULE_PATH": "" }, "builtin_modules": { //... "platform": "linux", (...) } "iotjs": { "board": "" }, "argv": [ "iotjs", "demo.js" ], // (...) } ● cat demo.js console.log(“Hello IoT.js”) console.log(process) ● iotjs demo.js
  9. Samsung Open Source Group 9 #CampOSV #InOut2018 Connectivity and protocols ● Different contexts: – Permanent or intermittent connected ? – Single of both way channels? – Topologies & architectures: Mesh/P2P, Star, Gateway, Cloud centric... – Fixed or moving ? Wired or Radio ? ● Personal (Bluetooth, BLE, NFC), Local (Ethernet, WiFi, Zigbee, Zwave, Thread, 6loWPAN) ● City (DSL, Cellular, WiMax, 5G, LPWAN, NB-IoT, V2X), Region, Global (Sat) ● No single protocols ! – Publisher/ Subscriber: MQTT – Request/Response: HTTP/S, RESTful API, CoAP, IoTivity – Real time: plain sockets, WebSockets ● Will be somehow visible/monitored/controlled using Internet technologies (browsers, apps)
  10. Samsung Open Source Group 10 #CampOSV #InOut2018 Example: Using IoT.js’ HTTP module ● Post message to mastodon micro blogging service – Create account on: https://instances.social ● Or use nodejs’s NPM: https://www.npmjs.com/package/mastodon-lite ● Try many WebServices, APIs – Examples: Rennes OpenData, PSA’s Connected Car – https://www.programmableweb.com/apis/directory var config = { method: “POST”, hostname : 'mastodon.social', port : 443, path: “/api/v1/statuses”, headers: {...(access_token)...} } http.request(config, function(res) { receive(res, callback); }).end(); git clone https://github.com/rzr/mastodon-lite cd mastodon-lite IOTJS_EXTRA_MODULE_PATH=. iotjs main.js "Hi @TizenHelper from #IotJs"
  11. Samsung Open Source Group 11 #CampOSV #InOut2018 Physical world and Input/Output ● Analog: Measured phenomena – Physics, Chemicals, Probabilities ● Digital: States (ON/OFF) – →Several bits ● Analog↔Digital conversion – Quantification ● Time matters – Periodic (frequencies) ● Sensors and actuators ● I/O Pins – GPIO: General Input (or) Output ● Numeric: 3.3v = 1 , 0v = 0 ● Used for input: buttons, switch – or output: relay, LED, lights – PWM: Pulse width modulation ● Pulse signal (frequency) ● Used for buzzer, motors, dimmed LED – UART: Universal Asynchronous Receiver Transmitter ● Serial line: Send (TX) / Receive (RX) data ● Speed in baud (bit per second) ● Used for console, modems, peripheral MCU – I2C & SPI buses ● Used for chips (ADC/DAC, sensors, memory)
  12. Samsung Open Source Group 12 #CampOSV #InOut2018 Using generic sensors ● Easy High level abstractions of sensors for Node.js or IoT.js: git clone https://github.com/rzr/generic-sensors-lite ● + Temperature (BMPx80), gaz (MQ), accelerometer, proximity…. var ambientlight = new GenericSensors.AmbientLight({ frequency: 1 }); ambientlight.onreading = function() { console.log("log: ambientlight: " + ambientlight.illuminance); }; iotjs example log: ambientlight: 42 ... pulls bh1750 patched NPM module (for iotjs’s i2c API)
  13. Samsung Open Source Group 13 #CampOSV #InOut2018 Standards and interoperability ● Web success: – Common protocol: ● HTTP based on IP – With network neutrality – Common data models ● HTML/XML (subset of SGML) – Working implementation ● Web browsers – = Massive adoption by humans ● IoT challenges: – Interoperability between ● protocols: – Seamless connectivity – Support non IP networks ● products & API: – What is a lamp ? ● How to turn it on/off? – Easy and Reliable ● Secure & Privacy friendly
  14. Samsung Open Source Group 14 #CampOSV #InOut2018 Automotive Hackathon challenge ● Embed a computer on Vehicle – expose some vehicle data, ● RPM, sensor, position, speed, ... – to nearby devices: ● phone, tablet, others... ● Using JS & web standards – WebSockets – RESTful: ● HTTP(s), OCF/IoTivity ● Along existing FLOSS: – Avoid “Not Invented Here” (NIH) ● Automotive projects/communities: – W3C: Vehicle Information S, WoT ● https://www.w3.org/TR/ ● http://schema.org/Car – Automotive Grade Linux (AGL): ● https://www.automotivelinux.org/ – GENIVI: ● https://www.genivi.org/ – Open Connectivity: ocf-automotive ● https://wiki.iotivity.org/automotive
  15. Samsung Open Source Group 15 “Any sufficiently advanced technology is indistinguishable from magic.” ~ Arthur C. Clarke
  16. Samsung Open Source Group 16 https://fosdem.org/2018/schedule/event/tizen_rt/ DIY: mobile air quality monitor, and beyond? Demo code (WIP): https://github.com/rzr/TizenRT LoRaLoRa LoRa LoRa GPS GPS OCFOCF OCF OCF
  17. Samsung Open Source Group 17 https://fosdem.org/2018/schedule/event/tizen_rt/ Showcase: Tizen:RT, LoRaWAN, IoT.js https://youtu.be/S7zpBpnpflU#tizen-rt-lpwan-20180204rzr ● https://my.wirelessthings.be/index.php/device/device_view/1229
  18. 18 #LFALS Showcase: SmartHome+Automotive #CES2017 https://youtu.be/3d0uZE6lHvo#smarthome-ces2017
  19. Samsung Open Source Group 19 #CampOSV #InOut2018 References ● Entry points: – http://iotjs.net ● More: – https://fosdem.org/2018/schedule/track/internet_of_things/ – https://blogs.s-osg.org/?s=iotjs – http://wiki.iotivity.org/automotive ● Keep in touch online: – https://blogs.s-osg.org/author/pcoval/ – https://wiki.tizen.org/wiki/Meeting
  20. Samsung Open Source Group 20 #CampOSV #InOut2018 Thanks / Merci Contact: https://wiki.tizen.org/wiki/User:Pcoval Resources: flaticons CC
Publicidad