Ceci est une ancienne révision du document !
Digital Systems for Humans - Technological Challenges in IoT (DS4H-IoT)
Pedagogical Approach for this course is learning-by-doing and then conceptualizing .
After a brief introduction, the first step of this course is practicing with use cases and exercices on a specific IoT Infrastructure called YoIoT. The second step is generalising some concepts towards an abstract representation to reason on other cases.
Short Introduction to IoT infrastructure
IoT Infrastructure Principes
Example of commercial solution using IoT infrastructure : HDSN (see Demonstrator)
- From Real IoT Sensors (IoT Level) to a datacenter in a Cloud provider (Cloud Level)
- WebApp for user access to this smart home information
- Web Service for software access to this smart home information
Your own IoT Infrastructure (YoIoT) (See demonstration)
In order to provide a complete IoT/Edge/Cloud infrastructure for the practical part of this course we chose various free integrated solutions in the smart home application domain. Then the overall architecture consists in:
- Various sensors / actuators and sometimes more sophisticated smart devices, using Zwave and EnOcean standards for communication protocol
- Gateways based on RaspberryPi and the OpenHab software connected to Zwave/EnOcean but also wifi/ethernet and internet on the local netwark (LAN)
- PCs using Node-Red software environment as the first level for programming IoT application
- Remote Cloud services like OpenWeatherMap, ThingSpeak, Google Storage … (Cloud for SAAS)
Support de présentation des principaux éléments des infrastructures IoT - Introduction
YoIoT: Your own IoT Infrastructure for Tutorials
YoIoT is a technological example of an IoT infrastructure with only free software products !
Some materials about YoIoT deployment and manipulation can be find in
IoT4SME like iot4smes_iot_demonstrator_uns_v1.3.pdf.
How to install YoIoT
Comment : Home I/O installation is optional. It depends on your computer skills …
From IoT Devices to Edge in YoIoT
From(IoT Level) to RaspberryPi/PC (Edge Level) thanks to MQTT communication protocol
Required Knowledge:
- What is OpenHab ?, Documentation
Manipulations with Real Smart Home Devices connected through a gateway RaspberryPi with OpenHab
Correction :
[{"id":"a1550bd9.1468c8","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"4f3e12bb.aa3b8c","type":"mqtt in","z":"a1550bd9.1468c8","name":"","topic":"openhab/#","qos":"2","broker":"f9e5d8f1.1e9188","x":67,"y":204,"wires":[["5194de73.2aacf"]]},{"id":"5194de73.2aacf","type":"debug","z":"a1550bd9.1468c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":151.99998474121094,"y":327,"wires":[]},{"id":"43e7d350.1318f4","type":"mqtt out","z":"a1550bd9.1468c8","name":"","topic":"openhab/zwave_device_1b2be295_node4_switch_binary/commandssub","qos":"","retain":"","broker":"f9e5d8f1.1e9188","x":600,"y":248,"wires":[]},{"id":"eb50de7a.5703b8","type":"inject","z":"a1550bd9.1468c8","name":"Prise ON","topic":"","payload":"ON","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":366,"y":155,"wires":[["43e7d350.1318f4"]]},{"id":"3f8fea1a.953a7e","type":"inject","z":"a1550bd9.1468c8","name":"Prise OFF","topic":"","payload":"OFF","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":362,"y":343,"wires":[["43e7d350.1318f4"]]},{"id":"f9e5d8f1.1e9188","type":"mqtt-broker","z":"","name":"","broker":"192.168.1.134","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
From Edge to Cloud in YoIoT
RaspberryPi/PC (Edge Level) to ThingSpeak (Cloud Level) thanks to Web Service - HTTP communication protocol
Required Knowledge:
- What is a Web Service ?
- What is ThingSpeak ?
- How to access to a Web Service with Node-Red ?
Tutorial : How to use Node-Red to access to Web Services ?
exercice 1 : send some values to a ThingSpeak Channel with Node-Red and visualize the result on the Web exercice 2 : get some information (like a temperature in a given city) from one Web service like OpenWeatherMap and see the result with Node-Red debug. exercice 3 : after giving a
A completet Application in YoIoT
Required Knowledge:
Nothing more …
Projects
First design and developp an application with these functionalities :
Technical specifications:
- Get temperature value from a connected sensor in openhab
- Display the evolution of this temperature in a chart in ThingSpeak
- Get temperature value in Biot thanks to OpenWeatherApp Web Service
- Display the evolution of this temperature in a chart in ThingSpeak
- Compute the difference between them and display the evolution of this value
Question : Imagine you can get 100.000 measures like that in a Smart City. Do you have some applications in mind?
Optionnal Project
This project aims to use a IoT devices simulator in a Smart Home Context. To use it, you need Home I/O installation (the simulator) and to prepare a software configuration(see installation section above) to be able to access to the simulator with MQTT protocol.
After that you can collect some data from virtual sensors in the simulator, send some commands to various actuators like lights, windows etc., move accross the virtual smart home scene and interact with virtual devices.
For the most advanced student, feel free to imagine interesting applications and developp your own project in Smart Home.
Correction
Web Services Accesses
be careful, if you want to use Web Services to access to ThingSpeak first you must create channels to publish data and get the corresponding keys
- Dataflow that publishes/displays a changing data in ThingSpeak, using timer
This example uses a key of the 275 public channel : https://sparks-vm24.i3s.unice.fr/channels/275
[{"id":"b6ba693.b940298","type":"inject","z":"2ce2a219.894e3e","name":"Inject data","topic":"","payload":"-5","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":580,"wires":[["d23c2100.93cbc"]]},{"id":"9dde6e7f.3cd66","type":"delay","z":"2ce2a219.894e3e","name":"delai repet","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":390,"y":660,"wires":[["7db93689.4f46c8"]]},{"id":"a61123ff.96303","type":"http request","z":"2ce2a219.894e3e","name":"","method":"GET","ret":"txt","url":"https://sparks-vm24.i3s.unice.fr/update?key=F5OBSRU54WPK0XSA&field1={{{field1}}}&field2={{{field2}}}&field3={{{field3}}}&field4={{{field4}}}","tls":"","x":620,"y":580,"wires":[[]]},{"id":"d23c2100.93cbc","type":"function","z":"2ce2a219.894e3e","name":"set fields","func":"msg.field1 = msg.payload;\nmsg.field2 = msg.payload + 1;\nmsg.field3 = msg.payload - 1;\nmsg.field4 = msg.payload * 2;\nreturn msg;","outputs":1,"noerr":0,"x":400,"y":580,"wires":[["9dde6e7f.3cd66","a61123ff.96303"]]},{"id":"7db93689.4f46c8","type":"function","z":"2ce2a219.894e3e","name":"increment","func":"msg.payload++;\nreturn msg;","outputs":1,"noerr":0,"x":390,"y":720,"wires":[["d23c2100.93cbc"]]}]
* Dataflow that gets weather information on OpenWeatherMap Web Service (here, students can use my API key but without any guarantee). In case of problem, get your own API key after free registration.
[{"id":"452441aa.07cbd","type":"inject","z":"2ce2a219.894e3e","name":"","topic":"","payload":"Biot,FR","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":810,"y":400,"wires":[["abb00141.4754c"]]},{"id":"65daee20.15c48","type":"inject","z":"2ce2a219.894e3e","name":"","topic":"","payload":"Moscow,RU","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":830,"y":460,"wires":[["abb00141.4754c"]]},{"id":"abb00141.4754c","type":"http request","z":"2ce2a219.894e3e","name":"OpenWeatherMap Request","method":"GET","ret":"txt","url":"http://api.openweathermap.org/data/2.5/weather?q={{{payload}}}&appid=8e35e9a5638ee0540022a6b38d9ea89c","tls":"","x":1040,"y":380,"wires":[["10bf958d.e421aa"]]},{"id":"fc448289.27d86","type":"debug","z":"2ce2a219.894e3e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1250,"y":440,"wires":[]},{"id":"10bf958d.e421aa","type":"function","z":"2ce2a219.894e3e","name":"parse and format","func":"var obj = JSON.parse(msg.payload);\nmsg.payload = obj.name + \":\" + obj.weather[0].main;\nreturn msg;","outputs":1,"noerr":0,"x":1070,"y":480,"wires":[["fc448289.27d86"]]}]
Dataflow that gets information from OpenHAB
- using a OpenHab MQTT flow
[{"id":"7e96c990.582bf8","type":"mqtt in","z":"2ce2a219.894e3e","name":"","topic":"openhab/#","qos":"2","broker":"aa872460.7dff18","x":120,"y":160,"wires":[["e6cd4834.c78e68"]]},{"id":"e6cd4834.c78e68","type":"debug","z":"2ce2a219.894e3e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":390,"y":160,"wires":[]},{"id":"420c7771.ed7e08","type":"mqtt out","z":"2ce2a219.894e3e","name":"","topic":"openhab/zwave_device_1b2be295_node4_switch_binary/commandssub","qos":"","retain":"","broker":"aa872460.7dff18","x":1000,"y":160,"wires":[]},{"id":"2bfce164.02ee0e","type":"inject","z":"2ce2a219.894e3e","name":"Prise ON","topic":"","payload":"ON","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":620,"y":140,"wires":[["420c7771.ed7e08"]]},{"id":"1165f273.5a523e","type":"inject","z":"2ce2a219.894e3e","name":"Prise OFF","topic":"","payload":"OFF","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":620,"y":180,"wires":[["420c7771.ed7e08"]]},{"id":"aa872460.7dff18","type":"mqtt-broker","z":"","name":"192.168.137.93","broker":"192.168.137.93","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
- using the OpenHab REST API
[{"id":"b72e122c.7d834","type":"inject","z":"2ce2a219.894e3e","name":"Prise ON","topic":"","payload":"ON","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":840,"y":580,"wires":[["ba7d98c.9efac68"]]},{"id":"5bf29976.e28098","type":"inject","z":"2ce2a219.894e3e","name":"Prise OFF","topic":"","payload":"OFF","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":840,"y":620,"wires":[["ba7d98c.9efac68"]]},{"id":"ba7d98c.9efac68","type":"http request","z":"2ce2a219.894e3e","name":"OpenHAB Node4","method":"POST","ret":"txt","url":"http://192.168.137.93:8080/rest/items/zwave_device_1b2be295_node4_switch_binary","tls":"","x":1050,"y":600,"wires":[["96d0f087.426fa"]]},{"id":"96d0f087.426fa","type":"debug","z":"2ce2a219.894e3e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1260,"y":600,"wires":[]}]
Loop to read OpenHab sensor value
[{"id":"5e2906c6.ff0a28","type":"http request","z":"a1550bd9.1468c8","name":"","method":"GET","ret":"txt","url":"http://192.168.1.134:8080/rest/items/zwave_device_1b2be295_node10_sensor_temperature/state","tls":"","x":406.10003662109375,"y":180.1999969482422,"wires":[["abf47735.d71a28"]]},{"id":"61272c17.7ce984","type":"inject","z":"a1550bd9.1468c8","name":"","topic":"","payload":"","payloadType":"date","repeat":"3","crontab":"","once":false,"onceDelay":0.1,"x":272.1000061035156,"y":73,"wires":[["5e2906c6.ff0a28"]]},{"id":"abf47735.d71a28","type":"debug","z":"a1550bd9.1468c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":624.1000366210938,"y":180.40000915527344,"wires":[]}] [{"id":"a1550bd9.1468c8","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"5e2906c6.ff0a28","type":"http request","z":"a1550bd9.1468c8","name":"","method":"GET","ret":"txt","url":"http://192.168.1.134:8080/rest/items/zwave_device_1b2be295_node10_sensor_luminance/state","tls":"","x":406.10003662109375,"y":180.1999969482422,"wires":[["abf47735.d71a28","89172555.a47bc8"]]},{"id":"61272c17.7ce984","type":"inject","z":"a1550bd9.1468c8","name":"","topic":"","payload":"","payloadType":"date","repeat":"3","crontab":"","once":false,"onceDelay":0.1,"x":272.1000061035156,"y":73,"wires":[["5e2906c6.ff0a28"]]},{"id":"abf47735.d71a28","type":"debug","z":"a1550bd9.1468c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":624.1000366210938,"y":180.40000915527344,"wires":[]},{"id":"89172555.a47bc8","type":"http request","z":"a1550bd9.1468c8","name":"","method":"GET","ret":"txt","url":"https://sparks-vm24.i3s.unice.fr/update?key=F5OBSRU54WPK0XSA&field1={{{payload}}}","tls":"","x":519.1000366210938,"y":276,"wires":[[]]}]--
correction for optionnal Home IO manipulations
Find in the Home I/O installation directory, a zip/csv file that gives the sensors list with prefixes A,B,C …
- Dataflow that get boolean sensors information in room A
[{"id":"72ccc74c.836b88","type":"mqtt in","z":"2ce2a219.894e3e","name":"","topic":"/home/A/Input/bool/#","qos":"2","broker":"53b33537.72499c","x":200,"y":360,"wires":[["7f13ecda.da48c4"]]},{"id":"7f13ecda.da48c4","type":"debug","z":"2ce2a219.894e3e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":460,"y":360,"wires":[]},{"id":"53b33537.72499c","type":"mqtt-broker","z":"","name":"localhost","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"", "closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
- Dataflow that controls lights in room A
[{"id":"18542933.86d2c7","type":"mqtt out","z":"2ce2a219.894e3e","name":"","topic":"/home/A/Output/bool/Lights","qos":"","retain":"","broker":"53b33537.72499c","x":540,"y":460,"wires":[]},{"id":"3b14a0e3.3cf4c","type":"inject","z":"2ce2a219.894e3e","name":"Lampes ON","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":440,"wires":[["18542933.86d2c7"]]},{"id":"9cc3ec49.cc846","type":"inject","z":"2ce2a219.894e3e","name":"Lampes OFF","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":480,"wires":[["18542933.86d2c7"]]},{"id":"53b33537.72499c","type":"mqtt-broker","z":"","name":"localhost","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
Link one Home IO virtual switch to a real light in OpenHab
[{"id":"63cba22a.43de3c","type":"mqtt in","z":"2ce2a219.894e3e","name":"","topic":"/home/A/Input/bool/Up-Down_Switch_1_(Up)","qos":"2","broker":"53b33537.72499c","x":310,"y":960,"wires":[["88c2d0ba.4c8b9"]]},{"id":"779f82d3.a80d4c","type":"mqtt in","z":"2ce2a219.894e3e","name":"","topic":"/home/A/Input/bool/Up-Down_Switch_1_(Down)","qos":"2","broker":"53b33537.72499c","x":320,"y":1020,"wires":[["e44a55cd.753418"]]},{"id":"88c2d0ba.4c8b9","type":"switch","z":"2ce2a219.894e3e","name":"filter true","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"True","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":600,"y":960,"wires":[["529f2ff8.62271"]]},{"id":"e44a55cd.753418","type":"switch","z":"2ce2a219.894e3e","name":"filter true","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"True","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":600,"y":1020,"wires":[["63d5e341.6a145c"]]},{"id":"529f2ff8.62271","type":"change","z":"2ce2a219.894e3e","name":"convert payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":960,"wires":[["37074f0a.af995"]]},{"id":"63d5e341.6a145c","type":"change","z":"2ce2a219.894e3e","name":"convert payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":1020,"wires":[["37074f0a.af995"]]},{"id":"37074f0a.af995","type":"mqtt out","z":"2ce2a219.894e3e","name":"","topic":"openhab/zwave_device_1b2be295_node4_switch_binary/commandssub","qos":"","retain":"","broker":"aa872460.7dff18","x":1230,"y":1000,"wires":[]},{"id":"53b33537.72499c","type":"mqtt-broker","z":"","name":"localhost","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"aa872460.7dff18","type":"mqtt-broker","z":"","name":"192.168.137.93","broker":"192.168.137.93","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
Back to the concepts Of IoT infrastructure
Main commercial platforms
Main Companies and their solutions : 10 of the famous platforms available today
- MICROSOFT AZURE IOT HUB
- IBM WATSON IOT PLATFORM
- GOOGLE CLOUD PLATFORM
- ORACLE
- SALESFORCE
- BOSCH
- CISCO IOT CLOUD CONNECT
- GENERAL ELECTRICS PREDIX
- SAP