z

Communicating with Internet of Things

door Peter Martin / @pe7er

Joomladay UK 2017 in London,
Saturday July 8th 2017

About me


Peter Martin (@pe7er)




Lent (Nijmegen-Noord), Netherlands

About me

www.db8.nl
Joomla support & development

Options Manager (paid)
(batch) Export / Import "Options" of Components, Plugins, Modules and Template Styles

Free version: Options Manager Lite supports only Components

Organizes:
* Linux Usergroup Nijmegen
* Open Coffee Nijmegen

Joomla volunteer:
* Global Forum Moderator
* Joomla! Operations
   Department Coordinator
* Mentor GSoC 2016 + 2017

* Joomla Bug Squad
* Pizza Bugs & Fun (in NL)

* former Joomla Community
   Leadership Team (6 yr)

Overview Presentation

  • Internet of Things (IoT)
  • My IoT “project”
  • MQTT
  • Demo



Questions preferably after the demo

Presentation: http://slides.db8.nl
IoT code: https://github.com/pe7er/db8iot

1. Internet of Things (IoT)

“The Internet of Things (IoT) is
a network of devices that are connected to each other using TCP/IP
and communicate autonomously.
#IoT #JaB16
@pe7er (exactly 140 characters)

Be Careful!

We all know what happened in the movie “The Terminator

Application to boost IoT?

Samsung Family Hub Refrigerator
5,999.99 USD

Smarter FridgeCam
99.99 GBP

Self-ordering Fridge:
not for me!

Arduino

Microcontroller

ESP8266

Wifi chip

Add Wifi to Arduino

ESP8266
- low-cost: £ 0.99 GPB (eBay)
- full TCP/IP stack
- connects to a Wi-Fi router

Problem 1: Communication:
Hayes-style "AT" (modem)


Problem 2:

Chinese documentation

Pins of ESP8266-01

GPIO: General-purpose
input/output

Input
Sensors
   - temperature
   - movement
   - sound
   - light
   - touch / push button
   - pressure

Output
Signals
    - light (LED)
    - switch (Relay)
    - sound
    - screen

ESP8266

No need for Arduino microcontroller
programme & flash chip on ESP!

- Software Development Kit (SDK)
- esp-open-sdk (GCC toolchain)
- NodeMCU + LUA scripts

- Arduino IDE + ESP8266WiFi library !

2. My IOT “project”

ESP8266 pins too close for gutter

Bridging the gutter

USB to TTL Serial interface

Flashing the ESP8266

Temperature sensor

Connect to ThingSpeak.com (RESTFull)

48 hours later... drained battery

MY IOT “project”


all 1-to-1 communication

all RESTFull
(need Webserver; can be heavy)

And Now For Something Completely Different...

Some Message Protocols

6LoWPAN (IPv6 over Low power Wireless Personal Area Networks). DASH7 active RFID. MyriaNed wireless sensor network (WSN) platform. Z-Wave wireless communications protocol for home automation. ZigBee for personal area networks with small, low-power digital radios. Low-Power Wide-Area Network (LPWAN). Thread protocol for household devices to communicate on a network. Matrix open protocol for real-time communication. Constrained Application Protocol (CoAP) used for very simple electronics devices. AMQP (Advanced Message Queuing Protocol). STOMP (Simple (or Streaming) Text Oriented Message Protocol). MQTT (MQ Telemetry Transport).

3. MQTT

- messaging protocol
- publish/subscribe

- simple + lightweight
- layer on TCP/IP


(IBM) “MQ Telemetry Transport”
Official standard: ISO/IEC PRF 20922

“WhatsApp for machines”


WhatsApp Server = Broker (server)

WhatsApp Group = Topic

Member of Group = Subscriber

Post in Group = Publish to Topic

Topics

Topic name: hierarchically structured with forward slashes

Examples of topics:

house/kitchen/temp
house/livingroom/light
house/livingroom/temp
house/bathroom/temp
garage/temp

Wildcards in Topics


Single level: +
house/+/temp

house/kitchen/temp
house/livingroom/light
house/livingroom/temp
house/bathroom/temp
garage/temp

Wildcards in Topics


Multi level: #
house/#

house/kitchen/temp
house/livingroom/light
house/livingroom/temp
house/bathroom/temp
garage/temp

MQTT Security

Authentication

Access to MQTT Broker

- Username + Password

- X509 Client Certificate
(Public/Private Keys)

- OAuth 2.0

Authorization

Control MQTT resources

- Allowed topics

- Allowed operation
(publish and/or subscribe)

- Allowed QoS

Secure communication

Secure communication
between client & broker

- Secure connection
   Transport Layer Security (TLS)
    MQTT over SSL / TLS (using Let’s Encrypt)


- Secure message
   MQTT Payload Encryption

What's needed for MQTT ?

MQTT Broker Services

ThingSpeak.com

io.adafruit.com

CloudMQTT.com

List of
publically-accessible
MQTT brokers

(for testing and prototyping)


MQTT Broker for Linux


Mosquitto
An Open Source MQTT v3.1/v3.1.1 Broker







MQTT Client for PC

MQTT.fx (Java)
for: Windows, Apple, Linux, Unix







MQTT Client for Smartphones


MyMQTT
MQTT Client
MQTT Dashboard


MQTT Tester
ICPDAS MQTT
MQTTInspector


M2Mqtt

MQTT Client Arduino / ESP8266

Code editor: Arduino IDE v1.6.9
+ esp8266 v2.2.0 library installeren
to flash ESP board



to use MQTT + esp8266 in C++ code:
add libraries PubSubClient + ESP8266WiFi
and add in C++ code::

// include MQTT library
#include <PubSubClient.h>
// include ESP8266
#include <ESP8266WiFi.h>

MQTT Client scripts

Python:
Mosquitto module


PHP:
bluerhinos/phpMQTT










4. Demo

Sorry,

I do not have sheets for the demo...
You had to be there!


There is a video available from this
Joomla World Conference 2016 presentation at YouYube.


Or check out the video from
JandBeyond 2016 (European Joomla conference).

Thank you!


Presentation:
http://slides.db8.nl

IoT code:
https://github.com/pe7er/db8iot


Peter Martin
e-mail: info at db8.nl
twitter: @pe7er
presentation: https://db8.nl

Photo Credits 1/2

Photo Credits 2/2