ttgo-t-beam-gps-ttn-tracker/README.md

67 lines
3.4 KiB
Markdown
Raw Normal View History

2019-04-04 00:53:44 +00:00
## TTGO T-Beam Tracker for The Things Network
2019-02-10 18:35:12 +00:00
2019-08-23 14:33:00 +00:00
Uploads GPS data from the TTGO T-Beam to [The Things Network](https://www.thethingsnetwork.org) (TTN) and [TTN Mapper](https://ttnmapper.org) for tracking and determining signal strength of LoRaWAN gateways and nodes.
2019-04-04 00:53:44 +00:00
#### Based on the code from [xoseperez/ttgo-beam-tracker](https://github.com/xoseperez/ttgo-beam-tracker), with excerpts from [dermatthias/Lora-TTNMapper-T-Beam](https://github.com/dermatthias/Lora-TTNMapper-T-Beam) to fix an issue with incorrect GPS data being transmitted to The Things Network. I also added support for the 915 MHz frequency (North and South America).
2019-02-10 18:35:12 +00:00
2019-02-10 18:47:31 +00:00
This is a LoRaWAN node based on the [TTGO T-Beam](https://github.com/LilyGO/TTGO-T-Beam) development platform using the SSD1306 I2C OLED display.
It uses a RFM95 by HopeRF and the MCCI LoRaWAN LMIC stack. This sample code is configured to connect to The Things Network using the US 915 MHz frequency by default, but can be changed to EU 868 MHz.
2019-08-25 16:57:37 +00:00
NOTE: There are now 2 versions of the TTGO T-BEAM, the first version (Rev0) and a newer version (Rev1). The GPS module on Rev1 is connected to different pins than Rev0. This code has been successfully tested on REV0, and is in the process of being tested on REV1. See the end of this README for photos of eah board.
2019-08-23 14:33:00 +00:00
2019-08-25 16:57:37 +00:00
#### Setup
1. Follow the directions at [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32) to install the board to the Arduino IDE and use board 'Heltec_WIFI_LoRa_32'.
2019-02-10 18:35:12 +00:00
2019-08-25 16:57:37 +00:00
2. Install the Arduino IDE libraries:
2019-08-23 13:23:39 +00:00
2019-08-25 16:57:37 +00:00
* [mcci-catena/arduino-lmic](https://github.com/mcci-catena/arduino-lmic)
* [mikalhart/TinyGPSPlus](https://github.com/mikalhart/TinyGPSPlus)
* [ThingPulse/esp8266-oled-ssd1306](https://github.com/ThingPulse/esp8266-oled-ssd1306)
2019-08-23 13:23:39 +00:00
2019-08-25 16:57:37 +00:00
3. Edit arduino-lmic/project_config/lmic_project_config.h and uncomment the proper frequency for your region.
2019-02-10 18:35:12 +00:00
2019-08-25 16:57:37 +00:00
4. Edit ```main/credentials.h``` to use either ```USE_ABP``` or ```USE_OTAA``` and add the Keys/EUIs for your Application's Device from The Things Network.
2019-02-10 18:56:18 +00:00
2019-08-25 16:57:37 +00:00
5. Add the TTN Mapper integration to your Application (and optionally the Data Storage integration if you want to access the GPS location information yourself), then add the Decoder code:
2019-08-23 14:22:03 +00:00
```C
function Decoder(bytes, port) {
var decoded = {};
decoded.latitude = ((bytes[0]<<16)>>>0) + ((bytes[1]<<8)>>>0) + bytes[2];
decoded.latitude = (decoded.latitude / 16777215.0 * 180) - 90;
2019-08-23 22:05:07 +00:00
2019-08-23 14:22:03 +00:00
decoded.longitude = ((bytes[3]<<16)>>>0) + ((bytes[4]<<8)>>>0) + bytes[5];
decoded.longitude = (decoded.longitude / 16777215.0 * 360) - 180;
2019-08-23 22:05:07 +00:00
2019-08-23 14:22:03 +00:00
var altValue = ((bytes[6]<<8)>>>0) + bytes[7];
var sign = bytes[6] & (1 << 7);
2019-08-23 22:05:07 +00:00
if(sign) decoded.altitude = 0xFFFF0000 | altValue;
else decoded.altitude = altValue;
2019-08-23 14:22:03 +00:00
decoded.hdop = bytes[8] / 10.0;
2019-08-23 22:05:07 +00:00
decoded.sats = bytes[9] / 10.0;
2019-08-23 14:22:03 +00:00
return decoded;
}
```
2019-08-25 16:57:37 +00:00
Compile the Arduino code and upload it to your TTGO T-Beam. Turn on the device and once a GPS lock is acquired, the device will start sending data to TTN and TTN Mapper.
2019-04-04 00:53:44 +00:00
2019-08-25 16:57:37 +00:00
I also developed The [Things Network Tracker (TTN-Tracker)](https://github.com/kizniche/ttn-tracker), a web app that pulls GPS data from TTN and displays it on a map in real-time (TTN Mapper is not real-time).
2019-08-23 15:19:07 +00:00
### Rev0
2019-02-10 18:56:18 +00:00
![TTGO T-Beam 01](img/TTGO-TBeam-01.jpg)
![TTGO T-Beam 02](img/TTGO-TBeam-02.jpg)
![TTGO T-Beam 03](img/TTGO-TBeam-03.jpg)
2019-08-23 15:19:07 +00:00
### Rev1
![T-BEAM-Rev1-01](img/T-BEAM-Rev1-01.jpg)
![T-BEAM-Rev1-02](img/T-BEAM-Rev1-02.jpg)