Help me, I can't connect Neo-6m and MAXIIOT DL7612-AS923-TH in one Esp32-wroom-32. I want to get latitude/longtitude from neo-6m and send it to lorawan by maxiiot but i don't know to coding. This is code.
#include <TinyGPS++.h>
#include <HardwareSerial.h>
#define RXPin_1 (22)
#define TXPin_1 (21)
#define RXPin_2 (17)
#define TXPin_2 (16)
static const uint32_t GPSBaud = 9600;
String response = "";
// The TinyGPS++ object
TinyGPSPlus gps;
// The serial connection to the GPS device
HardwareSerial ss(2);
void setup(){
Serial.begin(115200);
ss.begin(GPSBaud, SERIAL_8N1, RXPin_1, TXPin_1, false);
Serial.println(TinyGPSPlus::libraryVersion());
Serial2.begin(115200, SERIAL_8N1, RXPin_2, TXPin_2);
sendCommand("AT\r\n");
sendCommand("AT+INFO\r\n");
sendCommand("AT+NCONFIG\r\n");
sendCommand("AT+DEVEUI\r\n");
sendCommand("AT+APPKEY\r\n");
sendCommand("AT+APPEUI\r\n");
sendCommand("AT+NRB\r\n");
delay(40000);
}
void loop(){
while (ss.available() > 0)
if (gps.encode(ss.read())){
displayInfo();
sendCommand("AT+INFO\r\n");
sendCommand("AT+CGATT\r\n");
sendData(5,"HELLO");
delay(10000);
}
if (millis() > 5000 && gps.charsProcessed() < 10){
Serial.println(F("No GPS detected: check wiring."));
while(true);
}
}
void displayInfo(){
Serial.print(F("Location: "));
if (gps.location.isValid()){
Serial.print(gps.location.lat(), 6);
Serial.print(F(","));
Serial.print(gps.location.lng(), 6);
}else{
Serial.print(F("INVALID"));
}
Serial.println();
}
void sendCommand(String atComm){
response = "";
Serial2.print(atComm);
Serial.println("*******AT Command Sent");
Serial.print(atComm);
delay(300);
while(Serial2.available()){
char ch = Serial2.read();
//delay(500);
response += ch;
}
Serial.println(response);
}
void sendData(int type, String data){
String command = (String)"AT+NCMGS=" + type + "," +data + (String)"\r\n";
sendCommand(command);
}