I am trying to use a Wemos D1 R2 to connect to my NEO-6M GPS module. I am able to make the module work fine with an Arduino UNO. I'm having significant trouble with the D1. Based upon other posts I have read here, I have included the appropriate Pins_Arduino.h include file and used the aliased settings. Here is the code I am using:
#include <Pins_Arduino.h>
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
// The serial connection to the GPS module
SoftwareSerial ss(D2, D3); // Here are the aliased pins
TinyGPSPlus gps;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
ss.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
while (ss.available() > 0){
gps.encode(ss.read());
if (gps.location.isUpdated()){
//int value = analogRead(lightPin);
//Serial.print("Light= ");
//Serial.println(value);
Serial.print("Latitude= ");
Serial.print(gps.location.lat(), 6);
Serial.print(" Longitude= ");
Serial.println(gps.location.lng(), 6);
Serial.println(gps.time.value());
// Hour (0-23) (u8)
Serial.print("Hour = ");
Serial.println(gps.time.hour());
// Minute (0-59) (u8)
Serial.print("Minute = ");
Serial.println(gps.time.minute());
// Second (0-59) (u8)
Serial.print("Second = ");
Serial.println(gps.time.second());
// 100ths of a second (0-99) (u8)
Serial.print("Centisecond = ");
Serial.println(gps.time.centisecond());
}
}
}
I have ensured that I have the RX and TX pins correct, even reversing them to test the connection. Am I doing something wrong with the pins? Or do I have to just drop seven and punt on the D1 and get an ESP8266 shield for my UNO?
To help explain the ultimate purpose of this project, plan to use an esp8266 based web server to pull geographic based data from other sensors on the board. If I can't get the GPS to work here, I'll need to re-engineer my project.
Thanks. I apologize if this is a duplicate question, but my petrified brain just isn't searching correctly if it is.
Update:
If I use an Arduino UNO, everything works fine. I tried using the WeMos D1 R2 over the weekend and received data for about 5 seconds and then it stopped. I used pins D4 and D5 for RX and TX respectively. I'm not sure if the data was in the serial buffer when I uploaded a new Sketch or if it was actually returned from the GPS.
I'm going to punt on making the WeMos board work for now and ordered an ESP-01S to use with my Arduino UNO. I'm also reaching out to a supplier for assistance on this. Thanks for the help.
I'm going to leave this open for now in case someone else can provide some insight.