Environment sensors

As mentioned in the last post I’ve been experimenting again with my LoRa setup and have got my RAK831 gateway running again. Previously I’d used the excellent Balena containerised device control, but the image I was using with it seemed to stop working with the RAK device so I swapped over to using the full tool-chain supplied by RAK themselves and built from their new generic git repository. This worked well and my gateway is live again on The Things Network.

I also purchased and installed the excellent Things Network Indoor Gateway at my work location, and this is running well using the building’s WiFi for back-haul. I’ll distribute environment sensors with the facility manager’s permission around the campus to start measuring conditions such as temperature, humidity, frost levels and external gates opening.

Closed source LoRa device for temperature, humidity measurement

I also found and have started experimenting with the Dragino series of LoRa sensors – I’d have to comment that as a Chinese manufacturer they seem more experienced with producing for a world-wide market, and devices are relatively low priced for mass consumption. The sensors such as the LDS01 and LWL01 easily fit what I need without being in the hundreds of euros bracket. While using development platforms such as the Pycom LoPy or Adafruit Feather devices is better for code development, they do require cases and batteries for waterproofing and field-hardening which take cost and effort to make. A manufacturer can source these in bulk to reduce cost and test before shipping.

I will continue with the Pycom devices for the simple reason that I like tinkering with code, and they are fun to understand the internals of IoT. I also need them for things that do not have a LoRa component such as my remote weather station and my gateway tracking.

These Dragino devices work well and I have started looking at setting up a dashboard for my devices, once they are installed. So far I have looked at:

  • MyDevices, inventors of the Cayenne IoT format which is helpfully produced and consumed by some devices and dashboards.
  • DataCake, a useful European data provider that has a large library of devices already coded into their dashboard.
  • ThingsBoard, DevicePilot, and others are only a Google search away
  • … or self-host using the NodeRED dashboard, my preferred solution if I can get space on my work’s infrastructure for a virtual image.
NodeRED dashboard

Low power for sensors

Following on from my research in sensors for ice detection, I’ve been looking at the different modules available for environment measurement that transmit using LoRa. The ‘development’ platforms I am happy with should use MicroPython (or CircuitPython or variation on same) since I develop best in that language.

Low power is also important – long ago I realised that Raspberry Pi and SBC-type platforms that ran Linux were better on powered supply, as they consume too much current even when doing nothing. Nobody can really run a remote RaspberryPi off-grid, even with large power supplies such as USB cells they quickly deplete. As well, anything that uses WiFi is out as that is a very chatty interface and seems incompatible with low-power embedded operation. Adafruit has a great page to help decide on which processor fits your requirements. The devices I’ve considered:

  • M5Square – a block-building format that clips together the different components so you get a computing base, never tried but seem to have a comprehensive lineup
  • Pycom – I’ve used their various modules from the early WiPy through LoPy (and struggles to get low-power working) and found they are ‘acceptable’ to wrangle into a working module
  • Some sort of ESP8266-based platform such as the Wemo D1 mini and those based on the Expressif ESP32 chips
  • Adafruit and their Feather range of development platforms such as those based on the ESPxxx but more recently on the ATmega32u4 and variations

While all of these are good it is probably more import to choose a platform and stick with it – “a long obedience in the same direction” and all that. The other consideration is how low can they go? Not all chips faithfully power down well and I know that Pycom struggled to get the Expressif ESP32 chips down to very low power. Apparently they can go as low as 25uA for ULP consumption and 1uA for LoRa in standby. Comparing with the Adafruit they say that you can achieve 300uA (0.3mA). This is not as low as the Pycom chips but I am willing to experiment with both to see which performs best.

Although I’ve played with the ESP8266-based ones and have had several successfully running, but as they are primarily a WiFi-based system I will not use them. You also have to remove the LUA software platform and re-flash the µPython environment to get them working. I also won’t attempt the M5Square ecosystem as it would mean purchasing a whole raft of new chips and understanding how to program them. So it is either Feather or LoPy – I think I’ll experiment with both.

Ice detection for footpaths

In my role as a caretaker for a large facility with car park and pavements I need to detect hazards and mitigate the dangers. The particular hazard I wish to know is when my footpaths and pavements are covered in ground ice so that I can apply grit. My paths get icy and it is barely visible – the image below has ground ice on a resin bound surface and even wearing boots I could skate the entire length of path.

