PC Pro

PAU L OCKENDEN

Paul untangles the power demands of IoT sensors before revealing a Wi-Fi module that can last several years on a single AA battery

- PAUL OCKENDEN

Paul untangles the power demands of IoT sensors before revealing a Wi-Fi module than can last several years on a single AA battery.

So much IoT and other datagather­ing kit is powered by batteries these days, particular­ly the sensors. It makes sense too, with a weather station being the perfect example. It’s fine for an indoor unit with a display to be plugged into a power supply, but temperatur­e, wind and humidity sensors must be sited outdoors, and the last thing anyone wants to do is run power and signal cables to the bottom of their garden. Wireless comms and battery power are perfect for this.

Indoors, too, it makes sense for

IoT kit to use batteries. I have a sensor on my patio doors and if the door is open for more than a minute then my system automatica­lly turns the heating down in that room; I don’t want to pay to heat the garden! Again, I wouldn’t want to run wires to the various sensors on my doors and windows, so wireless and battery power makes sense.

Speaking of heating, I use Resideo’s Evohome system, so have a remote controllab­le thermostat­ic radio valve (TRV) on every radiator, allowing me to schedule different temperatur­es in every room of the house. These TRVs are wireless and each contains a couple of batteries – just imagine having to run a cable to every radiator. Evohome uses a proprietar­y communicat­ion protocol called Ramses II. It’s quite mature, having been used for many years by Honeywell before it spun off Resideo as a separate company.

So there are all these bits of kit sending wireless signals all over the place, which means lots of batteries. No sane person wants to change a battery somewhere in the system every other day, so these devices are all built with power frugality in mind.

Let’s go through the systems I’ve already mentioned. A weather station will typically use one-way comms at 443MHz. The sensors power up, send a burst of data and then quickly power back down again. There’s no waiting for an acknowledg­ement signal – just transmit and then back to sleep. These 433MHz sensors typically use Manc hester, Differenti­al Manchester or Biphase Mark encoding to give the signal built-in integrity and robustness, but certain sensors use simple on/off keying with no encoding at all. Whichever method they use, it’s all very power efficient because of the short duty cycle.

Another optimisati­on is that temperatur­e sensors won’t just send data every ten minutes, say: they only transmit data when the temperatur­e has changed by a certain amount. This is why some systems only record temperatur­es to the nearest 0.5˚C; it m eans far fewer transmissi­ons than if every change of 0.1˚C is sent, and so the battery will last many times longer. The same applies for other slowchangi­ng analogue signals such as humidity.

The door sensor I mentioned that saves me from pouring heat out into the garden is a Z-Wave model from Aeotec. The Z-Wave system communicat­es at 868.42MHz in Europe (never

buy sensors from the US because they use a different frequency and are inoperable with UK systems). Unlike with the weather station, Z-Wave is a two-way protocol, meaning a device knows whether its signals have been received. Sensors are made power efficient by sleeping a lot, only waking up when they need to transmit, and having low sleep power requiremen­ts. Also, because the system is meshbased, the radio signal can be relatively low powered – it doesn’t need to transmit to the far end of the house, only to the nearest plugged-in device (permanentl­y powered devices such as switches and dimmers act as repeaters, while battery-powered kit doesn’t because it’s usually asleep).

Z-Wave has always been frugal when it comes to depleting batteries and it’s been through a few revisions, each of which has made this aspect even better. My door sensor uses the Gen5 version, which you might also see referred to as 500 Series or Z-Wave Plus. Some manufactur­ers are now shipping Gen7 devices, but Gen5 is the most common at the moment.

Gen5 products have at least twice the range of previous Z-Wave products, anything from a 50% to 100% increase in battery life, and they also have greater bandwidth and much improved noise immunity.

My door sensor is rechargeab­le, and that’s actually quite rare for a Z-Wave device. Most of them use disposable batteries, some in quite obscure sizes such as CR14250 (1/2 AA), 4LR44, CR123A and CR2. Sometimes they take button cells such as CR2016 and CR2032. This means that you probably won’t be able to stock up when you do your weekly supermarke­t shop, although a bulk order from an online retailer will be cheaper anyway.

I mentioned my Evohome heating system. The TRVs each contain a couple of AA cells that not only power the communicat­ions side of things but also the motor that opens and closes the radiator valve. Amazingly, given this mechanical involvemen­t, a couple of good quality alkaline cells will last for a year or more. I’ve switched to using lithium AAs, though, as they last twice as long.

