Skip to content

Latest commit

 

History

History
345 lines (219 loc) · 19.7 KB

README.md

File metadata and controls

345 lines (219 loc) · 19.7 KB

LoRa_cat_tracker 😺

This cat tracker sends GPS coordinates using LoRa

A Raspberry Pi receives the data and sets a marker at your cat's position onto a map

There is also a portable receiver in case the Raspberry Pi doesn’t receive the data, or you have to search for your cat/collar

leaflet leaflet

©Gregor Wiebe | Huckleberryking

leaflet

map

Parts List

Before you buy one of the LoRa boards, check if the board has the correct frequency

  • Europe EU868 MHz
  • South America AU915/AS923-1 MHz
  • North America US915 MHz
  • India IN865 MHz
  • Asia AS923 MHz
Sender portable receiver receiver other parts
1x CubeCell GPS-6502 1x Heltec WiFi LoRa 32 V2 1x Raspberry Pi 3 2x 1k resistor
1x Lithium Polymer Battery 3,7V 480mAh 1x Lithium Polymer Battery 3,7V 1100mAh 1x LoRa breakout board 1x 2k resistor
1x active buzzer (1x tactile button) 2x slide switch
1x BLE hm-10 module 4x Neopixels (1x strip) 1x ttl converter
some jumper wires
1x breadboard

Case

3D printed

You can print a case for the portable receiver and the sender


©Gregor Wiebe | Huckleberryking

but the case for the sender is a little bit too big for a cat, in my opinion

alternative

If you cannot print a 3D case, you also can use heat shrink tubes for the sender and a plastic box for the receiver. To fit everything in the tube you should use one with at least an inner diameter of 30mm. For the receiver, you can use, for example, the box that the Heltec board came with. Make holes for the antenna, power switch, display and USB port. In this case, you can use the programable button on the board because the plastic is very thin, and you can push the button through the plastic, so choose the Portable_Receiver_onboardButton sketch and upload it to the white heltec board.

©Gregor Wiebe | Huckleberryking

Soldering

Sender

To make the sender thinner, you can try to remove the plastic socket Or try to desolder the oled display

