progress update
This commit is contained in:
parent
0e6586a55a
commit
b8f6df7f53
13
README.md
13
README.md
@ -21,7 +21,7 @@ Follow the directions at [espressif/arduino-esp32](https://github.com/espressif/
|
|||||||
- [mikalhart/TinyGPSPlus](https://github.com/mikalhart/TinyGPSPlus)
|
- [mikalhart/TinyGPSPlus](https://github.com/mikalhart/TinyGPSPlus)
|
||||||
- [ThingPulse/esp8266-oled-ssd1306](https://github.com/ThingPulse/esp8266-oled-ssd1306)
|
- [ThingPulse/esp8266-oled-ssd1306](https://github.com/ThingPulse/esp8266-oled-ssd1306)
|
||||||
|
|
||||||
#### TTN Decoder
|
#### TTN Payload Decoder
|
||||||
|
|
||||||
```C
|
```C
|
||||||
function Decoder(bytes, port) {
|
function Decoder(bytes, port) {
|
||||||
@ -35,16 +35,11 @@ function Decoder(bytes, port) {
|
|||||||
|
|
||||||
var altValue = ((bytes[6]<<8)>>>0) + bytes[7];
|
var altValue = ((bytes[6]<<8)>>>0) + bytes[7];
|
||||||
var sign = bytes[6] & (1 << 7);
|
var sign = bytes[6] & (1 << 7);
|
||||||
if(sign)
|
if(sign) decoded.altitude = 0xFFFF0000 | altValue;
|
||||||
{
|
else decoded.altitude = altValue;
|
||||||
decoded.altitude = 0xFFFF0000 | altValue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
decoded.altitude = altValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
decoded.hdop = bytes[8] / 10.0;
|
decoded.hdop = bytes[8] / 10.0;
|
||||||
|
decoded.sats = bytes[9] / 10.0;
|
||||||
|
|
||||||
return decoded;
|
return decoded;
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,14 @@ void ttn_register(void (*callback)(uint8_t message));
|
|||||||
// Configuration
|
// Configuration
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Select which T-Beam board is being used. Only uncomment one.
|
||||||
|
#define T_BEAM_V07 // AKA Rev0 (first board released)
|
||||||
|
// #define T_BEAM_V10 // AKA Rev1 (second board released)
|
||||||
|
|
||||||
|
// Select the payload format. Change on TTN as well. Only uncomment one.
|
||||||
|
#define PAYLOAD_USE_FULL
|
||||||
|
//#define PAYLOAD_USE_CAYENNE
|
||||||
|
|
||||||
#define DEBUG_PORT Serial // Serial debug port
|
#define DEBUG_PORT Serial // Serial debug port
|
||||||
#define SERIAL_BAUD 115200 // Serial debug baud rate
|
#define SERIAL_BAUD 115200 // Serial debug baud rate
|
||||||
#define SLEEP_BETWEEN_MESSAGES 0 // Do sleep between messages
|
#define SLEEP_BETWEEN_MESSAGES 0 // Do sleep between messages
|
||||||
@ -51,10 +59,6 @@ void ttn_register(void (*callback)(uint8_t message));
|
|||||||
#define LORAWAN_ADR 0 // Enable ADR
|
#define LORAWAN_ADR 0 // Enable ADR
|
||||||
#define GPS_WAIT_FOR_LOCK 5000 // Wait 5s after every boot for GPS lock
|
#define GPS_WAIT_FOR_LOCK 5000 // Wait 5s after every boot for GPS lock
|
||||||
|
|
||||||
// Only enable one payload format. Change on TTN as well.
|
|
||||||
#define PAYLOAD_USE_FULL
|
|
||||||
//#define PAYLOAD_USE_CAYENNE
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// DEBUG
|
// DEBUG
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -94,11 +98,17 @@ void ttn_register(void (*callback)(uint8_t message));
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
#define GPS_SERIAL_NUM 1
|
#define GPS_SERIAL_NUM 1
|
||||||
#define GPS_RX_PIN 12
|
|
||||||
#define GPS_TX_PIN 15
|
|
||||||
#define GPS_BAUDRATE 9600
|
#define GPS_BAUDRATE 9600
|
||||||
#define USE_GPS 1
|
#define USE_GPS 1
|
||||||
|
|
||||||
|
#if defined(T_BEAM_V07)
|
||||||
|
#define GPS_RX_PIN 12
|
||||||
|
#define GPS_TX_PIN 15
|
||||||
|
#elif defined(T_BEAM_V10)
|
||||||
|
#define GPS_RX_PIN 34
|
||||||
|
#define GPS_TX_PIN 12
|
||||||
|
#endif
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// LoRa SPI
|
// LoRa SPI
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -111,3 +121,12 @@ void ttn_register(void (*callback)(uint8_t message));
|
|||||||
#define DIO0_GPIO 26
|
#define DIO0_GPIO 26
|
||||||
#define DIO1_GPIO 33
|
#define DIO1_GPIO 33
|
||||||
#define DIO2_GPIO 32
|
#define DIO2_GPIO 32
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Rev1-specific options
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if defined(T_BEAM_V10)
|
||||||
|
#define GPS_POWER_CTRL_CH 3
|
||||||
|
#define LORA_POWER_CTRL_CH 2
|
||||||
|
#endif
|
||||||
|
14
main/gps.ino
14
main/gps.ino
@ -63,9 +63,10 @@ static void gps_loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PAYLOAD_USE_FULL
|
#if defined(PAYLOAD_USE_FULL)
|
||||||
|
|
||||||
// More data than PAYLOAD_USE_CAYENNE
|
// More data than PAYLOAD_USE_CAYENNE
|
||||||
void buildPacket(uint8_t txBuffer[9])
|
void buildPacket(uint8_t txBuffer[10])
|
||||||
{
|
{
|
||||||
LatitudeBinary = ((_gps.location.lat() + 90) / 180.0) * 16777215;
|
LatitudeBinary = ((_gps.location.lat() + 90) / 180.0) * 16777215;
|
||||||
LongitudeBinary = ((_gps.location.lng() + 180) / 360.0) * 16777215;
|
LongitudeBinary = ((_gps.location.lng() + 180) / 360.0) * 16777215;
|
||||||
@ -83,12 +84,14 @@ static void gps_loop() {
|
|||||||
altitudeGps = _gps.altitude.meters();
|
altitudeGps = _gps.altitude.meters();
|
||||||
txBuffer[6] = ( altitudeGps >> 8 ) & 0xFF;
|
txBuffer[6] = ( altitudeGps >> 8 ) & 0xFF;
|
||||||
txBuffer[7] = altitudeGps & 0xFF;
|
txBuffer[7] = altitudeGps & 0xFF;
|
||||||
hdopGps = _gps.hdop.value()/10;
|
hdopGps = _gps.hdop.value() / 10;
|
||||||
txBuffer[8] = hdopGps & 0xFF;
|
txBuffer[8] = hdopGps & 0xFF;
|
||||||
|
sats = _gps.satellites.value() / 10;
|
||||||
|
txBuffer[9] = sats & 0xFF;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PAYLOAD_USE_CAYENNE
|
#elif defined(PAYLOAD_USE_CAYENNE)
|
||||||
|
|
||||||
// CAYENNE DF
|
// CAYENNE DF
|
||||||
void buildPacket(uint8_t txBuffer[11])
|
void buildPacket(uint8_t txBuffer[11])
|
||||||
{
|
{
|
||||||
@ -112,4 +115,5 @@ static void gps_loop() {
|
|||||||
txBuffer[9] = alt >> 8;
|
txBuffer[9] = alt >> 8;
|
||||||
txBuffer[10] = alt;
|
txBuffer[10] = alt;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -31,11 +31,10 @@ RTC_DATA_ATTR uint32_t count = 0;
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
#include <TinyGPS++.h>
|
#include <TinyGPS++.h>
|
||||||
|
|
||||||
#ifdef PAYLOAD_USE_FULL
|
#if defined(PAYLOAD_USE_FULL)
|
||||||
uint8_t txBuffer[9];
|
// includes number of satellites and accuracy
|
||||||
#endif
|
uint8_t txBuffer[10];
|
||||||
|
#elif defined(PAYLOAD_USE_CAYENNE)
|
||||||
#ifdef PAYLOAD_USE_CAYENNE
|
|
||||||
// CAYENNE DF
|
// CAYENNE DF
|
||||||
static uint8_t txBuffer[11] = {0x03, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
static uint8_t txBuffer[11] = {0x03, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user