They cost more than twice the price of alkaline cells, so there’s no cost saving, but I’m happy to pay extra knowing that I won’t have to faff around so often.

Bowled over by Cricket

Have you noticed a common thread between all of the devices I’ve mentioned so far? It’s something that applies to other battery-powered things too, such as wireless burglar alarms and even most radio frequency (RF) remote controls. The common factor is that none of them use Wi-Fi.

That might seem strange at first. Wi-Fi is well known with many chipsets out there that support it and lots of existing support libraries. The trouble is, Wi-Fi can be slow and also power hungry.

Slow? Surely Wi-Fi is a heck of a lot faster than all the other protocols I’ve mentioned? Well, yes, if you’re looking at sheer throughput. With something like a temperatur­e sensor, though, we’re talking about such a tiny amount of data that it hardly matters whether it arrives at gigabit or carrier pigeon speed. Where Wi-Fi is often slow is in the communicat­ion setup every time the device wakes up. Typically, the code that drives Wi-Fi is quite large, so even the waking up takes a while. Then the Wi-Fi chipset has to be brought online, has to hunt down the signal from your router, establish a connection, authentica­te, obtain an IP address and a few other fiddly bits in between. between As a result, result

“The battery is more likely to reach its use-by date than expire from powering a Cricket!”

where a simple

433MHz temperatur­e sensor will wake up, broadcast its reading and power down again in a fraction of a second, with a Wi-Fi-based device that will usually take many seconds.

This affects battery life: the longer the hardware and firmware spends faffing around, the more juice is drawn. But, even if you ignore that, Wi-Fi is inherently power hungry. It’s just the nature of the beast. Although it was designed to support battery-powered devices, these tend to be things such as laptops, where the batteries are substantia­l. The MacBook Pro I’m typing this on has a 95Wh battery. A CR2016 button cell has a capacity of 0.3Wh. So my laptop battery contains over 300 times the oomph of the battery that might be powering a wireless sensor.

It’s bonkers to use Wi-Fi for battery-powered sensors then? Well, no, because Wi-Fi has a lot going for it, including better range than many of the alternativ­es. Also, because Wi-Fi is IP-based, a device can squirt data directly into something such as a home automation system or a cloud-based IoT repository without going via a separate hub. There would be much to commend it if someone could product a cheap Wi-Fi based board that was able to last a long time on batteries…

You’ve guessed where I’m going with this, haven’t you? There’s a company in Cambridge called Things On Edge ( thingsoned­ge.com) that has come up with a Wi-Fi-based IoT module called Cricket.

Cricket has a lot going for it. First, it’s cheap at £16, including postage. When triggered it hops on and off your Wi-Fi very quickly. And, best of all, it’s extremely frugal when it comes to power consumptio­n. If you use it as a temperatur­e sensor nsor that updates every very hour or so, the Cricket ricket module will run for or a whopping six or seven even years on a single AA battery. In fact, the battery is more likely to reach its use-by date than expire from powering a Cricket!

The tiny module has five usable connection­s. There’s

a positive and ground connection for the battery, a combined digital and analogue input, a wake-up connection that forces the board out of sleep mode and a stable 3.3V output.

The module is very tolerant of supply voltages, working on anything from 1V to 3.7V. This means it’s ideally suited to working from standard AA or AAA batteries, in either one-cell or two-cell configurat­ions, and because it goes up to 3.7V you can also use a lithium-polymer slab battery. If you want to plug it into an existing 5V power supply (a phone charger, say) or the 12V supply of your car, you’ll need a step-down regulator, which costs £1 or less from the usual online retailers. The fact that you can get it to work from just a single AAA battery is brilliant, though.

The input pin is quite configurab­le. You can set it as a digital input where it will work with any logic levels between 1V and 3.5V, or you can configure it as an analogue input. The range here is 0V to 3.5V, and you can set the resolution to between one and eight bits. The more astute reader will wonder whether one-bit resolution is the same as setting it to a binary input, but it isn’t. With one-bit resolution the crossing point is 1.75V, whereas, like I said, as a binary input it can use 1V logic.

The wake-up connection is exactly what it says, but interestin­gly it can be configured to trigger a different action than the other input, so it’s effectivel­y a second digital input. Which is neat.

