Live lecture notes 2021
Live session. 2021-06-16
- Quiz from videos. Wireless Sensor Networks
- Anna Förster, background and research
- Hardware discussions
- Arduino
- ESP32
- Pycom
- 5V or 3.3V
- Best practices when working with hardware
- Choice of programming languages, C++, MicroPython
- Power management
- Battery design
- How to measure or calculate?
Hardware in course
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →










CPS and ES

IoT





Applications



Use cases, massive IoT



What makes IoT so interesting?

Node-RED
Either locally with Docker
https://nodered.org/docs/getting-started/docker
Or, in the cloud
https://nodered.org/docs/getting-started/ibmcloud
- Node-RED dashboard
- Webhooks
- MicroPython
- MQTT
- Webhook
- Platforms, local and online
- TTN, LoRa, SigFox
MicroPython
- Official homepage: http://micropython.org/
- Documentation: http://docs.micropython.org/en/latest/
- PyCom docs: https://docs.pycom.io/ (MicroPython + Pycoms libs)
- Adafruit has CircuitPython (a fork of MicroPython)
- Firmware to the PyCom device.
- Legacy, not containing Pybytes library. Older.
- Flash with Pybytes, even not using Pybytes.
- Contains
pybytes_config.json
.
- Provisioning from Pybytes homepage. May interfere with you own code.
Disable Pybytes on boot!
Design
- MicroPython is designed to work on small micro-controller platforms.
- There are learning material out there. MicroPython series by unexpected maker
- You must first write your code and load it onto the board.
- Boards have a flash drive storage. You can copy your Python file(s) to this drive for execution at boot time.
boot.py
and main.py
- The MicroPython console is called the run, evaluate, print loop, or REPL. Makes it easy to get started and to debug (remove errors).
- Run, Evaluate, Print, Loop (REPL)

REPL Interface in Atom.io
Projects Atom/VSCode and PyMakr, USB, WiFi,
- Projects, you need to work in projects.
- Do not use PyBytes for coding! No debug. Inconsistent connection.
- FW of Expansion board. If you have no problems uploading, it should be OK.
- Online platforms.
- You send you data directly from your device to the internet.
- Local platform (which can be hosted in the cloud …)
- You send the data to a local platform. Either directly over LAN, or via internet.
- The TIG-stack. Telegraf, Influx and Grafana.
https://hackmd.io/@lnu-iot/cloud-platforms
LoRa
- 10 km range, ~ 10y battery life
- Gateways, forward packages using TCP/IP
- Build/buy gateway - register to TTN.
- TTN is a MQTT broker!
- OTAA Over-The-Air Activation and ABP (Activation By Personalisation)

thethingsnetwork.org

thethingsnetwork.org

ttnmapper.org

https://www.frugalprototype.com/technologie-lora-reseau-lorawan/

LoRaWAN-protocol specifications, LPWAN-Technologies for IoT (2020)

LoRaWAN-protocol specifications, LPWAN-Technologies for IoT (2020)

Info regarding Pycom devices:
device_class
sets the LoRaWAN device class. Can be either LoRa.CLASS_A
or LoRa.CLASS_C

https://www.newieventures.com.au/blogtext/2018/2/26/lorawan-otaa-or-abp


SigFox
- 0G network
- Same frequencies as LoRa. Different, ultra-narrowband instead of LoRa which uses a broader spectrum.
- Low throughput, limited 144/messages day.
- Top-down approach. The company owns all of its technology.
- Each message transmitted 3 times in 3 different frequencies.
MQTT
-
Show MQTT Explorer
- JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write.
What is MQTT
MQTT stands for MQ Telemetry Transport. It is a publish/subscribe, extremely simple and lightweight messaging protocol, designed for constrained devices and low-bandwidth, high-latency or unreliable networks. The design principles are to minimise network bandwidth and device resource requirements whilst also attempting to ensure reliability and some degree of assurance of delivery. These principles also turn out to make the protocol ideal of the emerging “machine-to-machine” (M2M) or “Internet of Things” world of connected devices, and for mobile applications where bandwidth and battery power are at a premium.
MQTT security
You can pass a user name and password with an MQTT packet in V3.1 of the protocol. Encryption across the network can be handled with SSL, independently of the MQTT protocol itself. Additional security can be added by an application encrypting data that it sends and receives, but this is not something built-in to the protocol, in order to keep it simple and lightweight.
-
- can be used as a wildcard for a single level of hierarchy. It could be used with the topic above to get information on all computers and hard drives as follows:
sensors/+/temperature/+
As another example, for a topic of "a/b/c/d", the following example subscriptions will match:
'#' can be used as a wildcard for all remaining levels of hierarchy. This means that it must be the final character in a subscription. With a topic of "a/b/c/d", the following example subscriptions will match:
Quality of Service
MQTT defines three levels of Quality of Service (QoS). The QoS defines how hard the broker/client will try to ensure that a message is received. Messages may be sent at any QoS level, and clients may attempt to subscribe to topics at any QoS level. This means that the client chooses the maximum QoS it will receive. For example, if a message is published at QoS 2 and a client is subscribed with QoS 0, the message will be delivered to that client with QoS 0. If a second client is also subscribed to the same topic, but with QoS 2, then it will receive the same message but with QoS 2. For a second example, if a client is subscribed with QoS 2 and a message is published on QoS 0, the client will receive it on QoS 0.
Higher levels of QoS are more reliable, but involve higher latency and have higher bandwidth requirements.
0: The broker/client will deliver the message once, with no confirmation.
1: The broker/client will deliver the message at least once, with confirmation required.
2: The broker/client will deliver the message exactly once by using a four step handshake.
https://mosquitto.org/man/mqtt-7.html
Webhook
- User-defined callback over HTTP
- Because webhooks use HTTP, they can be integrated into web services without adding new infrastructure.
- A POST request being the method that allows the transfer of information in the body of the request through HTTP.
- Include a body to the request, it's usually a simple JSON object.
- JSON, https://www.json.org/json-en.html