O'Reilly logo
live online training icon Live Online training

Fundamentals of IoT with JavaScript

Developing Node.js and HTML5 applications for IoT on Raspberry Pi

Leon Anavi

This course will show you how to build simple IoT solutions that will help you to understand how this technology works. You will explore the IoT solution stack, and will also see how to build solutions with Raspberry Pi, JavaScript and Node.js.

In today's age, it's important for any developer to possess the ability to interconnect and control Internet of Things (IoT). This course helps in impacting this knowledge using low-cost hardware, popular technologies and programming languages which are already well-known widely used for web development.

What you'll learn-and how you can apply it

By the end of this live online course, you'll:

  • Get to know the concepts of Internet of Things
  • Set up development environment and connect peripherals to Raspberry Pi
  • Connect remotely to Raspberry Pi using SSH client
  • Get started with Node.js on Raspberry Pi
  • Develop Node.js application for controlling LEDs connected to GPIO pins of Raspberry Pi
  • Develop Node.js application for reading output from tactile buttons connected to GPIO pins of Raspberry Pi
  • Develop Node.js application for reading temperature and humidity from HTU21D I2C sensor module connected to Raspberry Pi
  • Learn basics of the MQTT machine-to-machine protocol for communication between IoT
  • Install and set up MQTT broker on Raspberry Pi
  • Create web page with HTML5, JavaScript and Paho library for publishing and subscribing to MQTT topics through web sockets.
  • Get to know the concepts of ASP.Net MVC and build a new static web page using HTML, CSS, and jQuery

And you'll be able to:

  • Learn the basics for using the GNU/Linux distribution Raspbian on Raspberry Pi
  • Develop and deploy Node.js applications for IoT
  • Use the MQTT messaging protocol for real-time communication with IoT
  • Create HTML5 web page with web sockets for reading data from sensors for temperature and humidity

This training course is for you because...

  • This course is aimed at web developers, students and open source enthusiasts interested in learning cutting-edge technologies and leveraging their skills and knowledge for building Internet of Things.

Prerequisites

  • Basics of JavaScript
  • Basic familiarity with GNU/Linux distributions and Raspberry Pi

Materials, downloads, or supplemental content needed in advance:

  • Raspberry Pi 3 Model B or Model B+
  • microSD card class 10 (8GB or more)
  • Raspberry Pi peripherals: HTU21D I2C sensor module, ANAVI Traffic Lights and ANAVI Buttons, USB keyboard and HDMI monitor
  • USB power supply (5V/2.5A)
  • Apart from Raspberry Pi (with power supply, keyboard, mouse and monitor), the following specific hardware is required for the labs:
    • Option A) ANAVI Edu Kit, https://www.tindie.com/products/anavi/anavi-edu-kit
    • Option B) HTU21D sensor module (Adafruit offers it at https://www.adafruit.com/product/1899), breadboard, tact momentary buttons, red, green and yellow 5mm diffused LED, 3x 330 Ohm resistors, male to male, male to female and female to female jumper wires

Apart from Raspberry Pi (with power supply, keyboard, mouse and monitor), the following specific hardware is required for the labs:

About your instructor

  • Leon Anavi is an open source enthusiast and a senior software engineer. He is an active contributor to various open source software and hardware projects. His professional experience includes embedded Linux as well as web and mobile application development.

    Leon holds a masters in Information Technology from the Technical University Sofia. He is the author of the Tizen Cookbook printed by Packt Publishing. His previous speaking experience includes talks about open source software and hardware during events in San Francisco, Portland (OR), Hong Kong, Shanghai, Shenzhen, Brussels, Berlin, Bratislava, Prague, Sofia and his hometown Plovdiv.

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

Day 1

Section 1: Introduction to Raspberry Pi (30min)

  • A brief history of Raspberry Pi
  • Raspberry Pi versions and models
  • Raspbian GNU/Linux distribution
  • Peripheral devices and add-on boards for Raspberry Pi

Lab 1: Installing Raspbian on Raspberry Pi 3 (30 min)

  • Download, install to microSD card, boot and configure Raspbian GNU/Linux distribution on Raspberry Pi. Enable serial console output and I2C through raspi-config. (30 min practice)

Section 2: Introduction to Node.js (30 min)

  • What is Node.js?
  • What is NPM and how to use it?

Lab 2: Getting started with Node.js on Raspberry Pi (30 min)

  • Download and install Node.js on Raspberry Pi 3. Create a simple “Hello World” application and run it. (20 min practice)
  • Break (10 mins)

Section 3: LED (30 min)

  • Understanding how LED works
  • Wiring a LED to Raspberry Pi
  • Using the WiringPi library in Node.js for making a blinking LED
  • Lab 3: Making a traffic light with Node.js on Raspberry Pi (30 min)
  • Attach an add-on board with red, green and yellow LED to Raspberry Pi 3. Write Node.js applications that changes the colors of the traffic lights. (30 min practice)

Section 4: Buttons (30 min)

  • Understanding how a button works
  • Wiring a button to Raspberry Pi
  • Detecting when a button has been pressed with WiringPi and Node.js
  • Lab 4: Controlling buttons with Node.js on Raspberry Pi (30 min)
  • Attach an add-on board with several buttons to Raspberry Pi 3. Write Node.js applications that prints different text messages in the console when certain button is pressed. (30 min practice)

DAY 2

Section 5: Sensors (30min)

  • Finding sensors for Raspberry Pi
  • Exploring communication bus systems for controlling hardware peripherals attached to Raspberry Pi: 1-wire, I2C, I2S, SPI, UART, etc.
  • Deep diving in I2C communication bus system
  • Exploring HTU21D I2C sensor module for temperature and humidity

Lab 5: Reading temperature from HT21D with Node.js (30 min)

  • Enable I2C on Raspberry Pi, attach HTU21D I2C sensor module to Raspberry Pi and write a node.js application for reading temperature and humidity (30 min practice)

Section 6: MQTT (1h)

  • Exploring messaging protocols for real-time communication between Internet of Things
  • Introducing MQTT (messages, brokers, topics, wildcards, QoS, security, etc.)
  • Exploring open source MQTT brokers
  • Implementing MQTT client in Node.js
  • Break (10 mins)

Lab 6: Getting started with MQTT on Raspberry Pi (30min)

  • Installing Mosquitto MQTT broker on Raspberry Pi, writing Node.js application for publishing temperature from HTU21 I2C sensor, writing Node.js application for subscribing to MQTT topic and receiving data (1h)

Section 7: Web Sockets (30min)

  • Introducing the Paho Project
  • Understanding how web sockets work
  • Receiving and sending data through MQTT over web sockets directly from a web browser

Lab 7: Integrating it all together (1h)

  • Creating a web server with Node.js and HTML5 web page for showing temperature data from multiple HTU21D with a web socker and JavaScript. Publish MQTT messages to change the color of the traffic lights when a button is pressed on another Raspberry Pi (1h)