Connection­s are via plated through-holes on the PCB. You can solder wires or pins to these, but if you plan to do a lot of experiment­ation then you’re probably better off soldering a screw-down terminal block to the board. Six-pin connectors are available, but not common. Three-pin versions are readily available and cheap, so I suggest that you use two of those if you can’t find a six-way part.

As well as the external input, the module has both a built-in temperatur­e sensor and a real-time clock (RTC), which can be used to wake up the device at regular intervals.

Configurat­ion is all done over the air via a web-based portal. Head to dev. thingsoned­ge.com, create an account and then register your module. You’ll need the serial number, which is printed in big text on a label on the underside of the circuit board.

Next, you’ll need to connect your Wi-Fi, a one-time thing that you won’t ever have to repeat. Or rather, not unless you change your Wi-Fi network. There are two ways to do this but by far the easiest is to use the Things On Edge Android app. The alternativ­e is to connect to a temporary mobile hotspot on the module directly from your PC and enter the config details on a web page that’s hosted on the device.

The only problem I encountere­d with Cricket is that it didn’t like wireless SSIDs that included a space in their names, but thankfully the latest firmware fixes that.

Cricket has two ways to offload its data. The first is via MQTT; I don’t have room to write an in-depth explanatio­n of what MQTT is here.

The short version is that it’s a lightweigh­t messaging system designed for passing small elements of data from one machine to another. Lots of IoT “things” are designed to use MQQT. It uses a publish and subscribe model, with a “broker” server sitting in the middle. The publishers send data to the broker and subscriber­s retrieve the data. The beauty is that the subscriber­s and publishers don’t need to know about each other and don’t require, say, fixed addresses. They simply need to be able to access the broker. Things On Edge offers a free cloud-based MQTT broker for Cricket users, but you can also use your own.

Cricket can also talk to the outside world via webhooks. You basically give it a URL and drop in variables such as #temp for the temperatur­e and #batt for the battery level. Using this you can easily squirt data into a home automation system such as Domoticz, or trigger things in IFTTT. It took me less than ten minutes to set up a test so that when I pressed a button Cricket fired off a call to IFTTT, which in turn generated an alert on my phone and sent me an email.

That’s all great, but the thing that’s really impressive is watching the little blue LED on the Cricket module as it wakes up, connects to the Wi-Fi and transmits the data – this usually took less than two seconds in my tests .

I’ve never known a bit of kit that can operate so quickly via a Wi-Fi network. These are the kinds of speeds you expect to see with kit based on Z-Wave. And, of course, this rapid

“do your stuff and go back to sleep” really helps to conserve battery life. Especially as Cricket goes to sleep completely – proper, zero-amp sleep. Until it wakes there’s no drain on the battery whatsoever.

Even though it powers down completely, Cricket still remembers the previous value for things such as the temperatur­e, battery and input port. And it will only fire up the Wi-Fi and send the data if it has actually changed. If everything is the same as last time then it just goes straight back to sleep. There are things such as controllab­le analogue resolution and moving averages that can reduce the traffic and improve battery life even further.

If you’re into all things IoT then I thoroughly recommend giving Cricket a go. It’s an absolute steal at just £16.

“I’ve never known a bit of kit that can operate so quickly via a Wi-Fi network”

 ?? @PaulOckend­en ?? Paul owns an agency that helps businesses exploit the web, from sales to marketing
@PaulOckend­en Paul owns an agency that helps businesses exploit the web, from sales to marketing
 ??  ?? BELOW With Evohome and a bit of trickery, I don’t have to pay to heat the garden…
BELOW With Evohome and a bit of trickery, I don’t have to pay to heat the garden…
 ??  ?? BELOW Cricket: it’s tiny, cheap, and lasts for absolutely ages on a single battery
BELOW Cricket: it’s tiny, cheap, and lasts for absolutely ages on a single battery
 ??  ?? ABOVE The wellcamouf­laged Z-Wave from Aeotec. Sadly, the cat isn’t included
ABOVE The wellcamouf­laged Z-Wave from Aeotec. Sadly, the cat isn’t included
 ??  ?? ABOVE You can easily ping data to Domoticz or receive Cricket alerts from IFTTT
ABOVE You can easily ping data to Domoticz or receive Cricket alerts from IFTTT
 ??  ?? BELOW Howzat?! Cricket is configured via a user-friendly online portal
BELOW Howzat?! Cricket is configured via a user-friendly online portal

Newspapers in English

Newspapers from United Kingdom