parent
055e435177
commit
407fa3d871
@ -1,58 +1,49 @@
|
|||||||
#include <Arduino.h>
|
#include "TinyGPS++.h";
|
||||||
#include <types.h>
|
|
||||||
#include <TinyGPS++.h> // the TinyGPS++ librarie
|
|
||||||
//#include <HardwareSerial.h> // to convert serial from the GPS into something TinyGPS can understand
|
|
||||||
#include <WiFi.h> // from the ESP32 plugin
|
|
||||||
#include <AsyncTCP.h> // for basic TCP t/rx
|
|
||||||
#include <ESPAsyncWebServer.h> // for web server impl.
|
|
||||||
//#include <SoftwareSerial.h> // to send data back over USB
|
|
||||||
|
|
||||||
#define GPS_TX_PIN 1
|
#define GPS_RX_PIN 16
|
||||||
#define GPS_RX_PIN 3
|
#define GPS_TX_PIN 17
|
||||||
|
|
||||||
const char* SSID = "Bytetools Technologies Inc.";
|
|
||||||
const char* PASS = "Fuck commies #69420!";
|
|
||||||
|
|
||||||
AsyncWebServer server(80);
|
|
||||||
TinyGPSPlus gps;
|
TinyGPSPlus gps;
|
||||||
//HardwareSerial SerialGPS(1);
|
|
||||||
|
|
||||||
// Load variables into globals
|
/* LAT = latitude
|
||||||
|
LON = longitude
|
||||||
|
ALT = altitude
|
||||||
|
Note: all 32-bit flaoting point decimal operations ARE atomic for the ESP32.
|
||||||
|
This means that sharing data across threads and cores IS SAFE!
|
||||||
|
So launching the web server on a separate thread will ot cause a data race */
|
||||||
|
float LAT, LON, ALT;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
/*
|
||||||
//SerialGPS.begin(9600, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
|
Serial speed of USB.
|
||||||
WiFi.begin(SSID, PASS);
|
NOTE: this model of ESP has a native baud rate of 115200, meaning that boot message will display properly along with all other serial output
|
||||||
Serial.print("Connecting to wifi");
|
*/
|
||||||
Serial.print(".");
|
Serial.begin(115200);
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
// Serial speed of GPS module
|
||||||
delay(1000);
|
Serial2.begin(9600, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
|
||||||
Serial.print(".");
|
Serial.println("Setup complete!");
|
||||||
}
|
|
||||||
Serial.println(WiFi.localIP());
|
|
||||||
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
|
|
||||||
request->send(200, "text/plain", "HELO");
|
|
||||||
});
|
|
||||||
server.begin();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// loop forever
|
|
||||||
void loop() {
|
void loop() {
|
||||||
/*
|
// if there is anything to read from serial port 2
|
||||||
//while (SerialGPS.available() > 0) {
|
while (Serial2.available()) {
|
||||||
//gps.encode(SerialGPS.read());
|
// read one character into the char "in"
|
||||||
|
char in = Serial2.read();
|
||||||
|
//Serial.print(in);
|
||||||
|
// send to GPS encoder to create new data
|
||||||
|
gps.encode(in);
|
||||||
|
// if a new location is given
|
||||||
if (gps.location.isUpdated()) {
|
if (gps.location.isUpdated()) {
|
||||||
Serial.println("HELLO");
|
// set all location attributes we desire
|
||||||
|
LAT = gps.location.lat();
|
||||||
|
LON = gps.location.lng();
|
||||||
|
ALT = gps.altitude.meters();
|
||||||
Serial.print("LAT=");
|
Serial.print("LAT=");
|
||||||
Serial.println(gps.location.lat());
|
Serial.print(LAT, 6);
|
||||||
Serial.print("LON=");
|
Serial.print(" LON=");
|
||||||
Serial.println(gps.location.lng());
|
Serial.print(LON, 6);
|
||||||
Serial.print("ALT=");
|
Serial.print(" ALT=");
|
||||||
Serial.println(gps.altitude.meters());
|
Serial.println(ALT, 6);
|
||||||
} else {
|
} // close if
|
||||||
Serial.println("INVALID LOCATION");
|
} // close while
|
||||||
}
|
} // close loop
|
||||||
//}
|
|
||||||
*/
|
|
||||||
//Serial.println("Nothing in buffer.");
|
|
||||||
//delay(1000);
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in new issue