parent
055e435177
commit
407fa3d871
@ -1,58 +1,49 @@
|
||||
#include <Arduino.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
|
||||
#include "TinyGPS++.h";
|
||||
|
||||
#define GPS_TX_PIN 1
|
||||
#define GPS_RX_PIN 3
|
||||
#define GPS_RX_PIN 16
|
||||
#define GPS_TX_PIN 17
|
||||
|
||||
const char* SSID = "Bytetools Technologies Inc.";
|
||||
const char* PASS = "Fuck commies #69420!";
|
||||
|
||||
AsyncWebServer server(80);
|
||||
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() {
|
||||
Serial.begin(9600);
|
||||
//SerialGPS.begin(9600, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
|
||||
WiFi.begin(SSID, PASS);
|
||||
Serial.print("Connecting to wifi");
|
||||
Serial.print(".");
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(1000);
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.println(WiFi.localIP());
|
||||
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
|
||||
request->send(200, "text/plain", "HELO");
|
||||
});
|
||||
server.begin();
|
||||
/*
|
||||
Serial speed of USB.
|
||||
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.begin(115200);
|
||||
// Serial speed of GPS module
|
||||
Serial2.begin(9600, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
|
||||
Serial.println("Setup complete!");
|
||||
}
|
||||
|
||||
// loop forever
|
||||
void loop() {
|
||||
/*
|
||||
//while (SerialGPS.available() > 0) {
|
||||
//gps.encode(SerialGPS.read());
|
||||
// if there is anything to read from serial port 2
|
||||
while (Serial2.available()) {
|
||||
// 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()) {
|
||||
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.println(gps.location.lat());
|
||||
Serial.print("LON=");
|
||||
Serial.println(gps.location.lng());
|
||||
Serial.print("ALT=");
|
||||
Serial.println(gps.altitude.meters());
|
||||
} else {
|
||||
Serial.println("INVALID LOCATION");
|
||||
}
|
||||
//}
|
||||
*/
|
||||
//Serial.println("Nothing in buffer.");
|
||||
//delay(1000);
|
||||
}
|
||||
Serial.print(LAT, 6);
|
||||
Serial.print(" LON=");
|
||||
Serial.print(LON, 6);
|
||||
Serial.print(" ALT=");
|
||||
Serial.println(ALT, 6);
|
||||
} // close if
|
||||
} // close while
|
||||
} // close loop
|
||||
|
Loading…
Reference in new issue