Ground ice detection systems are expensive – they are used to detect conditions where warning signs are illuminated, deicing is initiated, or other remedial actions taken such as applying deicing solutions to airport runways. My needs are humbler than these; I simply want to be informed by text when ice may be present and arrive early to sweep some salt and grit over the footpaths so people don’t fall over. And I’d be more happy with false positives than false negatives – arriving to find that there is no ice is better than missing a day and someone is injured.

I intend to use LoraWAN to transmit the data as this is cheap and simple, and I have experience in coding and running such systems. Finding a detector that is simple, cheap, and reliable is a challenge. The components will be:

  • LoraWAN ice sensor
  • LoraWAN gateway through The Things Network (TTN)
  • NodeRED process to combine weather conditions including temperature, humidity, cloud cover, and wind. The latter two will likely come from a weather service.
  • SMS node in NodeRED to send warning texts

In my searching I found a number of systems that are either too expensive, too elaborate, or I don’t have the technology to produce. I can work with wires, wireless, embedded systems, 3D printed plastics, wood, and some metals such as steel in simple assemblies. Exotic plastics and sensors that require electrical potential are probably beyond my simple facilities, although the electric ones may be possible depending on my battery budget.

Meteorological conditions

There are some good references on the Internet that describe the conditions that lead to ground ice. These are likely to be the same conditions monitored by local council maintenance crews that go out and spread rock salt (called ‘gritting’ here in the UK) on the major trunk roads before a freeze. Mostly, to form ice needs:

  • little or no wind
  • water vapour in the air, or water on the ground from rainfall
  • clear skies without cloud cover
  • low temperatures, below freezing point

One way to monitor these things is to use weather sensors and meteorology reports. I could take feeds from something like Weather Underground and combine them, however standard measuring instruments are normally sited well above the ground surface so do not accurately measure the temperature on the ground.

Ice Sensors

Ice sensors come in a variety of implementations from mechanical to electrical through to optical using thermistors or other IR sensors at a distance. Some are well known in the aircraft runway industry while others are more suited to road surfaces. All the commercial ones cost in the hundreds or thousands of currency, and generally come as part of an integrated system with controller, reporting mechanism and loggers.

I need something under 50 $/£/€ so that I can afford at least a couple of them – one locally for reference, one on site to alert me. That rules out most commercial options. In addition even the most well tested commercial sensors only achieved rates of 86% in university tests, therefore I expect less accuracy in my cheap sensors and will tolerate more false positives.


I will likely go down the route of using a LoraWAN embedded item with temperature and humidity, and using a 3D printed case attach this to a tree or light pole near the main affected pathway. I’ll then combine this with cloud cover and wind sensor data – from locally if possible but if not from a weather service.

Smart Mirror

I’m building a smart mirror for my refurbished bathroom. Starting with a damaged LED mirror as the base I already have half of the underlying infrastructure in place. The LED mirror was already wired safely onto the wall and the insulated steel frame had drivers, transformers and other electrical components inside. Since the mirror itself was damaged when I removed it to store during the bathroom refurbishment, I needed a new partly silvered glass and I ordered this in the excellent Mirropane™ Chrome Spy having selected this from the sample pack sent by Brigla-Therm.

Removing the old broken mirror from the frame wasn’t easy! In fact, it was downright scary slowly prising off shards of glass from their glue and I did it very, very slowly. Once removed, I cleaned the old frame and reattached the new mirror glass using bathroom silicone sealant. Light showed through from the overlapped areas behind the white tiled wall so I covered the overlapped sides using black tape.

I chose a VA type of monitor after looking at the discussions on the MagicMirror forum. Apparently these show better contrasts than TN or IPS types, although their response times are slower and less suited to gaming. That’s fine by me – I’m not planning to run anything fast moving on this display as the primary things will be static text and graphics.

The software is relatively simple; I saw one video where the builder said that ‘maintaining JSON was hard’. As a software developer I find it relatively easy so the approach I have gone for is to run the MagicMirror (MM) server remotely in a virtual container and use a browser on a very small client (Raspberry Pi Zero W) to boot and display a single page in full screen mode. I like and admire DakBoard but firstly it is a subscription instead of a one-off cost, and I feel it is also more geared towards the commercial smart mirror provider with billing plans for your remote clients.

