iot-backend/docs/workshop/README.md

232 lines
6.2 KiB
Markdown
Raw Normal View History

---
marp: true
title: IoT & Dashboard Workshop
description: Including examples Sensors for Energy Management
author: Oliver Ochs, Sebastian Wendel
2023-09-26 21:11:36 +02:00
class: invert
paginate: true
---
# <!--fit--> IoT & Dashboard Workshop
2023-09-26 21:34:03 +02:00
![bg](./images/image.png)
2023-09-26 21:34:03 +02:00
---
# [Matrix Chat](https://matrix.org/)
To exchange information digitally during and after the workshop we use [Matrix as a chat solution](https://matrix.org/). You don't know this yet? Don't be hesitant and join us!
[https://matrix.to/#/#iot-platform:curious.bio](https://matrix.to/#/#iot-platform:curious.bio)
![bg right](./images/qrcode-chat.svg)
---
2023-09-26 21:34:03 +02:00
2023-09-26 18:39:45 +02:00
# Fab City Dashboard
This is a prototype of data management platform for Fab City Hamburg based on existing open source solutions.
![width:100pxy](./images/architecure.svg)
2023-09-26 18:39:45 +02:00
---
# Features
- [Eclipse Mosquitto](https://mosquitto.org/): MQTT broker
- [Node-RED](https://nodered.org/): Flow-based development tool for visual programming and data flow automation
- [InfluxDB](https://www.influxdata.com/): High-performance data storage
- [Grafana](https://grafana.com/): Real-time data visualization and monitoring dashboard
2023-09-26 18:39:45 +02:00
---
# Today's Goal
- install the stack
- configure one or two data sources
- transform data and store them in a database
- visualize data stored in the database
2023-09-26 18:39:45 +02:00
---
2023-09-26 18:39:45 +02:00
# Architecture
- Data is collected by IoT devices, e.g. an ESP32 based power monitor. These devices publish their data via MQTT into a topic in a message broker. We use Eclipse Mosquitto as a MQTT message broker.
2023-09-26 18:39:45 +02:00
- Node-RED is used to read and transform or combine data and to implement more sophicsticated use cases like notifications or worksflow. Node-RED subscribes to topics in Mosquitto and can be used to save transformed data into a database.
2023-09-26 18:39:45 +02:00
- As our data is bases on time, we are using a time series database to store information. We used InfluxDB as this database.
- Dashboards can already be created in Node-RED, but to be more flexible (and include more options) we are using Grafana. Grafana reads data from our database and other sources (like CSV files on the Internet) and displays them in a nice dashboard.
---
2023-09-26 18:39:45 +02:00
# Sensor level: Physical acquisition of measured values
Sensors can be build or bought:
- Sensor head
2023-09-26 18:39:45 +02:00
- ESP32 or equivalent
- OpenHardware or COTS (commercially of the self)
- Analog/Digital acquisition
- Communication gateway via WLAN / MQTT
2023-09-26 18:39:45 +02:00
- Examples measurements
- Energy measurement
- Temperature sensor -> temperature measurement
- Pulse sensor -> incremental measurement of filament
2023-09-26 18:39:45 +02:00
---
2023-09-26 21:11:36 +02:00
# Example sensor - Open Engergy Monitor
2023-09-26 18:39:45 +02:00
![[bg]](./images/breadboard.png)
2023-09-26 21:11:36 +02:00
---
# Example sensor - Open Engergy Monitor
![bg left](./images/clamp1.jpeg)
2023-09-26 18:39:45 +02:00
---
# Example sensor - Shelly Plug
2023-09-26 21:11:36 +02:00
![bg right](./images/shelly_plug_s_1-1.jpg)
2023-09-26 18:39:45 +02:00
---
# Example sensor - GCode Sender
![bg left](./images/gcode-sender.png)
2023-09-26 18:39:45 +02:00
---
# MQTT (Message Queuing Telemetry Transport)
- publish-subscribe, machine to machine network protocol
- designed for connections with remote locations
- devices with resource constraints
- limited network bandwidth
- Internet of Things (IoT)
- runs on top of TCP/IP, QUIC (UDP) or Bluetooth
2023-09-26 18:39:45 +02:00
---
# MQTT - Components
- one message broker (Mosquitto) and many clients
- broker receives published messages from clients
- routes them to subcribed clients
- clients subscribe to topic patterns
2023-09-26 18:39:45 +02:00
![bg right](./images/MQTT_protocol_example_without_QoS.svg)
2023-09-26 18:39:45 +02:00
---
# Flow - Node-RED
The idea behind it is to make it very easy to connect APIs, hardware devices, and anything else accessible over some type of network connection.
![bg left](./images/nr-image-1.png)
- open-source
- low-code
- visual programming tool
- flow-based development
2023-09-26 18:39:45 +02:00
---
# Node-RED - Core Concepts
2023-09-26 21:11:36 +02:00
Nodes are the important part of Node-RED, they:
2023-09-26 18:39:45 +02:00
- are triggered by either receiving a message object from a previous node or an external event like an MQTT event
- process messages or events and then passes them on to the next node
2023-09-26 18:39:45 +02:00
A node can:
- Inject: Starts a flow by injecting a message or a payload.
- Change: Here you can do basic transformation or modification on the message object.
- Debug: Can be used to help developing flows by sending messages to the side bar.
- Switch: Here you can add logic (like sending the message to different nodes).
- Function: Add custom JavaScript for uses cases where simple nodes do not do the trick.
2023-09-26 18:39:45 +02:00
---
# Node-RED - Plugins
Node-RED uses plugins:
- extend functionality (like dashboard)
- connectors (like influxdb)
- libraries (like aggregating watts and transform them to khw)
2023-09-26 18:39:45 +02:00
---
# Node-RED - Simple Flow
![height:600](../flow/docs/images/influx-flow.png)
2023-09-26 18:39:45 +02:00
---
# Database - InfluxDB
2023-09-26 21:11:36 +02:00
InfluxDB is a database for any time series data. Time series data is everywhere, since time is a constituent of everything that is observable. As our world gets increasingly instrumented, sensors and systems are constantly emitting a relentless stream of time series data. For example:
- Electrical activity in the brain
- Rainfall measurements
- Monthly subscribers
- Heartbeats per minute
- Electricity consumed by a chain saw
2023-09-26 18:39:45 +02:00
---
2023-09-26 21:11:36 +02:00
# Database - InfluxDB
![height:600](../flow/docs/images/influx-data-explorer.png)
2023-09-26 18:39:45 +02:00
---
# Dashboard - Grafana
Grafana is an open source analytics and interactive visualization tool.
2023-09-26 18:39:45 +02:00
- charts
- graphs
- alerts for the web when connected to supported data sources.
2023-09-26 18:39:45 +02:00
As a visualization tool, Grafana is a popular component in monitoring stacks, often used in combination with time series databases such as InfluxDB.
---
# Dashboard - Example
![bg left](../workshop/images/sampledashboard.png)
2023-09-26 18:39:45 +02:00
---
# Let's start
- Check installation requirements
- 64bit environment (AMD64, ARM64)
- [Docker](https://docs.docker.com/engine/install/)
- [Docker-Compose](https://docs.docker.com/compose/install/)
- Checkout the repository:
- [https://code.curious.bio/curious.bio/iot-backend](https://code.curious.bio/curious.bio/iot-backend)
- [https://code.curious.bio/curious.bio/smart-energy-monitor](https://code.curious.bio/curious.bio/smart-energy-monitor)
- Let's follow the README, together!
2023-09-26 21:11:36 +02:00
---
# <!--fit--> 🫵 Hands on
2023-09-26 18:39:45 +02:00
---
# Where can I find this presentation?
2023-09-26 21:17:14 +02:00
https://code.curious.bio/curious.bio/iot-backend/src/branch/main/docs/workshop
![bg right](./images/qrcode-slides.svg)