testing GPS
This commit is contained in:
parent
77431dbdde
commit
a43da889d1
@ -232,7 +232,7 @@ Note: all settings are stored in NVRAM and will be reloaded when device starts.
|
|||||||
|
|
||||||
0x80 get device configuration
|
0x80 get device configuration
|
||||||
|
|
||||||
device answers with it's current configuration. The configuration is a C structure declared in file [globals.h](src/globals.h#L27-L45) with the following definition:
|
device answers with it's current configuration. The configuration is a C structure declared in file [globals.h](src/globals.h#L32-L50) with the following definition:
|
||||||
|
|
||||||
byte 1: Lora SF (7..12)
|
byte 1: Lora SF (7..12)
|
||||||
byte 2: Lora TXpower (2..15)
|
byte 2: Lora TXpower (2..15)
|
||||||
|
@ -33,6 +33,7 @@ lib_deps_rgbled =
|
|||||||
SmartLeds@>=1.1.3
|
SmartLeds@>=1.1.3
|
||||||
lib_deps_gps =
|
lib_deps_gps =
|
||||||
https://github.com/mikalhart/TinyGPSPlus.git
|
https://github.com/mikalhart/TinyGPSPlus.git
|
||||||
|
;beware of TinyGPSplus in PlatformIO library manager, it loads old v.092 labeled as 1.0.0 !!
|
||||||
build_flags =
|
build_flags =
|
||||||
; we need build_flag for logging, otherwise we can't use ESP_LOGx in arduino framework
|
; we need build_flag for logging, otherwise we can't use ESP_LOGx in arduino framework
|
||||||
; ---> NOTE: For production run set DEBUG_LEVEL level to NONE! <---
|
; ---> NOTE: For production run set DEBUG_LEVEL level to NONE! <---
|
||||||
|
@ -51,14 +51,14 @@ typedef struct {
|
|||||||
|
|
||||||
#ifdef HAS_GPS
|
#ifdef HAS_GPS
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t latitude;
|
double latitude;
|
||||||
uint32_t longitude;
|
double longitude;
|
||||||
uint8_t hdop;
|
double hdop;
|
||||||
uint32_t satellites;
|
uint32_t satellites;
|
||||||
uint16_t altitude;
|
double altitude;
|
||||||
} gpsStatus_t;
|
} gpsStatus_t;
|
||||||
extern gpsStatus_t gps_status; // struct for storing gps data
|
extern gpsStatus_t gps_status; // struct for storing gps data
|
||||||
extern TinyGPSPlus gps; // Make TinyGPS++ instance globally availabe
|
extern TinyGPSPlus gps; // Make TinyGPS++ instance globally availabe
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern configData_t cfg;
|
extern configData_t cfg;
|
||||||
|
@ -9,9 +9,9 @@ static const char TAG[] = "main";
|
|||||||
void gps_read(){
|
void gps_read(){
|
||||||
gps_status.latitude = gps.location.lat();
|
gps_status.latitude = gps.location.lat();
|
||||||
gps_status.longitude = gps.location.lng();
|
gps_status.longitude = gps.location.lng();
|
||||||
gps_status.satellites = (uint8_t) gps.satellites.value();
|
gps_status.satellites = gps.satellites.value();
|
||||||
gps_status.hdop = (uint8_t) (gps.hdop.value() / 100);
|
gps_status.hdop = gps.hdop.value();
|
||||||
gps_status.altitude = (uint16_t) gps.altitude.meters();
|
gps_status.altitude = gps.altitude.meters();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// GPS serial feed FreeRTos Task
|
/// GPS serial feed FreeRTos Task
|
||||||
@ -19,17 +19,30 @@ void gps_loop(void * pvParameters) {
|
|||||||
|
|
||||||
configASSERT( ( ( uint32_t ) pvParameters ) == 1 ); // FreeRTOS check
|
configASSERT( ( ( uint32_t ) pvParameters ) == 1 ); // FreeRTOS check
|
||||||
|
|
||||||
HardwareSerial GPS_Serial(1);
|
HardwareSerial GPS_Serial(1);
|
||||||
//GPS_Serial.begin(HAS_GPS);
|
|
||||||
GPS_Serial.begin(9600, SERIAL_8N1, 12, 15 );
|
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
|
|
||||||
while (GPS_Serial.available()) {
|
if (cfg.gpsmode)
|
||||||
gps.encode(GPS_Serial.read());
|
{
|
||||||
|
// if GPS function is enabled try serial connect to GPS device
|
||||||
|
GPS_Serial.begin(HAS_GPS);
|
||||||
|
|
||||||
|
while(cfg.gpsmode) {
|
||||||
|
// feed GPS decoder with serial NMEA data from GPS device
|
||||||
|
while (GPS_Serial.available()) {
|
||||||
|
gps.encode(GPS_Serial.read());
|
||||||
|
vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// after GPS function was disabled, close connect to GPS device
|
||||||
|
GPS_Serial.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog
|
vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog
|
||||||
}
|
|
||||||
}
|
} // end of infinite loop
|
||||||
|
|
||||||
|
} // gps_loop()
|
||||||
|
|
||||||
#endif // HAS_GPS
|
#endif // HAS_GPS
|
@ -6,8 +6,7 @@
|
|||||||
//#define HAS_BUTTON GPIO_NUM_39 // on board button "BOOT" (next to reset button) !! seems not to work!!
|
//#define HAS_BUTTON GPIO_NUM_39 // on board button "BOOT" (next to reset button) !! seems not to work!!
|
||||||
#define HAS_BATTERY_PROBE ADC1_GPIO35_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7
|
#define HAS_BATTERY_PROBE ADC1_GPIO35_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7
|
||||||
#define BATT_FACTOR 2 // voltage divider 100k/100k on board
|
#define BATT_FACTOR 2 // voltage divider 100k/100k on board
|
||||||
//#define HAS_GPS 9600, SERIAL_8N1, 12, 15
|
#define HAS_GPS 9600, SERIAL_8N1, 12, 15
|
||||||
#define HAS_GPS 1
|
|
||||||
|
|
||||||
// re-define pin definitions of pins_arduino.h
|
// re-define pin definitions of pins_arduino.h
|
||||||
#define PIN_SPI_SS GPIO_NUM_18 // ESP32 GPIO18 (Pin18) -- HPD13A NSS/SEL (Pin4) SPI Chip Select Input
|
#define PIN_SPI_SS GPIO_NUM_18 // ESP32 GPIO18 (Pin18) -- HPD13A NSS/SEL (Pin4) SPI Chip Select Input
|
||||||
|
@ -129,8 +129,6 @@ void do_send(osjob_t* j){
|
|||||||
mydata[3] = 0;
|
mydata[3] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Prepare upstream data transmission at the next possible time.
|
// Prepare upstream data transmission at the next possible time.
|
||||||
LMIC_setTxData2(COUNTERPORT, mydata, sizeof(mydata), (cfg.countermode & 0x02));
|
LMIC_setTxData2(COUNTERPORT, mydata, sizeof(mydata), (cfg.countermode & 0x02));
|
||||||
ESP_LOGI(TAG, "%d bytes queued to send", sizeof(mydata));
|
ESP_LOGI(TAG, "%d bytes queued to send", sizeof(mydata));
|
||||||
|
@ -598,9 +598,6 @@ do_send(&sendjob);
|
|||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
||||||
HardwareSerial GPS_Serial(1);
|
|
||||||
GPS_Serial.begin(9600, SERIAL_8N1, 12, 15 );
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
// simple state machine for controlling uptime, display, LED, button, memory.
|
// simple state machine for controlling uptime, display, LED, button, memory.
|
||||||
@ -629,7 +626,7 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( (uptime() % 10000) == 0 )
|
if ( (uptime() % 10000) == 0 )
|
||||||
ESP_LOGI(TAG, "GPS NMEA data passed %d / failed: %d / with fix: %d || Sats: %d / HDOP: %d || m/s: %d / %d", gps.passedChecksum(), gps.failedChecksum(), gps.sentencesWithFix(), gps.satellites.value(), gps.hdop.value(), gps.time.minute(), gps.time.second() );
|
ESP_LOGI(TAG, "GPS NMEA data: passed %d / failed: %d / with fix: %d", gps.passedChecksum(), gps.failedChecksum(), gps.sentencesWithFix());
|
||||||
|
|
||||||
vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog
|
vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user