Update to version 1.1.0

This commit is contained in:
Kyle Gabriel 2019-08-23 10:22:03 -04:00
parent a2b2d3411d
commit e9c24695c6
5 changed files with 83 additions and 66 deletions

View File

@ -5,7 +5,7 @@
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.
To start, install the dependencies, below. Then edit ```src/credentials.h``` to use either ```USE_ABP``` or ```USE_OTAA``` and the Keys/EUIs for your Application's Device from [The Things Network](https://www.thethingsnetwork.org/). Add the TTN Mapper integration to your Application (and optionally the Data Storage integration if you want to access the GPS location information yourself). Compile the 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 start, install the dependencies and board, below, to your Arduino IDE. Then edit ```src/credentials.h``` to use either ```USE_ABP``` or ```USE_OTAA``` and add the Keys/EUIs for your Application's Device from [The Things Network](https://www.thethingsnetwork.org/). 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, below, if using . 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.
#### Arduino IDE Board
@ -17,6 +17,35 @@ Follow the directions at [espressif/arduino-esp32](https://github.com/espressif/
- [mikalhart/TinyGPSPlus](https://github.com/mikalhart/TinyGPSPlus)
- [ThingPulse/esp8266-oled-ssd1306](https://github.com/ThingPulse/esp8266-oled-ssd1306)
#### TTN Decoder
```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;
decoded.longitude = ((bytes[3]<<16)>>>0) + ((bytes[4]<<8)>>>0) + bytes[5];
decoded.longitude = (decoded.longitude / 16777215.0 * 360) - 180;
var altValue = ((bytes[6]<<8)>>>0) + bytes[7];
var sign = bytes[6] & (1 << 7);
if(sign)
{
decoded.altitude = 0xFFFF0000 | altValue;
}
else
{
decoded.altitude = altValue;
}
decoded.hdop = bytes[8] / 10.0;
return decoded;
}
```
### The TTGO T-Beam development platform
![TTGO T-Beam 01](img/TTGO-TBeam-01.jpg)

View File

@ -33,13 +33,12 @@ void ttn_register(void (*callback)(uint8_t message));
// -----------------------------------------------------------------------------
#define APP_NAME "TTN MAP-TRACK"
#define APP_VERSION "1.0.0"
#define APP_VERSION "1.1.0"
// -----------------------------------------------------------------------------
// Configuration
// -----------------------------------------------------------------------------
#define USE_CAYENNE
#define DEBUG_PORT Serial // Serial debug port
#define SERIAL_BAUD 115200 // Serial debug baud rate
#define SLEEP_BETWEEN_MESSAGES 0 // Do sleep between messages
@ -52,6 +51,10 @@ void ttn_register(void (*callback)(uint8_t message));
#define LORAWAN_ADR 0 // Enable ADR
#define GPS_WAIT_FOR_LOCK 5000 // Wait 5s after every boot for GPS lock
// Only enable one
//#define PAYLOAD_USE_CAYENNE
#define PAYLOAD_USE_FULL
// -----------------------------------------------------------------------------
// DEBUG
// -----------------------------------------------------------------------------

View File

@ -1,21 +1,21 @@
/*
GPS module
GPS module
Copyright (C) 2018 by Xose Pérez <xose dot perez at gmail dot com>
Copyright (C) 2018 by Xose Pérez <xose dot perez at gmail dot com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -62,7 +62,33 @@ static void gps_loop() {
_gps.encode(_serial_gps.read());
}
}
#ifdef USE_CAYENNE
#ifdef PAYLOAD_USE_FULL
// More data than PAYLOAD_USE_CAYENNE
void buildPacket(uint8_t txBuffer[9])
{
LatitudeBinary = ((_gps.location.lat() + 90) / 180.0) * 16777215;
LongitudeBinary = ((_gps.location.lng() + 180) / 360.0) * 16777215;
sprintf(t, "Lat: %f", _gps.location.lat());
Serial.println(t);
sprintf(t, "Lng: %f", _gps.location.lng());
Serial.println(t);
txBuffer[0] = ( LatitudeBinary >> 16 ) & 0xFF;
txBuffer[1] = ( LatitudeBinary >> 8 ) & 0xFF;
txBuffer[2] = LatitudeBinary & 0xFF;
txBuffer[3] = ( LongitudeBinary >> 16 ) & 0xFF;
txBuffer[4] = ( LongitudeBinary >> 8 ) & 0xFF;
txBuffer[5] = LongitudeBinary & 0xFF;
altitudeGps = _gps.altitude.meters();
txBuffer[6] = ( altitudeGps >> 8 ) & 0xFF;
txBuffer[7] = altitudeGps & 0xFF;
hdopGps = _gps.hdop.value()/10;
txBuffer[8] = hdopGps & 0xFF;
}
#endif
#ifdef PAYLOAD_USE_CAYENNE
// CAYENNE DF
void buildPacket(uint8_t txBuffer[11])
{
@ -85,47 +111,5 @@ static void gps_loop() {
txBuffer[8] = alt >> 16;
txBuffer[9] = alt >> 8;
txBuffer[10] = alt;
/*
txBuffer[2] = ( LatitudeBinary >> 16 );// & 0xFF;
txBuffer[3] = ( LatitudeBinary >> 8 );// & 0xFF;
txBuffer[4] = LatitudeBinary;// & 0xFF;
txBuffer[5] = ( LongitudeBinary >> 16 ) & 0xFF;
txBuffer[6] = ( LongitudeBinary >> 8 ) & 0xFF;
txBuffer[7] = LongitudeBinary & 0xFF;
txBuffer[8] = Height >> 16;
txBuffer[9] = Height >> 8;
txBuffer[10] = Height;*/
}
#else
uint8_t txBuffer[9];
void buildPacket(uint8_t txBuffer[9])
{
LatitudeBinary = ((_gps.location.lat() + 90) / 180.0) * 16777215;
LongitudeBinary = ((_gps.location.lng() + 180) / 360.0) * 16777215;
sprintf(t, "Lat: %f", _gps.location.lat());
Serial.println(t);
sprintf(t, "Lng: %f", _gps.location.lng());
Serial.println(t);
txBuffer[0] = ( LatitudeBinary >> 16 ) & 0xFF;
txBuffer[1] = ( LatitudeBinary >> 8 ) & 0xFF;
txBuffer[2] = LatitudeBinary & 0xFF;
txBuffer[3] = ( LongitudeBinary >> 16 ) & 0xFF;
txBuffer[4] = ( LongitudeBinary >> 8 ) & 0xFF;
txBuffer[5] = LongitudeBinary & 0xFF;
altitudeGps = _gps.altitude.meters();
txBuffer[6] = ( altitudeGps >> 8 ) & 0xFF;
txBuffer[7] = altitudeGps & 0xFF;
hdopGps = _gps.hdop.value()/10;
txBuffer[8] = hdopGps & 0xFF;
}
}
#endif

View File

@ -6,8 +6,8 @@
// inside the project_config folder.
// Make sure only one of the following is defined (CFG_us915 or CFG_eu868)
#define CFG_au915 1
//#define CFG_au923 1
#define CFG_us915 1
//#define CFG_eu868 1
// DO NOT modify this
#define CFG_sx1276_radio 1

View File

@ -24,7 +24,6 @@
#include "configuration.h"
#include "rom/rtc.h"
// Message counter, stored in RTC memory, survives deep sleep
RTC_DATA_ATTR uint32_t count = 0;
// -----------------------------------------------------------------------------
@ -32,13 +31,15 @@ RTC_DATA_ATTR uint32_t count = 0;
// -----------------------------------------------------------------------------
#include <TinyGPS++.h>
#ifdef USE_CAYENNE
// CAYENNE DF
static uint8_t txBuffer[11] = {0x03, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
#else
#ifdef PAYLOAD_USE_FULL
uint8_t txBuffer[9];
#endif
#ifdef PAYLOAD_USE_CAYENNE
// CAYENNE DF
static uint8_t txBuffer[11] = {0x03, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
#endif
// -----------------------------------------------------------------------------
// Application
// -----------------------------------------------------------------------------