GPS based vehicle tracker running on the LoRa network of The Things Network based on OTAA
-
Thanks to Tekk for his TTGO-T-Beam-Car-Tracker which came as an inspiration for this project
-
Thanks Matthijs Kooijman to for his OTAA example for The Things Network
-
Thanks to DeuxVis for his Lora-TTNMapper-T-Beam which formed inspiration for Tekk's repository
-
GPS power management based on the code provided by LilyGO
This is an Arduino project for the TTGO T-Beam ESP32 development board REV1.1, which has LoRa chip onboard. Cayenne backend provides very nice web visualization, and also provides free Android/iPhone apps, where you can watch your car's position and indoor climate. This project uses Cayenne Low Power Payload packet format to transfer GPS coordinates and some car's indoor climate data. It has adaptive packet rate, meaning that when the car moves, tracker starts to 'burst' sending packets to update the trajectory as precise as possible. The myDevices Cayenne for LoRa connection is made through The Things Network LoRaWAN cloud.
You can find docs about Cayenne Low Power Payload (LPP) here.
I'll try to describe whole project setup as best I can.
-
If you don't already have it, set up The Things Network account
-
Create new Application in TTN Applications Console
-
Add a new device for your new TTN application and select OTAA Activation Method
-
Insert Device EUI, Application EUI and App Key to the .ino file in the Arduino project Keep in mind the instructions in the file, e.g.
This EUI must be in little-endian format, so least-significant-byte first.
When copying an EUI from The Things dashboard, this means to reverse the bytes.
For TTN issued EUIs the last bytes should be 0xD5, 0xB3,0x70. -
Upload sketch to your board, you can program the T-Beam using the Arduino ESP32 board
Heltec_WIFI_LoRa_32
-
In your TTN application, in section Payload formats select
Cayenne LPP
-
In Integrations section, select
Cayenne
-
Fill Process ID (choose any name you prefer), select Default Access Key and click on Add integration
-
Log in to myDevices Cayenne, on the top click on
+
and enter project name -
Click on Add new -> Device/Widget -> LoRa -> The Things Network -> Cayenne LPP
-
Choose your Name and fill out DevEUI (copy Device EUI from TTN Console). Then select Activation Mode -> Already Registered, Tracking -> This device moves. Click Add device.
-
If your tracker already sent any data to TTN, you'll see bunch of data fields. You can drag them to your Cayenne project.
-
Install the Cayenne mobile app to your Android/iPhone.
This is how it will look like when data is received by TTN and Cayenne.
- After these steps, you will see these data fields in Cayenne Dashboard:
Note: In GPS field, there is also GPS altitude information available.
Optional fields, you can choose to send them in the program:
- Analog Input (5): Battery voltage (in volts)
- Analog Input (6): If tracker is moving, this field is GPS speed, in km/h
- Analog Input (7): Number of satellites, that the GPS module currently 'sees'
- Analog Input (8): Approximate tracker's altitude calculated from barometric air pressure
Connect the BME/BMP280 module's SDA
line to pin 21
and SCL
to pin 22
on the TTGO.
If you want a more reliable data line (if the wires are long for some reason), you can add pull-up resistors on SDA and SCL lines.
Any value from 2.2k to 10k should be OK.
VCC
of the module to 3V3
and GND
to GND
of course.
- ESP32 Core for Arduino (installation with Boards Manager)
- TinyGPS++
- CayenneLPP
- BME280-I2C-ESP32
- Delete / uninstall original Adafruit BME280 library after installing this, otherwise it will cause conflicts!
- Arduino-LMIC
These are the keys you will need from the TTN console (marked yellow).
- TTGO-T-Beam
- ESP32 + GPS + LoRa REV 1.1
- BME/BMP280 module
- For temperature, humidity, and atmospheric pressure reporting
- Fully implemented and working with the sketch
ESP32
ESP32 Version REV1
WiFi
Bluetooth
4MB Flash
3D Antenna
LORA
Working voltage: 1.8 ~ 3.7v
Acceptable current: 10 ~ 14mA
Transmit current: 120mA @ +20dBm
90mA @ +17dBm
29mA @ +13dBm
Operating frequency: 433MHz / 868MHz / 915MHz
Transmit power: +20dBm
Receive sensitivity: -139dBm @ LoRa & 62.5 KHz & SF=12 & 146bps
-136dBm @ LoRa & 125 KHz & SF=12 & 293bps
-118dBm @ LoRa & 125 KHz & SF=6 & 9380bps
-123dBm @ FSK & 5 KHz & 1.2Kbps
Frequency error: +/-15KHz
FIFO space: 64 byte
Data rate: 1.2K ~ 300Kbps @ FSK
0.018K ~ 37.5Kbps @ LoRa
Modulation Mode: FSK, GFSK, MSK, GMSK, LoRa TM, OOK
Interface form: SPI
Sleep current: 0.2uA @ SLEEP
1.5uA @ IDLE
Operating temperature: -40? - +85?
Digital RSSI function
Automatic frequency correction
Automatic gain control
RF wake-up function
Low voltage detection and temperature sensor
Fast wake-up and frequency hopping
Highly configurable data packet handler
GPS
GPS modules NEO-6M, 3V-5V power supply Universal
Destined module with ceramic antenna, signal super
Save the configuration parameter data EEPROM Down
With data backup battery
There are LED signal indicator
Default Baud Rate: 9600
Power
IP5306 2A Battery PMIC
LED, Blue - User controller
LED, Red - GPS 1PPS
LED, Red/green - battery charged/power on
Button, reset switch
Button, user readable
Switch, power on/battery charge
USB
CP2104-GMR
- Split code with separate configuration file
- Split code so that BME280 can be taken out when not in use
- Update LMIC compatiblity to new MCCI LMIC library
- Debug TTN downlink messages, there are a lot of frames down. Seems to come from the library but need to test this first
You are welcome to contribute to this project in any way. (Submit an issue, bug report, fork and improve...) Suggestions & feedback is much appreciated.