Industrial automation, communication and data management · Prototyping Simulation Prototype...
Transcript of Industrial automation, communication and data management · Prototyping Simulation Prototype...
![Page 1: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/1.jpg)
Politecnico di MilanoAdvanced Network Technologies Laboratory
Industrial automation, communication and data management
Hands on activities
![Page 2: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/2.jpg)
□ Edoardo Longo□ DEIB Building 20 - Ground Floor – ANTLab□ IG: @antlabpolimi
□ Email: [email protected]□ Phone: 02 2399 9614
![Page 3: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/3.jpg)
□ Giving you an overview on the software used in the IoT community
□ Stimulating your curiosity□ Providing you with basic tools to develop simple
IoT applications□ Classes time is limited -> Play with these tools
on your own!!
Classes Objectives
![Page 4: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/4.jpg)
Politecnico di MilanoAdvanced Network Technologies Laboratory
Internet of ThingsHardware and Sensors
4
’’take all the things in the world and connect them to the internet’’
![Page 5: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/5.jpg)
Things
![Page 6: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/6.jpg)
Hardware
MKR-1000Flash Memory: 256KB
SRAM: 32KBClock Speed: 48MHz
Wi-Fi
RASPBERRY PIFlash Memory: microSD
RAM: 1GBClock Speed: 1.2GHz
(Wi-Fi / Bluetooth) / Eth
MICAZFlash Memory: 128KB
SRAM: 4KBClock Speed: 7 MHz
ZigBee
ARDUINO UNOFlash memory: 32KB
SRAM: 2KBClock Speed: 16MHz
Ethernet
![Page 7: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/7.jpg)
Sensors
□ Temperature□ Proximity□ Gas□ InfraRed□ Chemical□ Smoke□ Motion detector□ Air quality□ …
![Page 8: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/8.jpg)
Communication pattern
![Page 9: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/9.jpg)
Politecnico di MilanoAdvanced Network Technologies Laboratory
IoT Software Platforms…in the cloud
9
![Page 10: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/10.jpg)
□ IoT is about DATA sensed and transmitted from OBJECTS□ How much data?
■ IPV6 covers every atom on 100+ earths■ Recent estimates: 4.4 zettabytes (10^21B) of IoT data
produced by 2020■ That’s 1 stack of 128 GB Ipad Air reaching the moon!
□ How to manage it? Go to the cloud with an IoT platform!
Why the cloud?
![Page 11: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/11.jpg)
□ The term “platform” can refer to:■ Hardware architectures (ARM, Arduino, etc…)■ Software frameworks to program smart things ■ Cloud-based middleware platforms to manage IoT data and
devices
IoT platforms
11
![Page 12: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/12.jpg)
□ IoT platforms world is growing fast■ 100+ platforms available online
□ They are getting more and more mature and stable■ Not only startups, also big players (Microsoft, IBM, AWS)
□ Key value proposition ■ reduce costs and time-to-market for IoT solution, reduce
management complexity□ But: a lot of confusion for users!
IoT platforms
12
![Page 13: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/13.jpg)
IoT platforms
13
![Page 14: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/14.jpg)
□ Old Giants■ IBM: Bluemix IoT Cloud, Node-RED■ Microsoft: Azure IoT Suite + Windows 10 IotCo■ Amazon: AWS IoT■ Google: Cloud IoT + Android Things■ Intel: IoT platform
□ Startups■ Thingspeak, FreeBoard, ThingWorx, Dweet.io….
Solutions
![Page 15: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/15.jpg)
□ Device management ■ Connect devices to the cloud, configure devices, update
firmware, monitor devices…□ Data management
■ Store and retrieve data, manage events, visualize and share data
□ Data analysis / automation■ Statistical analysis, data mining, machine learning, etc…
□ Security
Desired features
![Page 16: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/16.jpg)
Data Analytics &
BI
Device management
Security
Data management
Automation
Specialized platforms:only one feature is
implemented
AutomationDevice
management
Datamanagement
Data Analytics
& BI
Security
Generalized platforms: many features are
implemented
Two types of platforms
![Page 17: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/17.jpg)
How to choose?
□ Specialized■ Connectivity
management■ Device configuration■ OtA firmware update
□ Generalized■ Data mining & machine
learning■ Data fusion■ Event processing■ Rules engine
19
□ It depends on the particular IoT application!
![Page 18: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/18.jpg)
Distinctive Features
20
□ Device SDK:■ Firmware programming, API documentation
□ Cloud SDK:■ API■ Graphic programming tools ■ Built-in functional blocks
□ General features■ Language agnosticity (C, Java, Python)■ Communities (Arduino, mbed, launchpad)
![Page 19: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/19.jpg)
Easy development
21
![Page 20: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/20.jpg)
Easy development
22
□ Built-in and custom functionsReactive Blocks
Node-Red
![Page 21: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/21.jpg)
Communities
23
□ Speed-up learning processes
![Page 22: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/22.jpg)
Dashboard DIY24
DGLux CumulocityAzure BI
freeboard
![Page 23: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/23.jpg)
□ Many IoT platforms available□ Both startups and big IT players□ Different solutions / services for different
users□ In general, it’s quite a complex scenario
Summary
25
![Page 24: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/24.jpg)
Politecnico di MilanoAdvanced Network Technologies Laboratory
Developing IoT applications
26
MBED OS simulator
![Page 25: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/25.jpg)
Development Pipeline
□ Application design□ Prototyping
■ Simulation■ Prototype implementation
□ Production□ Release□ Application maintenance/updates
![Page 26: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/26.jpg)
Development boards
□ IoT devices are mostly microcontrollers (MCU)□ MCU = compact integrated circuit on a single board
■ Processor■ Memory■ Input/output peripherals■ (Serial ports)■ (ADC/DAC)
![Page 27: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/27.jpg)
Simulation
□ Complex and inefficient deploying applications on real HW■ Risk-free environment■ Debugging■ Save money and time■ Visualization■ Handle uncertainty■ Visualization
![Page 28: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/28.jpg)
MBED OS simulator
□ Operating system for ARM microcontrollers□ Simulate 200+ of embedded boards□ Add plenty of sensors to the boards□ C/C++ software platform and tool for creating
microcontroller firmware that runs on IoT devices
![Page 29: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/29.jpg)
MBED OS simulator
Available at:□ Under polimi-protected/eduroam network:
https://tinyurl.com/simulatorpoli
□ Under any other network:https://tinyurl.com/simulatormbed
![Page 30: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/30.jpg)
MBED OS simulator
Code area
Demo list
Debug area
Board & sensors area
![Page 31: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/31.jpg)
MBED Simulator Examples
□ Blink (turn on/off a LED)□ Temperature – Humidity sensors
![Page 32: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/32.jpg)
Send data somewhere
□ Communication protocols■ NFC■ ZigBee■ Bluetooth■ WiFi■ Cellular■ LoRaWan■ NB-IoT■ …
![Page 33: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/33.jpg)
Send data somewhere
□ Application layers protocols■ MQTT■ HTTP RESTful API■ CoAP■ AMQP■ DDS■ XMPP■ …
![Page 34: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/34.jpg)
RESTful API
□ Request –> response fashion□ Based on client-server architecture□ One-to-one communication□ The client requests resources to an online server
■ GET, PUT, POST, DELETE
![Page 35: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/35.jpg)
Query string
Examples:https://api.nasa.gov/planetary/apod?api_key=DEMO_KEYhttps://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?sol=1000&api_key=DEMO_KEY
![Page 36: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/36.jpg)
ThingSpeak
38
![Page 37: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/37.jpg)
ThingSpeak
39
![Page 38: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/38.jpg)
□ An IoT cloud platform for:■ Real-time data collection and storage■ Data analytics and visualization (integrated with MATLAB)■ Alerts and Scheduling■ Device Communication, Open API
ThingSpeak
40
![Page 39: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/39.jpg)
□ Weather Station: https://thingspeak.com/channels/536159■ Arduino-based to collect, store and analyze weather data
□ Tide Level Alerts https://thingspeak.com/channels/50289■ Real-time tide predictions and water levels monitoring
■ My channel: https://bit.ly/2xQdEwx
ThingSpeak features projects
![Page 40: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/40.jpg)
□ ThingSpeak uses channels to store data sent from devices or apps
□ Data stored in channels:■ Create / view / update / delete / import / export
□ Channel settings■ ID, name, description■ Up to 8 fields (datastreams)■ Public / private■ Location, Metadata, etc…
ThingSpeak channels
42
![Page 41: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/41.jpg)
Operating on a channel
43
□ Operations can be done from the web interface or through the REST API
□ Create a channel:■ Send an HTTP POST to:
https://api.thingspeak.com/channels■ With parameters
□ api_key=XXXXXXXXXXXXXXX□ name=My New Channel
![Page 42: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/42.jpg)
API Key
44
□ When performing an operation, your API key is required□ Keys can be regenerated
if the user feels that theyare compromised
![Page 43: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/43.jpg)
Channel fields
45
□ Each channel supports up to 8 fields□ Each field represents an individual sensor stream and is
associated to a chart■ e.g., temperature, humidity, number of parked cars, etc…
□ Field/Chart parameters:■ Title, x axis, y axis, appearance, etc…
![Page 44: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/44.jpg)
Channel field update
46
□ Like channels, fields can be updated via HTTP requests:
https://api.thingspeak.com/update?api_key=XXXXXXXXXX&field1=YY
https://api.thingspeak.com/update?api_key=XXXXXX&field1=YY&field2=ZZ
□ Try it from yourself, copy the GET API request in your browser address bar
![Page 45: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/45.jpg)
From the board to the cloud
□ Let’s insert HTTP requests into our simulated board□ Create a new channel with 2 fields:
■ Temperature■ Humidity
□ Send the data to ThingSpeak every time the temperature or the humidity change
![Page 46: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/46.jpg)
□ CURL: CLI tool for transferring data using HTTP (and many others protocols)
□ Escape “special” characters□ curl
https://api.thingspeak.com/update\?api_key\=YOUR_API_KEY\&field1\=XXXX
Update a channel via Terminal
![Page 47: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/47.jpg)
□ Use python3!
Update a channel (python3)
![Page 48: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/48.jpg)
Node-RED
51
![Page 49: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/49.jpg)
□ Visual tool for wiring the Internet of Things□ Can be run on a variety of platforms:
■ Edge devices: Raspberry PI, BeagleBone black■ Cloud: IBM Bluemix, Amazon AWS, Azure
□ The user creates flows by wiring together different nodes:■ I/O (serial port, tcp sockets, http, mqtt, files)■ Functions (built in or custom JS functions)■ Advanced (execute programs, post a tweet)
Node-RED
52
![Page 50: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/50.jpg)
□ Open a terminal and type node-red□ Open the browser and go to localhost:1880□ The node-red console appears
Node-RED flow
53
![Page 51: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/51.jpg)
Node-RED flow
Nodes
Flow Tabs
Flow Area
Deploy button
![Page 52: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/52.jpg)
□ Insert an inject node and a debug node. Wire them together.
□ Modify the inject block as it followsPayload -> "Hello World!"
□ Click on Deploy and then on the inject button
The “Hello World” flow
55
![Page 53: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/53.jpg)
A working example
56
□ Let’s create a flow in Node-RED that:■ Generates random data periodically■ Create a chart and a gauge with such numbers
□ We need:■ Inject node■ Random node -> to install■ Dashboard nodes -> to install■ Debug node
![Page 54: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/54.jpg)
MQTT
□ Protocol optimized for unreliable, low-bandwidth, high-latency network
□ Smallest possible packet size is 2 bytes□ Few methods: publish/subscribe/unsubscribe□ Based on topics
![Page 55: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/55.jpg)
□ Publish/Subscribe paradigm■ Clients don’t know each other■ One-to-Many paradigm■ Every client publishes & subscribes
MQTT
![Page 56: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/56.jpg)
MQTT
![Page 57: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/57.jpg)
Topics
□ Topics are arbitrary strings used to identify a resource
![Page 58: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/58.jpg)
□ Add the MQTT publisher node and the inject
□ Server: ws://mqtt.thingspeak.com:80/mqtt□ Topic: channels/<channelID>/publish/<apikey>□ Payload: field1=XX&field2=YY&status=MQTTPUBLISH□ Username: anyone□ Password: MQTT API key (Account -> My Profile)
Send data from Node-RED to ThingSpeak
![Page 59: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/59.jpg)
□ Add the MQTT subscriber node and the debug
□ Server: ws://mqtt.thingspeak.com:80/mqtt□ Topic: channels/<channelID>/subscribe/fields/+/<apikey>
□ <apikey> is not required if the channel is public□ Username: anyone□ Password: MQTT API key (Account -> My Profile)
Read data from Node-RED to ThingSpeak
![Page 60: Industrial automation, communication and data management · Prototyping Simulation Prototype implementation Production Release ... IBM Bluemix, Amazon AWS, Azure The user creates](https://reader033.fdocuments.in/reader033/viewer/2022042711/5f823ae9d7230938320106af/html5/thumbnails/60.jpg)
Last exercise
□ Send data from the MBED simulated temperature-humidity sensor to ThingSpeak via HTTP requests
□ Read the data on Node-RED■ Using MQTT, Subscribe to the channel from Node-RED
□ Visualize the data on the Node-RED dashboard■ A chart for historical temperature values■ A chart for historical humidity values■ A gauge for instantaneous temperature value■ A gauge for instantaneous humidity value