Compiling error for Adafruit GPS: "SoftwareSerial.h: No such file or directory"

Hi,

I'm very new to this so perhaps I'm missing something obvious but bare with me:

I have a Nano RP2040 and an 'ultimate GPS breakout' from Adafruit. The idea is that I install the Adafruit library for the GPS, wire some components together, and then I'll receive location data through the serial monitor.

I'm following a tutorial on making this, and it's telling me to run an example included in the library called 'GPS_SoftwareSerial_EchoTest'. When I try uploading this to the Arduino, I get an error reading: "SoftwareSerial.h: No such file or directory".

A search shows that others have had this issue before, though I don't currently have the knowledge to understand what their solutions were.

Any help is appreciated. Thank you!

Does the tutorial relate specifically to the RP2040 ?
Please provide a link to to the tutorial

Why do you need to use SoftwareSerial when you can use Serial1 to connect to the GPS ?

I'm following a few tutorials, but this is the main one:

It doesn't cover the RP2040, but an Arduino Uno instead.

I'm not sure I understand your last question, but to try answering: I've not come across any reason as to why I can't use the Serial ports to connect to the GPS, so I think I'll do that if I can't get this to work otherwise. Am I right in thinking that this would call for a change in the sketch as it calls on pins 7 and 8 to connect to RX and TX? If so, I don't have the understanding to change the sketch unless it's quite simple.

Yes, its quite simple. You will use Serial1 instead of software serial(which is not supported on the RP2020).

You will use the Rx and Tx pins on the RP2040 which are independent from the usb serial. They will replace the connections to pin 7 and 8.

See this discussion of using Serial1 on the RP2040.
https://docs.arduino.cc/tutorials/nano-rp2040-connect/rp2040-01-technical-reference#uart

The tx of the RP2040 will go to the rx of the gps and the tx of the gps will connect to the rx of the RP2040.

Not simple enough it seems! I've given it a go but I can't seem to figure out how to change the code to get this to work. This is the code, if it means anything:

// Test code for Adafruit GPS modules using MTK3329/MTK3339 driver
//
// This code just echos whatever is coming from the GPS unit to the
// serial monitor, handy for debugging!
//
// Tested and works great with the Adafruit Ultimate GPS module
// using MTK33x9 chipset
//    ------> http://www.adafruit.com/products/746
// Pick one up today at the Adafruit electronics shop
// and help support open source hardware & software! -ada

#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>

// Connect the GPS Power pin to 5V
// Connect the GPS Ground pin to ground
// Connect the GPS TX (transmit) pin to Digital 8
// Connect the GPS RX (receive) pin to Digital 7

// You can change the pin numbers to match your wiring:
SoftwareSerial mySerial(8, 7);

#define PMTK_SET_NMEA_UPDATE_1HZ  "$PMTK220,1000*1F"
#define PMTK_SET_NMEA_UPDATE_5HZ  "$PMTK220,200*2C"
#define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F"

// turn on only the second sentence (GPRMC)
#define PMTK_SET_NMEA_OUTPUT_RMCONLY "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29"
// turn on GPRMC and GGA
#define PMTK_SET_NMEA_OUTPUT_RMCGGA "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
// turn on ALL THE DATA
#define PMTK_SET_NMEA_OUTPUT_ALLDATA "$PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
// turn off output
#define PMTK_SET_NMEA_OUTPUT_OFF "$PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28"

#define PMTK_Q_RELEASE "$PMTK605*31"

void setup() {
  while (!Serial); // wait for Serial to be ready

  Serial.begin(115200); // The serial port for the Arduino IDE port output
  mySerial.begin(9600);
  delay(2000);

  Serial.println("Software Serial GPS Test Echo Test");
  // you can send various commands to get it started
  //mySerial.println(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  mySerial.println(PMTK_SET_NMEA_OUTPUT_ALLDATA);

  mySerial.println(PMTK_SET_NMEA_UPDATE_1HZ);

  Serial.println("Get version!");
  mySerial.println(PMTK_Q_RELEASE);
 }


