This is a usage note that collects together a bunch of information that was collected while working on a Grafana Dashboard for an IoT project.
The projects is using Grafana v9.4.9 and querying data in an Influx Database, using the Flux query language.
Getting Location values
The data that is being collected is tagged with a string that describes the location of the sensor. This is separate to the name of the device (dev_id), and this was a deliderate choice so that the device could be maintained and possibly be replaced with a new one, and continue to collect data for a particular locatgion. (The new sensor would also have different callibration data.)
The following query in the variable definition will extract a list of the locations.
Notice that this query also selects out the range of the data to display as selected from the time range of the dashboard.
Selecting Location Values
To allow the locations of interest to be selected on the dashboard as required, in the definition of the variable screen, select the “Show on Dashboard” option – “Label and Value”. This will automatically add the variable, possible values and selected values to the dashboard, and allow the user to selct between them.
Thanks
A quick thanks to Randall, from the PAE IoT Experimenters for providing the initial screenshot.
The company behind Zerotier have asked for feedback, stories and testimonials from people using their software, and as a more than happy user of their VPN software and network I am pleased to submit this article. I am not being paid for this. I make use of their free tier access, which currently meets my needs, although this may change as my circumstances change and my IoT and home network grows. I have been a very happy user for more than 5 years.
By way of a simple introduction, ZeroTier is a Virtual Private Network (VPN) technology, which enables all your devices to connect to each other via a separate, encrypted and controlled, software defined IP network, supporting both IPV4 and IPv6.
Why is this useful? The Zerotier network provides routers on the Internet which are used to route you packets. The beauty of this is that once you have installed the ZeroTier client on your devices (all major operating systems, including mobile device are supported), and authorised them on your network, they can communicate directly with each other, as if they were on the same local network.
My initial use case was so that I could access my home servers while away from home, particularly from my home wiki from my phone and mobile devices. Installing Zerotier removes the need to add port forwarding on my home router, or install a ‘Demilitarized Zone’ (DMZ) on my home network. Zerotier also allows all services to be available via to VPN, rather than having to open ports for every service or server that I want to access.
Another application is for remote access to remote servers for support services. The security implications need to be discussed with any customers, but having Zerotier installed on the remotely supported computer allows access from any other device which is also on the same Zerotier network. This was used to remotely control a robot at an exhibition and directly interact with the passing public. Like with all network services, the performance depends on the underlying networks.
In a more recent example, there is a plug-in for Zeroier in Home Assistant, which makes it almost effortless to setup secure access to my home management system for all members of the family both inside and outsode the home.
When registering devices on your private network (identified by a 16 digit hexi-decimal number, or 32 bits), you can explicitly set the IP address that devices are allocated, which they get when they authenticate to the network. Even though these IP addresses are private, if you have a register domain, it is possible to create public DNS names for them, which gives you the ability to use your private network in exactly the same way as you may setup a server on the internet itself.
What all this means is that Zerotier allows you to use internet as a ‘first class citizen’, rather than as a second or third, which has what has happened in the past when end users (home and commercial) have been forced to use network work-a-rounds like port forwarding, dynamic DNS websites, OpenVPN and IPSEC/L2TP, other router based solutions, and even manually configured web caching. No configuration change is required to maintain access, provided the end device has reasonably unfiltered access to the internet.
It is definitely worth giving Zerotier a go if you need to access all your devices that are on private networks, or even if you want to access public devices via an encrypted and secured subnet. The free subscription level allows registering up to 25 devices across multiple private networks. Checkout their website at https://www.zerotier.com/
The following is a short list of open source software worth checking out for home automation and IoT. (There will probably be some posts on each of these in the future.)
Usually, a RaspberryPi has been the platform of choice for deploying this software. Due to the current shortage and difficulty of getting RaspberryPis at the moment, Andreas Spiess (the guy with the Swiss accent) has just posted a Youtube video comparing other options using second-hand mini-pcs.
Andreas has also got some older videos introducing IoTstack, linked on the IOTstack website.
Home Assistant
This software for gluing together and managing a lot of the commercially available IoT and Home Automation products available for the home. The software used to connect to these products (called integrations) have been developed by the Home Assistant community and is available as additional plug-in or library which can be installed as required. (See: https://www.home-assistant.io/integrations/)
IoTstack
The IoTstack software is a system for installing, managing and backing up a large number of other software services which may be required (eg. Home Assistant, plus web server, databases, file servers etc.)
Open Energy Monitor is a project based in Wales which has developed an energy and environmental monitoring system. They have an energy sensor (the emontx series) which monitors the current in up to four(4) channels, together with the AC voltage, in order to measure the power flowing through electrical circuits.
Current transformers are used, and are placed by clamping around individual wires, allowing the current in the wire to be measured without making any change or direct contact to the existing wiring.
The Open Energy Monitor store are selling their sensors as a kit, and one has been ordered with four current transformers. This will be paired with an already available Arduino UNO to allow for an evaluation of the monitoring software.
We are just after the power measurements for each channel to be reported via a serial connection rather than using their project specific radio (a 433MHz radio link).
All of the code that they are using (with and without the radio link) is available via their forum and github repository.
As we evaluate this system we will be posting the results here.
The Open Energy Monitor also has a good set of documentation on how the units work, how they have been put together, and more on the theory of energy monitoring using current transformers.
As a birthday present for myself earlier in the year I purchased a “reMarkable 2” e-ink tablet and it’s been awesome. More details about the device below (for those that are interested) but I recently had the chance to use it in a 1-1 meeting covering the PAE IoT Workshop and it worked really well as a paper notebook substitute. Afterwards I was able to go over the details, tidy them up, and rearrange them into a more sensible layout (rather than the original messy stream of consciousness).
The tablet allows hand written text and drawings to be systematically edited, rearranged and replaced. There is the option on having layers (which I didn”t really use) and showing an underlying templete (lots to choose from) which is a useful guide for keeping everything nicely lined up, and which can be removed afterwards (replaced with the blank one).
The final result can emailed as PDF, PNG, or SVG formatted files, and the result is below.
About IoT Data Logging using LoRaWAN
The following is an example of the path which might be taken by a packet of date, created on a LoRaWAN IoT device, as it makes it’s way from the sensor to be displayed on a web-based dashboard on the Internet.
About the reMarkable2
There is quite a lot to talk about with the reMarkable2 but where is a vary brief summary – it’s a Linux based ARM system, which has Wifi access and drives a e-Ink display with stylus for drawing and input. The display and pen software is closed source, but everything else appears to be Free and Open Source Software. It is possible to SSH into the device from both Wifi and USB-C, with a password that is displayed from the settings menu. If you wanted to you could use that the change any of the software on the device but beware – there be dragons.
reMarkable (the company) currently send out software updates regularly (almost monthly), as these also include new features and tweeks.
There are also third party projects (the reHackable project) which make the tablet even more useful, and support the use of the reMarkable in many more ways than the manufacturer may have intended, including replacing the entire operating system. I have not considered doing this just yet.
The Department of Education, South Australia has issued the following anouncement (Link) this evening – Sunday, 15 November
Mawson Lakes School and Preschool will be closed on Monday 16 November following SA Health advice that a student who attends the school is a close contact to someone who has been diagnosed with COVID-19.
People who need to self-isolate will be contacted with further instructions.
A thorough clean of all relevant areas will be carried out. Parents have been notified.
From the South Australian Govenment Website (Link), concern has been expressed regarding anyone visiting the Lyell McEwin Hospital.
Anyone who was in the LMH emergency department between 5.30 pm Friday 13 November and 4.00 am Saturday 14 November who has not been contacted by SA Health should self-quarantine immediately and contact the SA COVID-19 Information Line on 1800 253 787.
In addition, anyone who was at Parafield Plaza Supermarket on Thursday 12 November between 10:30 am and 11:30 am should monitor for symptoms and get tested as soon as symptoms appear.
The local Councillor for the City of Salisbury, Beau Brug is covering these announcements on his Facebook page – here
If you think you may have been exposed or have symptoms, a Popup Testing Site has been set up at Parafield Airport. SA Health Facebook
Updates
Monday, 16 Nov 2020 – The event is now being called the “Parafield Cluster”, and now has 17 cases.
Contact Tracing details from SA Health – Includes locations (eg. shops) and services (eg. Bus services) with details of where and when contact with the virus may have occurred.
Affected locations (check the above site for specific times):
Elizabeth Vale, Lyell McEwin Hospital
Elizabeth, The Aquadome
Mawson Lakes, Mawson Lakes School and Preschool
Salisbury Downs, Thomas More College
Parafield Plaza Supermarket
Port Adelaide, Hungry Jacks
Anglicare SA Aged Care Facility, Brompton
Yatala Labour Prison
Salisbury Bus Interchange
Salisbury City Fruit Bowl
Elizabeth Shopping Centre, Harris Scarf
Hollywood Plaza – Surgery, Woolworths, Star Discount Chemist
Mantra on Frome
Enfield, Ekam Indian Groceries, Enfield Plaza
Mawson Lakes, Mint Leaf Lounge
Adelaide, Bus Stops – Internode, Grenfell St; GA1/GA2/GA3 near Train Station
Adelaide, Metro Convenience Pty Ltd, Waymouth St, Adelaide
Monday Evening, 16 Nov 2020 – Additional locations:
Ingle Farm, Coles, Ingle Farm Shopping Centre
Pooraka, On The Run, 126 Bridge Rd
Woodville South, Woodville Pizza Bar, 1/58 Woodville Rd
Tuesday, 17 Nov 2020 – Additional locations added, see contract tracing page for times:
Parabanks, Namaste Supermarket
Eastwood, Adelaide Eye and Lase Centre, 215 Greenhill Road
Edinburgh, SA Structural Steel, 5 Kaurna Ave
Elizabeth, BigW
Fulham Gardens, Community Centre – Festival of Lights Function
Findon, Woolworths
Gepps Cross, Spotlight
Mawson Lakes, Foodland
Parafield Gardens, Martins Road Family Medical Practice (Podiatrist)
Woohoo! A new project, or at the very least some new stuff to learn about. It’s been a while since I learnt about the basics of VLSI design and, in particular the ‘Magic’ chip design software package.
Google have just announced that they are partnering with SkyWater Technology Foundry to produce the “SkyWater Open Source PDK“, to produce a fully open Process Design Kit, for producing VLSI Chips. The 130nm process isn’t the newest, but it is still suitable for a variety of hardware applications.
As part of this collaboration, Google has also announced that they will be sponsoring a chip fabrication run later in the year, completely free for the chosen projects, when all the project code, file and documentation is Free and Open Source.
I’m not sure about you, but I have always loved the thought of producing a custom designed chip, otherwise known as an ASIC (Application Specific Integrated Circuit). There is going to be a whole bunch of things that I am going to have to learn, but being involved in the process of producing something like that will be awesome.
The aim is produce the design with cells provided in the SkyWater PDK. The initial proposal is that there will approximately 10mm^2 apace available (Maybe 3mm x 3mm). The 130nm process would there allow an area of 10,000 x 10,000 transistors ( Very roughly, if the transistors were 300nm in size. 3×10^-3 / (0.3 x 10^-6) = 10 x 10^3 )
Any-ho, this should be a lot of fun… and the Skywater-PDK Slack community has been particularly helpful.
After two years of delay, our household now has a chicken coop and five chickens (Bigbird, Tiny, Rose, Flame and Raptor).
Part of the plan other then getting the birds to produce eggs, eat garden waste, poop and generally scratch around, was to use this opportunity to turn their humble home into a Super Chicken House..
Currently, they need to be shut in and let our every day which which is not much of a chore but still needs to be done. Also, it would be nice to know when there are eggs to be collected, and if they need more water or food. Some temperature monitoring might also be ‘cool’ as well as air quality sensing.
As an acknowledgement to some other great work being done on home automation, the name and logo of the project had been blatantly copied and modified from Jon Oxer’s SuperHouse Automation business. (Does this classify as Fan art?)
Solar Power
I was struggling to find a reasonable cheap way to get power to the SuperCookHouse. I had some sets of solar powered garden fairy lights, several different models to experiment with. They all had internal batteries which charged up during the day and then automatically switched on at night.
The smaller units had multiple outputs on for their LED’s (three wires) which allowed them to have some interesting twinkle modes. They were cheaper, but they only contained a single Ni-MH battery. The larger unit had three batteries (see image below) but only had a two wire LED output. The cases themselves also had some rubber seals for waterproofing.
In the larger unit the output from the charged batteries was 4.1V. This proved sufficient to power up a Heltec WiFi LoRa 32 (V2) board which I had at hand. This was connected directly across the batteries.
This connection bypasses the power switch and the flashing circuit of the solar panel board. The batteries should still be able to be charged via the solar panel.
Briefly looking at the control board, with some hackery, it should be possible to make use of the on/off switch to control external power, but two other modifications would also need to be made;
bypass the flashing circuit
disable the ‘power off’ function when the solar panel is in light.
This work has been left to a time in the future.
Update: The batteries powered the module, as it was without any sensors, for about three hours.
Update 2: It looks like the chip SC24C02 (ATMEL268 24C02N) is an EEPROM 2-wire 2K memory chip (Datasheet). Pins 5 and 6 are the Serial Data (SDA) and Serial Clock Input (SCL) respectfully, which are routed up to pins 2 and 3 on the other (currently unknown) package.
Work has begun to create a robot for dispensing short stories at the touch of a button for Writers Week in 2020. The Storybot will be located in one of the Port Adelaide Enfield libraries and will print from it’s collection of pre-curated stories onto paper via a thermal printer for library patrons to take away with them.
Design
The initial design of the Storybot uses the following parts:
Raspberry Pi 4, with MicroSD card
Thermal Receipt Printer, USB (24V)
Button, resistor (220 Ohm) and connecting wire
Power supply (for Rasperry Pi and Printer)
Enclosure and stand
Intial print testing was done with a regular Canon USB Pixma printer.
Software
A repository of the code created for the Storybot can be found on GitHub. This repository ‘storybot’ is cloned directly into a subdirectory of the ‘pi’ user (in our case we are using ‘Document/git’).
The Raspberry Pi used has the most recent Raspbian installed which has been updated to the latest packages.
In addition, the CUPS Printing package has been installed, which allows Raspberry Pi to print to any of the supported printers including the receipt format thermal printer. This printer prints 40 column per row with a fixed width.
A quick solution[1] for selecting a random story used the ‘fortune‘[2] package.
Stories are copied to a directory on the Raspberry Pi as individual ASCII text files. Some example files have been created for testing purposes[3]. A global data file and index is created from these files, while also reformatting them for a 40 character line length. Fortune reads these files, and will extract a story and print it.
Story management is driven by a global Makefile with the following targets:
make help - this message (default) make story - display a story make prepare - compile the stories into data file (This will be run automatically, if required.) make list - list story files make clean - reset system by removing generated files make status - display system status
This system allows dependencies to be managed, so that ‘make prepare’ would be run if it is required and hasn’t yet been run, before ‘make story’. This allows new story uploads to be done even while the system may be printing.
Printing is done by sending (piping) the story output directly to the default printer with
make story | lpr
To detect a button press, where a button has been wired up to a GPIO pin, there are several options available. These still need to be investigated, but they include: Node-RED, WiringPi (C code and used in a previous project) or RPi.GPIO (Python)
Node-RED: This is a large-ish application, but it works well and does not require any addional configuration on system start-up and shut-down.
WiringPi: This C/C++library is useful for creating lightweight binary programs, but requires additional configuration to enable the created files to restart on reboot/startup. It is no longer being activity supported by it’s developer, but is open source software.
RPi.GPIO: Python library that together with Python makes writing scripts that interact with the GPIO on the RasberryPi very easy.
Each of these approaches will need to take care of button bounce/noisy inputs, and stop multiple press events happening in a short period. Some hardware conditioning may also be necessary.
Notes: [1] Very quick. There are no options for recording any statistics about which stories are printed, or when, which might be a useful thing to record and report on. [2] The fortune package has a very long history, originally appearing in very early editions of UNIX operating systems. [3] Stories fro testing were created from the inital paragraphs from “The Princess Bride”, “War and Peace” and “A Tale of Two Cities”.
In the last part of this blog post series, we look at pulling everything together with InfluxDB and Grafana to store and display outr IoT sensor data.
Tools to Collect and Display Data
In the workshop we are using the following software tools for processing our collected data.
Node-RED – Receive, Process and Push IoT sensor data
InfluxDB – Store the time series of sensor data
Grafana – Display and manipulate the data visualisation
These packages can easily be installed on a Ubuntu system (desktop or laptop) as well as Raspberry Pi Raspian system[1]. In the following I have included the instructions for installing on Ubuntu.
This combination of software will allow data to be displayed is graphs which can be interactively arranged and manipulated, and shared with multiple users on your network.
Node-RED
The installation and configuration of Node-RED was discussed in the previous post. An additional module needs to be install to allow Node-RED to send data to InfluxDB.
node-red-contrib-influxdb
InfluxDB
InfluxBD is a time series data store, which is like a database, but different. It is designed for storing and retrieving sequential data which contains timestamps in a more efficient way.
To install
$ sudo apt install influxdb influxdb-client
It uses the default port of 8086.
Before we are able to start storing data, a database needs to be created in InfluxDB, which we can then push our time series data into. This is done from the Linux commad line ($) as follows: First open a influx prompt (>), then create the ‘iot’ database.
$ influx -precision rfc3339 > create database iot
From the influx prompt (>) you can find out more about the available databases
> show databases
Node-RED can then be configured to push data to this database with the InfluxDB output node, configured as follows.
A flow can then be configured to pull the data from a Node-RED message and send it to the InfluxDB.
The function used to extract moisture data (analog to digital data in the range 0-1023) is as follows. An additional format check (message starts with “Sensor”) has been added in case some other format is received. The device (device_id) that is reporting the data is specified in the ‘msg.measurement’ field.
var payload = msg.payload.payload_fields.receivedString var dev_id = msg.payload.dev_id var re = /^Sensor/; var moisture = 0.0; if(re.test(payload)){ payload = payload.substring(10) var integer = parseInt(payload,16) moisture = integer/1024.0 * 100.0 } msg.measurement = dev_id msg.payload = moisture return msg;
Grafana
Grafana is a graphing and visualisation package. It can display the information from InfluxDB[3] and display it.
When logging in for the first time, you can use any username and password and you will be then prompted to change it.
Grafana is a very powerful piece of software but does a good job of helping the first time user through the initial setup. It is recommended that you have a read through the Getting Started documentation. The following is a very brief summary of the confugration process, and I have glossed over a lot of the details.
Once you login in, you will then be prompted for a data source. The details to connect to the local InfluxDB is as follows. Click and set the URL to http://localhost:8086 (it may just be displayed in grey which is a trap). There is no username or password needed if InfluxDB is installed as mentioned above.[5]
Grafana plots are configured by specifying a data query. In this case we are looking for data from the ‘iot-workshop-1’ device.
The following resulting plot came from defining two data queries for two IoT devices. The second one was configured to generate random data at 10 second intervals for testing purposes.
This series of posts covered the process of building a private IoT platform for collecting and displaying sensor information that uses the Internet to move data about but does not rely on cloud or other 3rd party hosted services other than The Things Network.
There are no ongoing charges or fees with this system, and it is a good introduction to software which can then be adapated for other purposes. Have a look for YouTube videos on how to connect Node-RED to home management systems (Google Assistant or Amazon’s Echo) or create different dashboards with Grafana plugins