I’ve been working with Arduino a lot lately, and ran into an extremely bizarre error:
Usually, when you’re adding a new library, you need to follow specific instructions about how to install that library in the Arduino IDE. So, if you’re getting this error with a non-standard Arduino library (like the Neopixel library, or something you’ve downloaded from the Internet), this error makes perfect sense. But SoftwareSerial is included with the Arduino IDE: It’s a built-in library. So how on earth could it not be found? I was especially confused since I had uploaded this code not two days ago!
Here’s what I tried:
- Checking that SoftwareSerial was indeed installed in my Arduino IDE application (These instructions are for a Mac, since that’s what I own):
- Select the Arduino application
- Chose ‘Show package Contents’ – a new window will appear.
- Now navigate to:
- All the standard libraries will be there.
- Moving the entire SoftwareSerial directory from that standard location above, to the location where all installed libraries are installed on my Mac (other included libraries were installing fine):
- Restarting Arduino IDE multiple times.
- Downloading a completely new version of the IDE.
- Restarting my computer.
Nothing worked: and the fact that downloading a completely new version of the IDE didn’t solve the issue meant that it was some issue with the way my Arduino/libraries folder was set up. Finally, I remembered that for another project I had edited SoftwareSerial so that it didn’t use any pins on PortD, and included that in my libraries as SoftwareSerialNoPortD. I thought that might be messing things up. A forum post taught me that if you open up the Arduino IDE and go to Sketch->IncludeLibrary… the IDE will automatically generate the import statement:
When I tried to automatically import SoftwareSerial, this is what showed up in my sketch:
Somehow, the IDE had linked SoftwareSerial with SoftwareSerialNoPortD, and couldn’t find SoftwareSerial anymore. I checked through all the files to make sure everything was named properly, and eventually found this file called library.properties:
I edited it so that it had the correct name for SoftwareSerialPortD:
Quit and restarted the Arduino IDE, and now I’m able to compile fine!