void loop() {
  if (Serial.available()) {
   char c = Serial.read();
   Serial.write(c);
   mySerial.write(c);
  }
  if (mySerial.available()) {
    char c = mySerial.read();
    Serial.write(c);
  }
}

What did you try? Please post your best attempt to use Serial1 instead of software serial.

Did you read any reference material on using Serial1 with the rp2040?

Unfortunately my best attempt might not be very good as I'm so new to this kind of stuff. Regardless, I've moved the pins in D7 and D8 to RX and TX instead, as you've suggested.

I've repeatedly triedrunning the examples 'GPS_SoftwareSerial_EchoTest' and 'GPS_HardwareSerial_EchoTest' in case that did anything, but no. I also tried pasting the code that you linked to in the RP2040 Cheat sheet (is that what I was supposed to try?), but that also failed.

I've read that the TX and RX lines can't work simultaneously - would you happen to know if this affects performance? Still, as you've mentioned SoftwareSerial isn't supposed on the RP2040, perhaps the best solution is to purchase a different arduino? If so, I think the Arduino Micro seems to work with SoftwareSerial.

Thanks!

You should post your updated code; we do not know what you've changed.

These would be the steps:

  1. Change mySerial.begin(9600) to Serial1.begin(9600);
  2. And anywhere where you use mySerial, replace it with Serial1.
  3. Remove #include <SoftwareSerial.h> and SoftwareSerial mySerial(8, 7);

A post was split to a new topic: Problem with Serial communications

To avoid too many changes to the sketch, I often avoid steps 1 and 2, carry out step 3 and add a;

#define mySerial Serial1

Like this?

// Test code for Adafruit GPS modules using MTK3329/MTK3339 driver
//
// This code just echos whatever is coming from the GPS unit to the
// serial monitor, handy for debugging!
//
// Tested and works great with the Adafruit Ultimate GPS module
// using MTK33x9 chipset
//    ------> http://www.adafruit.com/products/746
// Pick one up today at the Adafruit electronics shop
// and help support open source hardware & software! -ada

#include <Adafruit_GPS.h>


#define mySerial Serial1

// Connect the GPS Power pin to 5V
// Connect the GPS Ground pin to ground
// Connect the GPS TX (transmit) pin to Arduino RX
// Connect the GPS RX (receive) pin to Arduino TX

// You can change the pin numbers to match your wiring:


#define PMTK_SET_NMEA_UPDATE_1HZ  "$PMTK220,1000*1F"
#define PMTK_SET_NMEA_UPDATE_5HZ  "$PMTK220,200*2C"
#define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F"

// turn on only the second sentence (GPRMC)
#define PMTK_SET_NMEA_OUTPUT_RMCONLY "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29"
// turn on GPRMC and GGA
#define PMTK_SET_NMEA_OUTPUT_RMCGGA "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
// turn on ALL THE DATA
#define PMTK_SET_NMEA_OUTPUT_ALLDATA "$PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
// turn off output
#define PMTK_SET_NMEA_OUTPUT_OFF "$PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28"

#define PMTK_Q_RELEASE "$PMTK605*31"

void setup() {
  while (!Serial); // wait for Serial to be ready

  Serial.begin(115200); // The serial port for the Arduino IDE port output
  mySerial.begin(9600);
  delay(2000);

  Serial.println("Software Serial GPS Test Echo Test");
  // you can send various commands to get it started
  //mySerial.println(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  mySerial.println(PMTK_SET_NMEA_OUTPUT_ALLDATA);

  mySerial.println(PMTK_SET_NMEA_UPDATE_1HZ);

  Serial.println("Get version!");
  mySerial.println(PMTK_Q_RELEASE);
 }


void loop() {
  if (Serial.available()) {
   char c = Serial.read();
   Serial.write(c);
   mySerial.write(c);
  }
  if (mySerial.available()) {
    char c = mySerial.read();
    Serial.write(c);
  }
}

It's stuck uploading, unfortunately.

Thanks for the clear instructions! Is this correct?