I’d also like to control the monitor’s buttons using the GPIO from the RPi but I am uncertain at the moment how to do this. I’d also like to physically turn off the monitor back light when not in use but again not sure yet how this would work. Relays seem an obvious choice.

Power was a challenge as the space behind the mirror is limited particularly in the thickness dimension. Instead of the hulking wall-warts I have decided to build a small soldered breadboard with miniature power supplies to convert from the standard 230V delivered to the mirror into the 12V and 5V needed by the monitor and RPi.

It’s all about us, not about you

Many decades ago I worked on a time recording system for a large business department. This was to be used by a couple of hundred workers who would enter their time as they completed tasks, and then reported back up to managers. It may sound draconian in these days of zero-hour contracts and gig economy workers, but it was common in those days of top-down project management and still is today on major infrastructure projects.

What intrigued me was how a small, important, vocal minority of stakeholders bent requirements so that their needs were addressed to the detriment of the large body of people who would actually use it and enter information. One effect of this was that the workers took the lazy way out and simply reported in large blocks of work rather than the fine-grained estimation needed by the immediate project managers – too many tasks resulted in too little detail and most reported only when they had finished. In effect they ‘gamed’ the system.

But this isn’t just an historical tale. I’ve seen the same feature creep in a number of places. Take the UK government’s Covid-19 tracking app for example. In an excellently reasoned article one of the developers for that app discusses all of the reasons why they are not using the decentralised model offered by Google and Apple. Reading through, I think it is fair to say they rejected the decentralised approach “because it doesn’t help us, only you”. Therein lies the rub.

In all the systems I developed over many decades one thing I came to understand was that complex and intricate things were used less and less by the very people that were needed to collect accurate data. Unless the lowest and least important people use your system, the data is useless. You need buy-in from the very people you didn’t consult, as the whole premise of the system needs them to accurately, faithfully, and happily use your app.

I was a professional developer who is quite happy for much of my information to be online in the right places but I am concerned about the interconnected abilities of this app. Person-to-person interconnectedness takes this to a sinister level, one that reminds me of the worst excesses under the Iron Curtain. Anonymous entity resolution has been used for a decade or more to trace bad guys but a population mapping of this sort can only be dreamt up by Facebook, and we’ve seen where abuses of that led.

I’ve seen all types of ways to encourage, cajole, threaten, and advertise the use of systems and above all, unless the system gives the end user something back they will not use it. Money incentives, managers checking weekly, making it part of yearly objectives, all of these fail unless the system is simple, easy to use and above all helps users do their work. All other stakeholders are secondary consumers of the information and all the scientists, Public Health England, app developers and National Cyber Security Centre staff are not as important as the millions of ordinary Brits who are expected to use the app. Starting off by excusing privacy-breaking controls isn’t the best way to start introducing a new national app. The reason given? “It will help us”, not “help you”. To quote from the article,

“… and, most importantly, (it) provides the insights the public health professionals need to better manage the virus in the UK.”

… from NCSC blog post written by Ian Levy

MOST importantly?!? While other issues mentioned are interesting in a technical way, such not draining the battery and keeping me secure (from whom?) the article in a profound way exposes the general attitude about such systems – it’s all about us, not about you. We need this because we are important, not because you are important. But if we want people to do things, we need to do things for them, not for us.

How to keep you mobile phone clean from virus

During the corona-virus pandemic keep your mobile phone clean by covering it with cling film / saran wrap / plastic wrap before you leave the home. Don’t leave any bits exposed, only use 1 layer over the touch screen by joining the bits together on the back.

Outside, unlock using a digital method such as a password or pin – don’t use the fingerprint scanner! The power button and volume controls should function as normal. Don’t use a corded headset!

Don’t use the camera. While it does work, it doesn’t look good – sort of like a 60’s dreamy filter over everything. Unless you want that. And flash is a disaster as it plastic wrap makes it go everywhere.

When you get home, clean and wash your hands. Then, carefully unwrap the phone and dispose of the dirty plastic wrap without touching any of the contaminated bits.


Building an app

