conflicting libraries error for "SoftwareSerial.h" and "PinChangeInt.h"

Image embedded for our convenience:

Technique described here.

RX_PIN and TX_PIN are connected to a GPS sensor.

Great, I can use that to name the NeoSWSerial variable:

#include <EnableInterrupt.h>

#define WAKE_PIN 6
#define AS3935_PIN 9


#include <NeoSWSerial.h>
#define RX_PIN 7
#define TX_PIN 8
NeoSWSerial gpsPort( RX_PIN, TX_PIN ); //   <--  Now THAT'S a name!  :)

// Since it's hooked to a GPS, try NeoGPS for parsing...
#include <NMEAGPS.h>
NMEAGPS gps;
gps_fix fix;

void gpsPortISR()
{
  NeoSWSerial::rxISR( *portInputRegister( digitalPinToPort( RX_PIN ) ) );
     //  This is uglier than passing PIND, but it works for any RX_PIN you choose.
}

void setup()
{
  Serial.begin( 9600 );
  gpsPort.begin( 9600 );
  enableInterrupt( RX_PIN, gpsPortISR, CHANGE );
}

void loop()
{
  if (gps.available( gpsPort )) {
    fix = gps.read();

    // A new fix just came in, this is a good time to do other work
    if (fix.valid.location) {
      Serial.println();
      Serial.print( fix.latitude(), 6 );
      Serial.print( ',' );
      Serial.print( fix.longitude(), 6 );
      Serial.print( ' ' );
    } else {
      Serial.print( '.' );
    }
  }
}

Notice the <> include filenames. You also have to edit this line in NeoSWSerial.h:

      #define NEOSWSERIAL_EXTERNAL_PCINT // uncomment to use your own PCINT ISRs

That will fix the link errors you were getting.

This also uses NeoGPS for parsing the characters coming from gpsPort. If you want to try that sketch, NeoGPS is available from the Arduino IDE Library Manager, under the menu Sketch -> Include Library -> Manage Libraries.

Cheers,
/dev

1 Like