// Test code for Adafruit GPS modules using MTK3329/MTK3339 driver
//
// This code just echos whatever is coming from the GPS unit to the
// serial monitor, handy for debugging!
//
// Tested and works great with the Adafruit Ultimate GPS module
// using MTK33x9 chipset
//    ------> http://www.adafruit.com/products/746
// Pick one up today at the Adafruit electronics shop
// and help support open source hardware & software! -ada

#include <Adafruit_GPS.h>

// Connect the GPS Power pin to 5V
// Connect the GPS Ground pin to ground
// Connect the GPS TX (transmit) pin to Digital 8
// Connect the GPS RX (receive) pin to Digital 7

// You can change the pin numbers to match your wiring:


#define PMTK_SET_NMEA_UPDATE_1HZ  "$PMTK220,1000*1F"
#define PMTK_SET_NMEA_UPDATE_5HZ  "$PMTK220,200*2C"
#define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F"

// turn on only the second sentence (GPRMC)
#define PMTK_SET_NMEA_OUTPUT_RMCONLY "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29"
// turn on GPRMC and GGA
#define PMTK_SET_NMEA_OUTPUT_RMCGGA "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
// turn on ALL THE DATA
#define PMTK_SET_NMEA_OUTPUT_ALLDATA "$PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
// turn off output
#define PMTK_SET_NMEA_OUTPUT_OFF "$PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28"

#define PMTK_Q_RELEASE "$PMTK605*31"

void setup() {
  while (!Serial); // wait for Serial to be ready

  Serial.begin(115200); // The serial port for the Arduino IDE port output
  Serial1.begin(9600);
  delay(2000);

  Serial.println("Software Serial GPS Test Echo Test");
  // you can send various commands to get it started
  //Serial1.println(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  Serial1.println(PMTK_SET_NMEA_OUTPUT_ALLDATA);

  Serial1.println(PMTK_SET_NMEA_UPDATE_1HZ);

  Serial.println("Get version!");
  Serial1.println(PMTK_Q_RELEASE);
 }


void loop() {
  if (Serial.available()) {
   char c = Serial.read();
   Serial.write(c);
   Serial1.write(c);
  }
  if (Serial1.available()) {
    char c = Serial1.read();
    Serial.write(c);
  }
}

No errors yet, but I'm stuck uploading now.

Are suggesting that the code complies correctly, but wont upload ?

Yeah, that seems to be the case.

In order to gather more information that might help us to troubleshoot your problem, I'm going to ask you to post the full output from the upload when in verbose mode.

Please do this:

  1. Select File > Preferences from the Arduino IDE's menus.
  2. Uncheck the checkbox next to Show verbose output during: ☐ compilation
  3. Check the checkbox next to Show verbose output during: ☐ upload.
  4. Click the OK button.
  5. Attempt an upload, as you did before.
  6. Wait for the upload process to fail or hang.
  7. Click on the black console pane at the bottom of the Arduino IDE window.
  8. Press Ctrl+A to select all the text.
  9. Press Ctrl+C to copy the selected text to the clipboard.
  10. Open a forum reply here by clicking the Reply button.
  11. Click the </> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code block
  12. Press Ctrl+V.
    This will paste the error output from the upload into the code block.
  13. Move the cursor outside of the code tags before you add any additional text to your reply.
  14. Click the Reply button to post the output.

I seem to now be getting an error:

Arduino: 1.8.18 (Windows 10), Board: "Arduino Nano RP2040 Connect"





















libraries\Wire\Wire.cpp.o: In function `arduino::MbedI2C::receiveThd()':

C:\Users\AmirA\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\2.6.1\libraries\Wire/Wire.cpp:169: undefined reference to `yield'

C:\Users\AmirA\AppData\Local\Temp\arduino_build_332147/..\arduino_cache_992004\core\core_arduino_mbed_nano_nanorp2040connect_d4acc5eef4da44290f2de7b3425def2e.a(Serial.cpp.o): In function `arduino::UART::operator bool()':

C:\Users\AmirA\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\2.6.1\cores\arduino\USB/PluggableUSBSerial.h:272: undefined reference to `delay'

