#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include “LoRa_E32.h”
static const int RXPin = 11, TXPin = 10;
static const uint32_t GPSBaud = 9600;
TinyGPSPlus gps;
SoftwareSerial portgps(RXPin, TXPin);
SoftwareSerial portlora(52, 51);
LoRa_E32 e32ttl(&portlora);
typedef struct {
byte altitude[10];
byte latitude[10];
byte longtitude[10];
} Signal;
Signal data;
void setup()
{
Serial.begin(9600);
portgps.begin(GPSBaud);
delay(500);
e32ttl.begin();
delay(500);
}
void loop()
{
portgps.listen();
if (gps.location.isValid()) {
Serial.print(“Altitude: “);
*(float*)(data.altitude) = (gps.altitude.meters());
Serial.println(*(float*)data.altitude);
Serial.print(“Latitude: “);
*(float*)(data.latitude) = (gps.location.lat() ,6);
Serial.println(*(float*)data.latitude);
Serial.print(“Longitude: “);
*(float*)(data.longtitude) = (gps.location.lng(), 6);
Serial.println(*(float*)data.longtitude);
}
else
Serial.println( “error”);
smartDelay(1000);
if (millis() > 5000 && gps.charsProcessed() < 10)
Serial.println(F(“No GPS data received: check wiring”));
Serial.println();
portlora.listen();
ResponseStatus rs = e32ttl.sendFixedMessage(0, 6, 23, &data, sizeof(Signal));
Serial.println(rs.getResponseDescription());
}
static void smartDelay(unsigned long ms)
{
unsigned long start = millis();
do
{
while (portgps.available())
gps.encode(portgps.read());
} while (millis() – start < ms);
}
tmmdır hocam bu kodlar burda kalsın soran olursa bakar. Alıcı kısmında şu an da virgülden sonra 2 basamak yazar ,6 ile virgülden sonra 6 basamakta yazdırabilirsin.
Serial.println(*(float*)data.latitude ,6); gibi
#include “Arduino.h”
#include “LoRa_E32.h”
#include <SoftwareSerial.h>
SoftwareSerial mySerial(52, 51); // Arduino RX <– e32 TX, Arduino TX –> e32 RX
LoRa_E32 e32ttl(&mySerial);
typedef struct {
byte Altitude[10];
byte Latitude[10];
byte Longtitude[10];
} Signal;
Signal data;
void setup() {
Serial.begin(9600);
delay(500);
Serial1.begin(9600);
delay(500);
e32ttl.begin();
}
void loop() {
while (e32ttl.available() > 1) {
ResponseStructContainer rsc = e32ttl.receiveMessage(sizeof(Signal));
data = *(Signal*) rsc.data;
rsc.close();
Serial.print(F(“Altitude: “));
Serial.print(*(float*)data.Altitude);
Serial.print(F(“**** Latitude: “));
Serial.println(*(float*)data.Latitude);
Serial.print(F(“**** Longtitude: “));
Serial.print(*(float*)data.Longtitude);
}
}
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include “LoRa_E32.h”
static const int RXPin = 11, TXPin = 10;
static const uint32_t GPSBaud = 9600;
TinyGPSPlus gps;
SoftwareSerial portgps(RXPin, TXPin);
SoftwareSerial portlora(52, 51);
LoRa_E32 e32ttl(&portlora);
typedef struct {
byte altitude[10];
byte latitude[10];
byte longtitude[10];
} Signal;
Signal data;
void setup()
{
Serial.begin(9600);
portgps.begin(GPSBaud);
delay(500);
e32ttl.begin();
delay(500);
}
void loop()
{
portgps.listen();
if (gps.location.isValid()) {
Serial.print(“Altitude: “);
*(float*)(data.altitude) = (gps.altitude.meters());
Serial.println(*(float*)data.altitude);
Serial.print(“Latitude: “);
*(float*)(data.latitude) = (gps.location.lat());
Serial.println(gps.location.lat());
Serial.print(“Longitude: “);
*(float*)(data.longtitude) = (gps.location.lng());
Serial.println(gps.location.lng());
}
else
Serial.println( “error”);
smartDelay(1000);
if (millis() > 5000 && gps.charsProcessed() < 10)
Serial.println(F(“No GPS data received: check wiring”));
Serial.println();
portlora.listen();
ResponseStatus rs = e32ttl.sendFixedMessage(0, 6, 23, &data, sizeof(Signal));
Serial.println(rs.getResponseDescription());
}
static void smartDelay(unsigned long ms)
{
unsigned long start = millis();
do
{
while (portgps.available())
gps.encode(portgps.read());
} while (millis() – start < ms);
}