Introduction: Tinyduino LoRa Based Pet Tracker

Who doesn't want to have pets?? Those furry friends can fill you with love and happiness.But the pain of missing them is devastating. Our family had a cat named Thor(the picture above) and he was an adventure loving wanderer. Many times he returned after weekly trips often with injuries and so we tried not to let him out. But what not, he went out again but did not return :( We couldn't find a slight trace even after searching for weeks. My family became reluctant to have anymore cats as losing him was much traumatic. So I decided to have a look upon pet trackers. But most of the commercial trackers required subscriptions or are heavy for a cat. There are some good radio direction based trackers but I wanted to know an accurate location as I won't be at home for most part of the day. So I decided to make a tracker with Tinyduino and a LoRa module sending location to the base station at my home which updates the location to an app.

P.S. please forgive me for low quality images.

Step 1: Required Components

  1. TinyDuino Processor Board
  2. Tinyshield GPS
  3. ESP8266 WiFi development board
  4. Hope RF RFM98(W) (433 MHz) x 2
  5. Tinyshield Proto Board
  6. USB Tinyshield
  7. Lithium polymer battery - 3.7 V ( I used 500mAh to reduce the weight)
  8. Soldering iron
  9. Jumper wires (Female to Female)

Step 2: The Transmitter

We need to connect the LoRa transceiver to the tinyduino. For this, we need to solder wires from the RFM98 module to the tinyshield protoboard. I would be using the RadioHead library for communication and the connection is done as per the documentation.

Protoboard <--> RFM98

GND -------------- GND

D2 -------------- DIO0

D10 -------------- NSS (CS chip select in)

D13 -------------- SCK (SPI clock in)

D11 -------------- MOSI (SPI Data in)

D12 -------------- MISO (SPI Data out)

3.3V pin of RFM98 is connected to the battery +ve.

NOTE: As per the datasheet, the maximum voltage that can be applied to the RFM98 is 3.9V. Do check the battery voltage before connecting.

I used a helical antenna for RFM98 as it would reduce the size of the tracker.

Start with the tinyduino processor at the bottom of the stack followed by tinyshield GPS and then the protoboard at the top.The solder heads under the protoboard may get a bit annoying; in my case it touched the gps shield under it, so I insulated the bottom of the protoboard with electrical tape. That's it, we completed building the transmitter!!!

The transmitter unit can then be connected to the battery and attached to pet's collar.

Step 3: The Base Station

ESP8266 WiFi development board is a perfect choice if you want to connect your project to internet. The RFM98 transceiver is connected to the ESP8266 and receives the location updates from the tracker.

ESP8266 <--> RFM98

3.3V ---------- 3.3V

GND ---------- GND

D2 ---------- DIO0

D8 ---------- NSS (CS chip select in)

D5 ---------- SCK (SPI clock in)

D7 ---------- MOSI (SPI Data in)

D6 ---------- MISO (SPI Data out)

The power supply to the base station was made using a 5V DC wall adapter. I had some old wall adapters lying around, so I ripped off the connector and connected it to the VIN and GND pins of the ESP8266. Also the antenna was made out of a copper wire of length ~17.3 cm (quarter wave antenna).

Step 4: The App

I used Blynk (from here) as the app. This is one of the easiest option as it is very well documented and widgets can just be drag-dropped.

1.Create a Blynk account and make a new project with ESP8266 as device.

2.Drag and Drop Widgets from the widget menu.

3.Now,you need to set up virtual pins for each of these widgets.

4. Use the same pins as the above in the base station source code.

Remember to use your project authorization key in the arduino code.

Step 5: The Code

This project uses Arduino IDE.

The code is pretty simple. The transmitter would send a signal every 10 seconds and then wait for an acknowledgement.If an "active" acknowledgement is received, then it would switch on the GPS and wait for a location update from GPS. During this time, it will still be checking the connection with the base station and if the connection is lost in between the GPS updates, it would retry for a couple of times and if still not connected, the GPS is turned off and tracker will fallback to the normal routine (i.e sending signal every 10 second). Otherwise the GPS data is sent to the base station. Instead, if a "stop" acknowledgment is received(in between as well as at the beginning), the transmitter stops the GPS and then fall back to the normal routine .

The base station listens for any signal and if a signal is received, it checks whether the "find" button inside the app is on. If it is "on" then the location values are retrieved. If it is "off" then base station sends "stop" acknowledgement to the transmitter. You can choose to listen for signal only if the "find" button is on but I added it as a security feature to know if the connection got lost in between and alert the user (something like geofence).

Step 6: Enclosures

Tracker:

3D printing is the way to go, but I preferred to tape it on to the collar. It is a mess, and I seriously don't know whether cats would like to take such a mess on their neck.

Base Station:

A plastic container was more than enough for the base station. If you want to mount it outside, you might need to consider waterproof containers.

UPDATE:

I thought of making an enclosure for tracker, but as I did not have a 3D printer, small containers got turned into enclosures :) The electronics assembly was kept in one container and the battery in another.

I used blocks as an enclosure for electronics. Luckily, there was a cap that fitted it nicely. For the battery a Tic-Tac container was used. In order to secure the battery the container was shortened so that battery fitted perfectly. Paper clips were used to attach the containers onto the collar.

Step 7: Testing and Conclusion..

Whom would we test it on?? No, it is not that I don't have cats now. Well,I have two ;)

But they are too small to wear the collar and I decided to test it out myself. So I had a walk around my house with the tracker. Base station was kept at a 1m height and most of the time there was heavy vegetation and buildings in between the tracker and base station. I felt so sad that I suddenly ran out of space(though in some places the signal is weak). But in such a terrain getting a range of ~100m without much data loss is much appreciable.

The range testing I have done is here.

The GPS seems to work somewhat normal under heavy vegetation but occasionally location seems to drift. So I am also looking forward to add a WiFi module (since there are so many routers in nearby houses) in order to obtain a coarse location faster (by measuring signal strengths from many routers and triangulating).

I know that actual range should be pretty much more, but due to the current lockdown scenario, I cannot move much out of the house . In the future, I would certainly test it out to the extremes and update the results :)

Till then, happy purring.....

Pets Speed Challenge

Participated in the
Pets Speed Challenge