Cat-as-a-thing in IoT: tracking cat walks with LoRa, BroWAN sensor and TheThingsNetwork
Raised in a busy city, I always wanted to live in a quiet village - but with all city facilities nearby. When I bought my house in a lovely place called Duivendrecht (which is closer to Amsterdam centre than half of Amsterdam own districts), it was like a dream location — it is a quiet and green low residential density park zone — yet allows quick commutes to all vital destinations.
I also love cats, but keeping a beautiful and curious animal confined to an apartment just never felt right to me — a cat must be free to roam outside, scouting and sniffing, feeling the wonderful world around. In their furry heads, highly efficient neural networks, evolved by the millions years of natural selection, capable to map vast swathes of terrain to navigate across, may not stay idle.
It was just a question of time, before I got some beautiful soft furry creatures in my new house.
Being an engineer myself, I wondered what the gadget industry offers, how could I integrate my cats into Internet-of-Things, to let them walk outside and be able to find them back, should they get lost or in danger?
First, I ordered portable object locators, sold as pet trackers, from Invoxia, Findster, Tractive and some others, to check how all that really works. To express my deep frustration with all these solutions, another full-size article would be required, so I’ll be short — they all suck in some way. The main user story — finding a cat — is not implemented properly in any of these products.
Besides, paying monthly SIM fees of at least EUR 5,- for SIM-based trackers (and most of the trackers offered are SIM-based), didn’t appeal much to me. For that money, they all still seem to have pathetic connectivity quality, like 2G/WAP internets of the 20+ years ago.
So I wondered, maybe there are some ‘plain’ radio solutions that won’t require overhead of a SIM card. After all, a tracker is not a phone — all the tracker needs is to send small packets with the coordinates, once in few minutes. Of all trackers I bought, I still use SIM-free Findster only — it is SIM-less and realtime. But Findster is created for dogs, not for cats. It drains the battery really quickly, when tracking the walk. The advertised range of Findster being ‘800 meters in urban conditions’ looks like wishful thinking, at best. Even in low-density residential area I happen to live it is frustratingly short, about 100 meters.
LoRa and The Things Network
Googling around, I found that there’s a recent radio standard called LoRa, which is designed exactly for that — reliable and accessible radio communication for low-throughput IoT appliances. LoRa uses non-licensed public bands such as EU 868MHz. It also utilises efficient chirp modulation, originally developed for the military, to ensure radio waves go around the corners, ensuring energy-efficiency and robustness even without clear line of sight.
Gateway and base antenna
The Things Network offers inexpensive gateways, the cheapest being Indoor Gateway for about EUR 70,- It was also quite easy to set up, hook to WiFi, at one side, and configure in TTN console - in almost no time.
The only problem is that it is indoor — it has a printed, embedded antenna. It works reasonably good inside the house, but not really reaching anywhere else. Fortunately, connecting external antenna solves that, and the hack is as follows (no soldering needed!):
- order external antenna (e.g. Aurel GP 868, EUR 40,-)
- order IPEX-to-antenna cable adapter (in case of Aurel - IPEX-to-BNC-female, EUR 3,-)
- open the gateway case, disconnect internal antenna from IPEX socket on the gateway’s PCB and connect the external BNC via adapter cable.
With that upgrade, I was able to see traffic from multiple IoT LoRa devices around, all picked by my gateway. But as each device sends just few bytes once a few minutes, it’s a tiny fraction of my internet line, not to compare with Por… I mean, YouTube traffic. Besides, you get a great feeling of doing something together with other LoRa geeks: the TTN community members run the gateways and serves each other’s devices, providing free network coverage.
There are several object locators with LoRa radio available on the market. I tested some of them, and the only suitable one turned to be BroWAN Object Locator. Others were either too heavy/clumsy, or with unchargeable battery, or impossible to configure.
It weighs just 28 grams, has 540 mAh battery and is activated by accelerometer (on movement). The fixes are pretty good, the battery lasts for about 8-10 hours, if updates are sent every minute.
But if I were a cat, I wouldn’t fancy roaming around with such thing hanging on my neck.To put the tracker on the cat, in cat-friendly way, I bought a Trixie cat walking harness, and improved it a little bit — applying my modest sewing machine skills.
All leashes were cut, some Velcro added on the strap around the neck to let the cat breathe freely — while holding it on the cat reliably.
Two bright yellow-neon Velcro-sealed pockets added on the sides, to carry the equipment inside. Neon isn’t just a coincidence — this blue/gray cat’s coat is in fact nanomaterial that blurs shades of gray depending on the angle of light, effectively merging the cat with the background. Making Escobar stand out is beneficial for both the cat’s safety (as in “not being squished by a car”), and for the birds.
The birds. Because this furry ultimate killing machine, in full camouflage, armed with premium precision movements and millisecond-order reaction times, would otherwise murder the local birds in vast numbers, disrupting the fragile nature of the lowlands kingdom I happen to live in.
To tip the life-and-death balance further in favour of the birds, I also added a little bell on the top of the safety jacket — so that Escobar could fulfil the noble role of apex predator by just keeping birds fit, without killing them. Or, putting it another way, if a bird isn’t able to spot an approaching cat with bright yellow-neon stripes and a bell attached, and get away unharmed, then the cat may apply for a waiver: for this particular bird, Darwin’s laws may prevail over human-animal ethics.
While improving safety of both the cat and the birds, the pockets also allow to carry around the needed equipment: at the moment, Escobar roams around with BroWAN sensor on one side, and also Findster and Tile in another pocket.
Why all that extra stuff? I’d be happy to have all needed functionality in just one sensor, but this device doesn’t exist yet. BroWAN sensor has a reliable long range, about 1 kilometer from my rooftop antenna and covered by other TTN nodes otherwise, but has no buzzer to activate when nearby. Findster is a backup, as my setup with BroWAN is still experimental.
Tile has about 10 meter range in which it can buzz when a button is pressed on the phone. Tile helped me finding the lost jacket on three occasions when it wasn’t properly strapped — Escobar came home happy but naked, and I had to talk to the neighbours, to rescue the jacket from their gardens. Buzzer is absolutely an essential feature for an object locator.
Recently I spoke to BroWAN, they were keen to listen to my use case (cats and kids) — and I hope they could integrate buzzer in next generation of their sensors!
Fortunately, Escobar the cat is strong enough and eager to explore the neighbourhoods with all that hardware strapped on his back, about 2–3 kilometers per day, when I’m still adjusting the software part of the setup.
Yes, so far, it was cats’n’hardware story, and now the software part. Here’s how the solution architecture looks like.
The tracker carried by the cat broadcasts packets every minute (for now, it also could be adjusted by sending a downlink message to the tracker). The packets are picked up by one or more LoRaWAN gateways in vicinity. Each packet consists of just about 50 bytes, and contains, along with headers and some metadata, location fix and battery charge.
The gateway adds a wrapper around the packet, with gateway details, signal-to-noise ratio etc. and sends it to the network (TTN). In the TTN console, each device (tracker) is configured to be part of an application: a group of devices and the way to process incoming packets.
TTN application defines a function to convert raw bytes coming from the tracker into a meaningful structure.
For BroWAN, the code looks like this:
In TTN, there is an HTTP integration configured to post updates to the catracker application, that keeps tracking device and pushes updates to the browser via websockets, to see the cat’s route, as he roams.
There are not so many features at the moment, just connect and see the tracker moving, in real time, and also time since last update.
I plan to add alerts on drained battery and ‘no movement’ alerts (meaning that the cat is either sleeping, or lost his jacket again) via Telegram bot, to make it complete. Also extending periods between transmissions, when battery about to run out, seems useful. Geofencing alerts, too.
The full implementation, inclduding backend (Scala), frontend (TypeScript), Azure DevOps pipeline and Kubernetes descriptors is available under: https://github.com/jacum/catracker
Many thanks to TTN — for reliable and inexpensive hardware and console integration and to BroWAN — for best-of-breed LoRa trackers.
And of course — to Escobar for all his testing efforts!