C:\Users\AmirA\AppData\Local\Temp\arduino_build_332147/..\arduino_cache_992004\core\core_arduino_mbed_nano_nanorp2040connect_d4acc5eef4da44290f2de7b3425def2e.a(USBSerial.cpp.o): In function `arduino::USBSerial::operator bool()':

C:\Users\AmirA\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\2.6.1\cores\arduino\USB/PluggableUSBSerial.h:272: undefined reference to `delay'

C:\Users\AmirA\AppData\Local\Temp\arduino_build_332147/..\arduino_cache_992004\core\core_arduino_mbed_nano_nanorp2040connect_d4acc5eef4da44290f2de7b3425def2e.a(USBSerial.cpp.o): In function `waitForPortClose()':

C:\Users\AmirA\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\2.6.1\cores\arduino\USB/USBSerial.cpp:35: undefined reference to `millis'

C:\Users\AmirA\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\2.6.1\cores\arduino\USB/USBSerial.cpp:39: undefined reference to `delay'

C:\Users\AmirA\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\2.6.1\cores\arduino\USB/USBSerial.cpp:37: undefined reference to `millis'

C:\Users\AmirA\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\2.6.1\variants\NANO_RP2040_CONNECT/libs/libmbed.a(mbed_boot_gcc_arm.o): In function `__wrap_main':

mbed_boot_gcc_arm.c:(.text.__wrap_main+0x2): undefined reference to `main'

collect2.exe: error: ld returned 1 exit status

exit status 1

Error compiling for board Arduino Nano RP2040 Connect.



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

With what sketch ?

With anything I try, strangely enough. I've tried one of the built-in examples, the GPS_SoftwareSerial_EchoTest that I'm trying to run, as well as the edited versions we've made.

Would the fact that the arduino is in the breadboard, connected to the GPS, make any difference to uploading?

Can you upload the BareMinimum sketch ?

Can't even compile.

Arduino: 1.8.18 (Windows 10), Board: "Arduino Nano RP2040 Connect"





















libraries\Wire\Wire.cpp.o: In function `arduino::MbedI2C::receiveThd()':

C:\Users\AmirA\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\2.6.1\libraries\Wire/Wire.cpp:169: undefined reference to `yield'

C:\Users\AmirA\AppData\Local\Temp\arduino_build_332147/..\arduino_cache_992004\core\core_arduino_mbed_nano_nanorp2040connect_d4acc5eef4da44290f2de7b3425def2e.a(Serial.cpp.o): In function `arduino::UART::operator bool()':

C:\Users\AmirA\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\2.6.1\cores\arduino\USB/PluggableUSBSerial.h:272: undefined reference to `delay'

C:\Users\AmirA\AppData\Local\Temp\arduino_build_332147/..\arduino_cache_992004\core\core_arduino_mbed_nano_nanorp2040connect_d4acc5eef4da44290f2de7b3425def2e.a(USBSerial.cpp.o): In function `arduino::USBSerial::operator bool()':

C:\Users\AmirA\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\2.6.1\cores\arduino\USB/PluggableUSBSerial.h:272: undefined reference to `delay'

C:\Users\AmirA\AppData\Local\Temp\arduino_build_332147/..\arduino_cache_992004\core\core_arduino_mbed_nano_nanorp2040connect_d4acc5eef4da44290f2de7b3425def2e.a(USBSerial.cpp.o): In function `waitForPortClose()':

C:\Users\AmirA\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\2.6.1\cores\arduino\USB/USBSerial.cpp:35: undefined reference to `millis'

C:\Users\AmirA\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\2.6.1\cores\arduino\USB/USBSerial.cpp:39: undefined reference to `delay'

C:\Users\AmirA\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\2.6.1\cores\arduino\USB/USBSerial.cpp:37: undefined reference to `millis'

C:\Users\AmirA\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\2.6.1\variants\NANO_RP2040_CONNECT/libs/libmbed.a(mbed_boot_gcc_arm.o): In function `__wrap_main':

mbed_boot_gcc_arm.c:(.text.__wrap_main+0x2): undefined reference to `main'

collect2.exe: error: ld returned 1 exit status

exit status 1

Error compiling for board Arduino Nano RP2040 Connect.



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.