1 Cat, 3 Clouds — Where is Snowy sleeping?

Where is Snowy?

Goals & Requirements

With limited time, I wanted to ensure I was clear on the goals for the project, the hardware and software.

Project Goals

  • Real-time cat location — so I can find her secret hiding lair and take a photo
  • Historic location — so I can trace where she’s been over different days
  • Cool maps — as I really like interactive dynamic maps
  • Compatible with existing cat version

Hardware Requirements

  • Pet friendly (light, waterproof, not an embarrassment in front of neighborhood cats)
  • Provide an accurate location & provide a real-time up-link of location — preferable without data costs
  • Have a long battery life and capture motion and acceleration
  • Opensource hardware a plus! Oh, and low cost — because I’m cheap

Software Requirements

  • Write as little code & use native cloud services where possible
  • Try each cloud to see which is the easiest (plus give me a motivation to blog a bit more about the Amazon Web Services, Microsoft Azure & Google Cloud experiences)
  • Use Python (ominous foreboding; one cloud is not going to make this easy)
  • Low cost — did I mention I’m cheap?

Hardware Selection & Communication

I settled on using a LGT-92 GPS Tracker inspired by Shermayne Lee’s entertaining Internet of Dog presentation. This compact device uses an onboard GPS module to determine location, and transmits these coordinates on a regular schedule.

Connecting a cat to The Things Network

Well, the first task is actually connecting the LGT-92 to The Things Network before adding the device to the cat. If the LGT-92 is attached securely to Snowy, we’ll know where Snowy is when she’s outside.

LGT-92 User Manual — Connections in a LoRaWAN Network
The LGT-92 with printed keys
The Things Network portal
Snowy — we know where you are!

MQTT

MQTT is a machine-to-machine ”Internet of Things” protocol. It was designed as an extremely lightweight publish/subscribe messaging transport.

Connection details for MQTT.fx
Subscribing to MQTT topic

Uplink Data Payloads

The uplink message is a JSON payload from The Think Network are well documented. I generally only care about the payload_fields as this is where the useful data from the LGT-92 including Latitude, Longitude, Battery level, Motion etc.,

Data including location

Sleepy cats and motion detection

To conserve power, the LGT-92 GPS Tracker will only power up the GPS and broadcast location if movement is detected. By default, the device is set to movement detect mode (AT+MD=1). In this mode, if the tracker is not moving, it will uplink location info every 1 hour. If the tracker moves, it will uplink location info at every 5 minutes.

Snowy — unsure of the value of this project
export downlink_url="https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/saubury-001/mydownlink?key=ttn-account-v2.XXXXxxxxXXX"
curl -X POST --data '{"dev_id": "saubury0001",  "payload_raw": "pQA=" }'  ${downlink_url}
Downlink message

Summary & Next Steps

So far I have managed to get reliable location updates broadcast to a secure MQTT topic. These location messages are transmitted every 5 minutes.

Example map built on AWS cloud technologies

Code for this project

Thanks for reading this far. All code for this project available at

References and Links

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Simon Aubury

Simon Aubury

Day job: data steaming & system architecture. Night gig: IoT and random project hacking