BLE module: solder wires to gnd and vcc (before you desolder the pin header, you have to configure your BL module, which will be explained later Also, the red wire of the buzzer to pin 4 and the black one to gnd

Take the connector cable of the CubeCell board and connect the red wire with The red wire of the BLE module. Solder these cables to the middle pin of the Switch. Take the red battery wire and solder it to the correct pin of the switch. Solder the three black ground wires together.

Portable Receiver

Take the neopixels and solder three wires to it The data wire to pin 23 of the Heltec board Vcc to the 3.3 pin gnd to gnd

Use the connector cable and solder the red wire to the middle pin of the switch And the lipo red wire to the correct pin

Do this only if you are using the printed case: Solder a black wire to another gnd pin of the Heltec board, then solder a 1 k resistor to The end of the wire. Take the resistor and solder it to one pin of the tactile Button. On the correct pin solder a wire to it, and this wire to pin 17 of the Board. Now solder a wire to the other pin of the pin and the 3.3V pin

Now you can put everything in the receiver case

Raspberry Pi Receiver

Solder 11 wires to the LoRa breakout board And the antenna to the antenna pin

Raspberry Pi Lora – SX1276 Module
3.3V 3.3V
gnd gnd
GPIO 10 MOSI
GPIO 9 MISO
GPIO 11 SCK
GPIO 8 Nss / Enable
GPIO 4 DIO 0
GPIO 17 DIO 1
GPIO 18 DIO 2
GPIO 27 DIO 3
GPIO 22 RST

Software

Arduino IDE

Go to https://www.arduino.cc/en/software and download the Arduino IDE

Next, we have to include the libraries for the Heltec boards. Open the Arduino IDE and go to file -> preferences Click on the two squares and paste the three links into it

https://dl.espressif.com/dl/package_esp32_index.json
https://github.com/HelTecAutomation/CubeCell-Arduino/releases/download/V1.5.0/package_CubeCell_index.json
https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/releases/download/0.0.6/package_heltec_esp32_index.json

Sender

Connect the CubeCell board to your computer and choose the port and the correct board from the manager.

choosing board github ports

To test the CubeCell board upload the oledDisplayGPSInfo.ino file file->examples->OnBoardGPS -> oledDisplayGPSInfo -> ctrl + u. If there’s an compile error try to replace line 8 with this

SSD1306Wire display(0x3c, 500000, SDA, SCL ,GEOMETRY_128_64,GPIO10); // addr, freq, sda, scl,resolution, rst

Put the board outside and wait until the board gets a GPS fix First time using it could take some time until it gets a fix Next time it is much faster

If everything is working open the sender sketch which is in the github folder you’ve downloaded

GPS settings

The default GPS settings are GPS_INIT_TIMEOUT 5 Minutes, GPS_SLEEPTIME also 5 Minutes, GPS_UPDATE_TIMEOUT 30 seconds. If you want that your tracker sleeps longer you can change the sleeptime. The numbers are in milliseconds. (1 sec = 1000ms)

LoRa settings

choose your frequency :

  • Europe EU868 MHz
  • South America AU915/AS923-1 MHz
  • North America US915 MHz
  • India IN865 MHz
  • Asia AS923 MHz

You also can change the bandwidth, codingrate and spreading factor. Keep in mind if you change these settings you have to change them in the code for the receivers too. Upload the code (ctrl + u)

Portable Receiver

Now connect the Heltec WiFi board to your computer. Open the portable receiver sketch (downloaded github folder) and choose the Heltec Wifi LoRa V2 and the port.

portable receiver frequency

In line 284 change the LoRa frequency. This time it’s called band.

Here you can change the bandwidth, codingrate and sprading factor. But it has to be the same settings like in the sender sketch.

On the left side click on the library manager and search for adafruit neopixel. Install the Adafruit NeoPixel by Adafruit.

Upload the code

BT -> bluetooth connection with senders ble module, the number is the signalstrength

V -> it receives the senderes battery capacity in millivolts

LoRa:

  • zone -> you can set a zone to now wheres your pet at instead of only coordinates
  • numbers -> senders coordinates
  • RSSI -> LoRa signalstrength

Raspberry Pi Receiver

For this receiver I’m using this repository: https://github.com/rpsreal/pySX127x

Download the Raspberry Pi Imager from here: https://www.raspberrypi.com/software/ and Visual Studio Code https://code.visualstudio.com/ Open the imager and insert a micro sd cart into your computer.

rp-imager

Choose the Raspberry Pi Os (32-Bit) operating system and your sd card. Click on the gear and configurate following settings.

rp-imager settings

  • enable Hostname: raspberrypi
  • enable ssh
  • enter pi as username and choose a password
  • set your Wifi SSID and password
  • set your country

Save everything and click on the write button After the os is written to your sd card you can remove it and insert it into your Raspberry Pi. Plug the power cable into your Pi. Open Visual Studio Code and click on the left side on the extensions icon. Search for remote ssh and install it.

Wait couple minutes to let your Pi boot up. Click on the green icon in the bottom left corner and choose connect current window to host -> add new ssh host -> write ssh pi@raspberrypi and press enter -> C:\user.ssh\config -> click again on the green icon in the bottom left corner and choose connect current window to host -> Linux -> raspberrypi -> continue -> enter your password Now you are connected to your Pi. Click on file -> open folder -> \home\pi Terminal -> new terminal enter every line and press enter if it ask to continue enter y

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install apache2
sudo mkdir /var/www/html/tracker

sudo raspi-config nonint do_spi 0
sudo apt-get install python-dev python3-dev
sudo apt-get install python-pip python3-pip

pip install RPi.GPIO
pip install spidev
pip install pyLoRa

sudo apt-get install git
git clone https://github.com/rpsreal/pySX127x

After everything is installed enter sudo reboot. Wait a minute and connect with your pi again (green icon in the buttom left corner).

Drag the website.py file from the downloaded github folder and drop it into the pi folder in visual studio code.

Now right click under the website file -> new file -> array.txt Go to the terminal again. To run the code enter python3 website.py

To stop the code press ctrl + c.

To change the LoRa settings click on the website.py file. Remember to change your frequency and set the same bandwidth and spreading factor like the sender.

Map

for the map I'm using Leaflet. You can change the pictures and the offset of the paw prints

IF you changed the code press ctrl + s and run the code.

After your Raspberry Pi received some coordinates you can check them out here: http://raspberrypi/tracker/index.html

DSD TECH Bluetooth Tools

Because i use a module from DSD TECH i configurated my module with their software http://www.dsdtech-global.com/2017/11/dsd-tech-bluetooth-config-tool.html Use a ttl converter and connect

TTL converter BLE module
5V vcc
gnd gnd
RX TX
TX RX

In the software choose your com port, click on open and go to the hm-10 tab Click on ‘test’ to check if there is a connection

If in the consol comes a ok back everything is good

First change the modules name (e.g. your cats name) -> set

Auth Mode: Auth not need PIN -> set

PIN: choose a pin -> set

Go to the AT Comand tab

ASCII:

AT+PWRM0 -> send (auto sleep)

AT+MODE2 -> send (Remote Control Mode + Transmission Mode)

AT+BEFC000 -> send (Set Module pin output state, After power supplied)

AT+AFTC000 -> send (Set Module pin output state, After connection is established) In my case i wasn’t able to change the service and characteristics uuid with ascii (AT+UUID0xFFE4 | AT+CHAR0xFFE5) so i converted these two camands in hexadecimal

HEX:

41 54 2B 55 55 49 44 30 78 46 46 45 34 -> send (Service uuid)

41 54 2B 43 48 41 52 30 78 46 46 45 35 -> send (characteristics uuid)

Now your module is configurated. Click on close icon and unplug the ttl converter. Plug it again into your computer and search with your smartphone for bluetooth devices. If you are able to find your module with the name you set everything is fine. If you have an iPhone it coul be possible that you are unable to see the module in your bluetooth devices. Take the portable receiver and press the button now it will search for the ble module. When they are connected the neopixels begin to glow and show the distance between these two devices.