0

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.

  • what is ` <Pins_Arduino.h>`? if you select D1 R2 in tools menu, you have the Dx constants. D3 has external pull-up. it could disturb SoftwareSerial. SoftwareSerial of esp8266 doesn't work good in 2.4.x versions – Juraj Feb 7 at 20:25
  • Ah! I am using the 2.4.2 version of the board. Which version would you suggest? – Madere Feb 7 at 20:26
  • I never used SoftwareSerial with esp8266. I only know from forum and SE about the problems. And I saw some changes for SoftwareSerial in the GitHub repo of the esp8266 Arduino package. Try 2.5 beta version in Boards Manager. And pins D1 D2 (without <Pins_Arduino.h>) – Juraj Feb 7 at 20:29
  • Post that as an answer. I'll give it a try and accept if it works. As an aside, I only added the Pins... include as a last ditch effort. – Madere Feb 7 at 20:36
  • try it first. there was other question about SoftwareSerial of esp8266 yesterday without result arduino.stackexchange.com/questions/61313/… – Juraj Feb 7 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.