Take small bites, chew long and eat slow, but this time it is obeyed – Splitting message in Node-RED containing a JSON object

Take small bites, chew long and eat slow, but this time it is obeyed – Splitting message in Node-RED containing a JSON object

This sounds trivial – and it is. When you know how to do it 🙂 There’s an example on the Node-RED homepage splitting a message generated from CSV, but this isnt the case here. I somehow did miss the point – if there is one made in the documentation – of how to split a…

Multitasking: “Fucking up multiple things at the same time!” – MicroPython uasyncio howto

Multitasking: “Fucking up multiple things at the same time!” – MicroPython uasyncio howto

Most code for simple IoT devices is a script with an endless loop with the code for the connected hardware like reading a sensor or polling something from the network followed by a delay. Keeping that pattern in mind helps to write new or convert your existing code for asynchronous execution. If you want to…

Food delivery for the blood sucker – publishing temp/hum values read from DHT22 connected to NodeMCU v3 with MicroPython to Mosquitto MQTT server via WiFi

Food delivery for the blood sucker – publishing temp/hum values read from DHT22 connected to NodeMCU v3 with MicroPython to Mosquitto MQTT server via WiFi

a.k.a. longest post title ever 😛 This is the Python code for a NodeMCU v3 running MicroPython 1.19.1. It will measure temperature and humidity at the connected DHT22 with breakout board every 30 seconds, connect to WiFi and publish to a MQTT server.The first code block will be the necessary as simple and clear as…

“These ARE the devices you are looking for” – a MAC based identifier in Python, Micropython and C++

“These ARE the devices you are looking for” – a MAC based identifier in Python, Micropython and C++

TLDR: Code for MAC address in (Micro)Python and C++ for D1 Mini, Raspberry devices and NodeMCU. I was looking for a unique static identifier to handle my IoT devices without baking the mqtt publish topics, name and location into the code. The code on identical devices should be the same, the the individual configuration should…

Know what temp/hum to complain about – a DHT22 sensor on a NodeMCU v3 with very simple MicroPython code

Know what temp/hum to complain about – a DHT22 sensor on a NodeMCU v3 with very simple MicroPython code

My first NodeMCU v3 board. Connected a DHT22 (includes PCB with breakout board) to 3V, ground and data pin to D1 (which is Pin 5). Kept Python code for measuring loop as simple as possible. You will find a fitting pinout at RandomNerdTutorials. This code measures the temperature and humidity every 30 seconds and prints…

Software tests

Software tests

Write them. Do not try to save time writing them poorly or even not at all. You and your coworkers and even often your future self will appreciate the work you put in. Many many times I found probable issues, uncovered cases and bugs lurking in my code I wrote by testing the code step…

A snake with no name – Lambdas in Python (also functions and list comprehensions)

A snake with no name – Lambdas in Python (also functions and list comprehensions)

Sweet and short: Instead of a function you can write a single statement in Python as a lambda. Either is one either better or worse nor does one replace the other. They both have their place and intended use. Functions hopefully have describing names, are probably used multiple times and handle a specific part which…

“You won’t get IN with THIS E-Mail” – Python Regex to validate email (formally)

“You won’t get IN with THIS E-Mail” – Python Regex to validate email (formally)

Currently did some text analysis with Python and Regex. Came up with an E-Mail format validation method which could help you with the same problem and remind me of it in the future. Import package re and use the compile method to get a regex pattern with which you can match your desired String.For evaluation…