I use NEO-6M GPS module GY-GPS6MV2
and i want to connect with WiFi LoRa 32(V3)
I tried connecting the RX pin of the GPS module to pin 36 and the TX pin to pin 37.And connecting the RX pin to the TX pin on the board, connecting the TX pin to the RX pin on the board.
But I couldn’t receive any GPS signal.
Which pins of the GPS module should be connected to the ESP32, or how should the code be modified?
User
#include “heltec.h”
#include <SPI.h>
#include <TinyGPS++.h>
#define BAND 915E6 //you can set band here directly,e.g. 868E6,915E6
TinyGPSPlus gps;
unsigned int counter = 0;
String rssi = “RSSI --”;
String packSize = “–”;
String packet ;
int startSec;
int currentSec;
double latitude;
double longitude;
char latitudeString[12];
char longitudeString[12];
char gpsString[33];
char hhString[4];
char mmString[4];
int sendInterval = 10; //10 seconds
void displayInfo(){
if (gps.location.isValid()) {
latitude=gps.location.lat();
longitude=gps.location.lng();
dtostrf(latitude,6,3,latitudeString);
dtostrf(longitude,7,3,longitudeString);
strcpy(gpsString, "Latitude:");
strcat(gpsString, latitudeString);
strcat(gpsString, " Longitude:");
strcat(gpsString, longitudeString);
Serial.print("Latitude: ");
Serial.println(latitude, 6);
Serial.print("Longitude: ");
Serial.println(longitude, 6);
Serial.print("Altitude: ");
Serial.println(gps.altitude.meters());
}
else Serial.println(“Location: Not Available”);
Serial.print("Date: ");
if (gps.date.isValid()) {
int mm=gps.date.month();
int dd=gps.date.day();
int yy=gps.date.year();
Serial.print(mm);
Serial.print("/");
Serial.print(dd);
Serial.print("/");
Serial.println(yy);
}
else Serial.println(“Not Available”);
Serial.print("Time: ");
if (gps.time.isValid()) {
int hh=gps.time.hour();
int mm=gps.time.minute();
int ss=gps.time.second();
dtostrf(hh,2,0,hhString);
dtostrf(mm,2,0,mmString);
if (hh < 10) Serial.print(F("0"));
Serial.print(hh);
Serial.print(":");
if (mm < 10) Serial.print(F("0"));
Serial.print(mm);
Serial.print(":");
if (ss < 10) Serial.print(F("0"));
Serial.print(ss);
Serial.print(".");
if (gps.time.centisecond() < 10) Serial.print(F("0"));
Serial.println(gps.time.centisecond());
}
else Serial.println(“Not Available”);
Serial.println();
Serial.println();
delay(100);
}
void setup() {
Serial.begin(115200);
Serial2.begin(9600, SERIAL_8N1, 36 , 37);
Heltec.begin(true, false, true, true, BAND);
Heltec.display->init();
Heltec.display->flipScreenVertically();
Heltec.display->setFont(ArialMT_Plain_10);
Heltec.display->clear();
Heltec.display->drawString(0, 0, “Heltec.LoRa Initial success!”);
Heltec.display->display();
startSec = int(millis()/1000);
delay(500);
}
void loop(){
currentSec = int(millis()/1000);
while (Serial2.available() > 0)
if (gps.encode(Serial2.read()))
displayInfo();
if ((currentSec-startSec) > sendInterval) {
Serial.println("Sending LoRa Data...");
Serial.print("Latitude: ");
Serial.println(latitude, 6);
Serial.print("Longitude: ");
Serial.println(longitude, 6);
Serial.println("Attempting to start LoRa...");
LoRa.beginPacket(); //send packet
/*
-
LoRa.setTxPower(txPower,RFOUT_pin);
-
txPower – 0 ~ 20
-
RFOUT_pin could be RF_PACONFIG_PASELECT_PABOOST or RF_PACONFIG_PASELECT_RFO
-
- RF_PACONFIG_PASELECT_PABOOST – LoRa single output via PABOOST, maximum output 20dBm
-
- RF_PACONFIG_PASELECT_RFO – LoRa single output via RFO_HF / RFO_LF, maximum output 14dBm
*/
LoRa.setTxPower(14,RF_PACONFIG_PASELECT_PABOOST);
LoRa.println(gpsString);
//LoRa.println(counter);
LoRa.endPacket();
digitalWrite(LED, HIGH); // turn the LED on
delay(1000);
digitalWrite(LED, LOW); // turn the LED off
Heltec.display->clear();
Heltec.display->setTextAlignment(TEXT_ALIGN_LEFT);
Heltec.display->setFont(ArialMT_Plain_10);
Heltec.display->drawString(0, 0, "Sending packet: ");
Heltec.display->drawString(90, 0, String(counter));
Heltec.display->drawString(0, 20, "Latitude");
Heltec.display->drawString(60, 20, "Longitude");
Heltec.display->drawString(0, 32, String(latitude,4));
Heltec.display->drawString(60, 32, String(longitude,4));
Heltec.display->display();
Serial.print("Frame Counter: ");
Serial.println(counter);
counter++;
startSec = int(millis()/1000);
}
}