Chat freely about anything...

User avatar
By cpper
#80855 I'm trying to do serial communication between a Wemos D1 mini and a GPS module. The following happens:
    SoftwareSerial works ok on two GPIO pins(for example D1+D6)
    HardwareSerial works ok on GPIO13+GPIO15(D7+D8), after being remapped by calling Serial.swap();
    SoftwareSerial started on Tx+Rx works, but with lots of garbage
    Default HardwareSerial on Tx+Rx works, but with the same amount of garbage.
Between these tests, the code stays the same(only changes related to serial object), and the baud rate is always the same.
The GPS sends data each second. While data is received, the LED stays on.

What could cause this issue ? What's wrong with the Tx/Rx pins ?
User avatar
By Barnabybear
#80857 Hi, it could be stuck in a reset loop where it reads and prints one set of data and then resets. If you set the serial monitor to 74880 baud it will give you a better idea. To go further than that you’ll need to post some code.
User avatar
By cpper
#80859 It's not resetting, the output from the GPS is appended to a string which gets longer and longer.
This is the code:
Code: Select all#include "Network.h"
Network net;
String output = "";
bool newdata=false;
 
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);
 
  net.begin();
  Serial.begin(115200);
  Serial.setTimeout(5);
 
}
 
void loop() {
  while (Serial.available() > 0) {
    if (!newdata) {
      newdata = true;
      digitalWrite(LED_BUILTIN, LOW);
    }
    output += Serial.readString();
  }
  if (newdata) {
    net.handleClient(output);
    digitalWrite(LED_BUILTIN, HIGH);
    newdata = false;
  }
}


I know this blocking approach is not recommended, I only use it in this demo.
Keep in mind that the exact same code works perfectly if I add Serial.swap() after Serial.begin(), or change Serial to SoftwareSerial on any GPIO pins(and rewire accordingly). That being said, I don't see how the problem could be related to the code.