For some time I’ve wanted to automate my caretaker job with some software tools. I guess I’m just lazy, but sometimes the sheer amount of side requests that come through to me is astonishing – every day someone will ask questions, suggest improvements to a building, or report a broken thing. Maintaining the list of ‘things to do’ was a full-time job for an artist using colourful Post-it notes on the back of my door. There had to be a better way, and I looked at CMMS suites as an option – many were excellent and even had a mobile app, however as they were all paid it was beyond my budget allocation which is basically zero unless I pay for it personally.

I’ve just started building a new app myself using some interesting tools. I get too interested in the tools sometimes, sometimes to the detriment of the end result and my wallet. Here’s what I want to do:

I want to capture a list of work and maintenance requests into a data store for review and annotation. Some or most of these will be completed by me, while some will be tagged for inclusion into what we call a “working party” where people come to the church, and work! Some party … but actually, it is a lot of fun to have a group of mostly guys hacking and wracking and packing. The break time is a highlight and we all sit around and talk, which is great.

However in the current circumstances it is impossible to get together in such close circumstances and I’ve thought of running it instead as a type of virtual party, one where volunteers can select a job they think they could do alone, then select a date when I’m available to unlock the facilities, then I would bring along needed items such as tools and materials and let them get on with it alone while I am busy elsewhere in the building. A win-win all around – I get things done, they get out of the house, and the building is repaired a little more.

One of the interesting things I have come across is AppSheet – now part of Google Cloud. It is a simple workflow automation tool set that takes structured data as input and displays it on a responsive display (ie. one that adapts to the display size: mobile, tablet, or monitor) with triggers to different events. I love event and flow programming as it fits my mind better than event-oriented programming or object-oriented programming. And as it is visual I can see the immediate effects and links between different classes and objects. Here’s an example:

Taken from AppSheet examples

I am going to take this and join together the data sources held on an organisation data source and meld it into a ad-hoc work-selection process, hopefully one that allows us to operate and encourage our volunteers – who are mostly older men in the ‘vulnerable’ category – to use their skills while the country is on lockdown.

Mercy Pig

I’m glad Marks and Spencer threw in a bag of Percy Pig chocolate goodies into their essential food hamper that arrived today. Without the pig it may have got the chop. There was no mention on their website as to whether this box was reserved for essential workers such as nurses, care home cleaners, or brick layers but in terms of abundance it was rather parsimonious for £35.

Mercy for the Percy

Still, mustn’t grumble in these desperate times. With even the PM laid low with this fickle disease any food is good food, right? With a household of four adults packed into approximately four rooms it does get a little tight at times. The only blessing I can see is a free one, and the sun pouring down in pretty much unremitting glory reminds me of sunnier climes and gives the excuse to those who take to parks and seaside to do their allotted exercise per day.

I’ve taken to setting up website snoopers to monitor the state of flour supply. It’s absent everywhere and the moment someone offers even larger bags it is offline again in an instant. We bake our own wholemeal and have been doing so every week for the last 5-8 years. I love the stuff and even take it to work as lunchtime sandwiches. But without yeast or flour it is looking increasingly difficult to do that and the spelt loaf we’ve just baked may be our last one…

Food has taken on a strange new obsession with the family. Even my son for who AM is a foreign field awoke to witness the unpacking of the last food box. We are pretty unanimous to this point that the local green grocer is streets ahead with their generous delivery of bread, milk, eggs and a bumper box of fruit and veg for the same price as the M&S one.

We anxiously await the arrival of Morrisons box later this week as their mix seemed a little closer to our eating pattern. Could this become the next version of the annual write-up of Christmas puddings or Easter hot-cross buns?

What are you doing during lockdown?

For the last 48 hours I’ve been printing Prusa face visor frames on my three 3D printers. This has been a mixed success, but I am pleased to say that I’ve now a box full that will be sent off with courier DPD this week, to be fitted with clear plastic visor material and used by front-line health care workers!

Sealed frames ready for shipping to the factory

A couple of things are certain: there will be problems with some of the items printed and supplied this way by over 5,000 volunteers around the UK. Secondly, there will be a portion of the press that focus and comment snidely that it was “less than successful”.

Why do we seek to find the worst possible aspect of everything, rather than acknowledging that nothing is perfect and doing our best? I prefer the motto:

It is better to light a candle than to curse the darkness.

Sadly I hear personal stories from friends who have experienced verbal abuse during this time. It seems that everyone interprets rules differently and will gladly express what they think other people should be doing. As an example, the government allows people to travel to work if they cannot work remotely. But others think this is wrong and write up signs to say “stay home, don’t drive”. Another said they had been sworn at in a supermarket when they got too close to someone.

Rather than curse the government, those who need to travel to work, those who are trying their best to help where they can, or rule breakers (and there are always some). Instead we should celebrate those who are doing what they can and seek to help those less able. Get busy with doing good rather than sit in fear and getting angry.

Looking forward …

Just as the speed of the spread of SARS-Cov-2 has surprised the general population, so too the measures introduced to halt its spread seem to have taken governments by surprise. Here in the UK as little as 2 weeks ago my organisation was discussing guidelines as to how we could safely conduct events (hand-washing, sanitiser at door, no handshakes, asking everybody who came in how they felt, …) whereas now we are at the point of shutting doors and turning everyone away.

Just 2 weeks ago there were plans for mass events such as 450 schoolchildren in a combined concert, civic events requiring bands and full day rehearsals. Building works that would take out whole rooms and working parties of 10-15 people hammering and fixing around the building. All that has stopped with a bang. What will happen in the next weeks, months, and year?

How will life look as we emerge from this?

After the SARS and MERS incidents – when I was still travelling extensively – I brought packs of gloves, disposable masks, and anti-viral drugs. These sat in a drawer until recently but when I took them out I saw that they were inadequate! Gloves have to be gauntlet type to the elbow, aprons have to have long sleeves, and masks need to be disposable, filtering, and include full visor. None of these I had thought of and as a result what I have offers little protection. But at least I thought ahead and waited until the panic had died down before ordering them. Will the world react similarly and prepare for the next pandemic, or will we go back to our short-termism and fail to prepare for the next disease?

Futurists have a terrible prediction rate. Forget sci-fi as a means of prediction – most of the ‘inventions’ are either plain wrong or extrapolate current technologies in ways they just won’t work. Take a read of older sci-fi to see just that: canons to the moon, flywheels powering cable cars across cities, flying cars. A good sci-fi book tells you more about the age in which it was written than as a reliable prediction of the future. While others have written more soberly of this, let’s join the game and take a punt where this will lead us. So here are my predictions, I’ll revisit in a year and see how many came true!

  1. Very large increase in the number of people using technology to connect and conduct work.
    • so transport links will experience lower numbers
    • … and decreased road pollution
  2. CO2 will decrease world-wide, as will nitrogen dioxide and other measures of pollution.
    • while not enough to halt or reverse global warming, it will be a short reprieve
    • the rate of adoption of electric cars will increase
  3. Hyper-local delivery.
    • Micro collection services and ‘last mile’ delivery within the hour will mean less need to physically view objects, and smaller quantities will become the norm.
  4. More distance learning.
    • … but frankly not enough. Why have physical schools when most knowledge is online?
    • I suspect this will be dependent on how long the lock-down lasts – over a year and it becomes ingrained habit, finished by September and everything flops back to normal.
  5. Bricks-and-mortar shops will largely disappear.
    • They were decreasing already, this just speeds it up.
  6. Leisure time activity will increase.
    • 4 day weeks, part-time employments, zero-hours contracts, portfolio incomes and so on
    • Some people may never in their lifetime have a classical ‘job’ as we understood it at the close of the twentieth century.
  7. Massive underemployment and new class of non-workers.
    • University trained graduates who avoid company employment.
    • This is harder to predict but I suspect that either a basic income, payment rations, or new classes of social security.
  8. The organisational structure called a ‘company’ will devolve.
    • Work sites such as Fiver, Upwork and other gig platforms will increase.
    • New organisational structures such as Colony will evolve and broaden their appeal.
    • New payment mechanisms or crypto tokens will grow.
    • Piecework and small seller platforms such as Etsy will increasingly become the main remuneration route for some.

If that last point sounds as utopian as the community rules in the movie The Beach then it probably is. But remember that the structure of the world 100 years ago was very different from the structure we have now, and the next 30 years are likely to see massive changes.