Conflicting libraries include<SoftwareSerial.h> and #include "PinChangeInt.h"

Hello Forum,
I have a problem with conflicting libraries. Anyone who knows how I can overcome this.

I have two interrupts; one to wake the ATMEGA328 and the other to retrieve data from a sensor register. I want to use pin 9 for interrupt. I get below error message when I run the code.

libraries/SoftwareSerial/SoftwareSerial.cpp.o (symbol from plugin): In function `SoftwareSerial::read()':
(.text+0x0): multiple definition of `__vector_3'
sketch/AS3935.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries/SoftwareSerial/SoftwareSerial.cpp.o (symbol from plugin): In function `SoftwareSerial::read()':
(.text+0x0): multiple definition of `__vector_5'
sketch/AS3935.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries/SoftwareSerial/SoftwareSerial.cpp.o (symbol from plugin): In function `SoftwareSerial::read()':
(.text+0x0): multiple definition of `__vector_4'
sketch/AS3935.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Uno.

Here is the code I am using.

#include "PinChangeInt.h"


#include <SPI.h>
#include "AS3935n.h"
#include <avr/sleep.h>
#include<SoftwareSerial.h>


//#include "<PinChangeInt.h>"

SoftwareSerial mySerial(8, 7); //RX, TX

String inputString = "";
bool stringComplete = false;
char time1[30];

unsigned long beit; //Stores bytes from AS3935 registers
unsigned long strokeEnergy;     //Stores stroke energy from AS3935 registers

#define ARDUINOPIN 9 // Maps to ATmega328 pin15, connected to IRQ Thunder click

void printAS3935Registers();

// Function that provides SPI transfer and is passed to
// AS3935 to be used from within library.
byte SPItransfer(byte sendByte);

// Iterrupt handler for AS3935 irqs
// and flag variable that indicates interrupt has been triggered
volatile int AS3935IrqTriggered;
void AS3935Irq()// Used when 
                 // 1. Controller wakes up from sleep
                  //2. When there is lightning strike and there is lightning strike. 
{
  //FIRST THING AFTER WAKING UP. 
  sleep_disable();         // first thing after waking from sleep: // disable sleep...
  detachInterrupt(ARDUINOPIN);      // wakeUpNow code will not be executed. WAKE UP NOW will not be executed during normal running time
  
  
  AS3935IrqTriggered = true;
}

// First parameter - SPI transfer function, second - Arduino pin used for CS
// and finally third argument - Arduino pin used for IRQ
// Library internally polls this pin when doing calibration, so being an interrupt pin
// is not a requirement

AS3935 AS3935(SPItransfer,SS,ARDUINOPIN);  // Here, ARDUINOPIN is not yet associated with an IRQ, 

int count = 0; 
char str[30];

void setup()
{ 
  
 
  Serial.begin(115200);  
  // first begin, then set parameters
  SPI.begin();
  // NB! chip uses SPI MODE1
  SPI.setDataMode(SPI_MODE1);
  // NB! max SPI clock speed that chip supports is 2MHz,
  // but never use 500kHz, because that will cause interference
  // to lightning detection circuit
  SPI.setClockDivider(SPI_CLOCK_DIV16);
  // and chip is MSB first
  SPI.setBitOrder(MSBFIRST);
  // reset all internal register values to defaults
  AS3935.reset();
  // and run calibration
  // if lightning detector can not tune tank circuit to required tolerance,
  // calibration function will return false
  if(!AS3935.calibrate())
    Serial.println("Tuning out of range, check your wiring, your sensor and make sure physics laws have not changed!");


  AS3935.setIndoors();
  disableDisturbers()
  AS3935.enableDisturbers();
  //AS3935.disableDisturbers();

  AS3935.setNoiseFloor(0011);
  printAS3935Registers();
  AS3935IrqTriggered = 0;

  
  attachPinChangeInterrupt(ARDUINOPIN, AS3935Irq, RISING);
  //attachInterrupt(ARDUINOPIN, AS3935Irq, RISING);

  beit=256ul; //Forces beit to be unsigned long integer

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  //mySerial.println("Hello, world?");
  
  // reserve 200 bytes for the inputString:
  inputString.reserve(200);
}

void loop()
{
 
 //Serial.println(count);
  
  Wakeloop(); // We check whether ATMEGA328 needs to be asleep or awake

 
  if(AS3935IrqTriggered)
  {
           
    // reset the flag
    AS3935IrqTriggered = 0;
    // first step is to find out what caused interrupt
    // as soon as we read interrupt cause register, irq pin goes low
    int irqSource = AS3935.interruptSource();
    // returned value is bitmap field, bit 0 - noise level too high, bit 2 - disturber detected, and finally bit 3 - lightning!
    if (irqSource & 0b0001)
    {
      
          Serial.println("Noise level too high, try adjusting noise floor");
     
         Serial.println("Entering Sleep Mode ");
     sleepNow();
      //return;
    }

    if (irqSource & 0b1000)  //Original code to select only valid lightning events
    {
      
      // need to find how far that lightning stroke, function returns approximate distance in kilometers,
      //ke where value 1 represents storm in detector's near victinity, and 63 - very distant, out of range stroke
      // everything in between is just distance in kilometers
     int strokeDistance = AS3935.lightningDistanceKm();
      if (strokeDistance == 1)
        Serial.println("Storm overhead, watch out!");
      if (strokeDistance == 63)
        Serial.println("Out of range lightning detected.");
      if (strokeDistance < 63 && strokeDistance > 1)
      {
          Serial.print("Lightning detected ");
          Serial.print(strokeDistance,DEC);
          Serial.println(" kilometers away."); 
      }
    
          byte strokeEnergyB0 = AS3935.registerRead(0x06, 31);
          byte strokeEnergyB1 = AS3935.registerRead(0x05, 255);
        byte strokeEnergyB2 = AS3935.registerRead(0x04, 255);
          unsigned long strokeEnergy = beit*beit*strokeEnergyB0 + beit*strokeEnergyB1 + strokeEnergyB2;
          
          Serial.println(strokeEnergy);
      
  
       itoa(strokeDistance, str, 10); //Turn value into a character array
       Serial.write(strokeDistance);
       itoa(strokeEnergy, str, 10); 
      Serial.write(strokeEnergy);
       //itoa(strokeEnergy, str, 10); 
          /*
          function to send data via SD12 will be here
           Parameters to be sent
          1. Stroke Distance
          2. StrokeEnergy
          3. GPS timestamp
          4. Latitude and Longitude (from GPS)
          
          
          count=0;  


      }
    
  }
  
}

void printAS3935Registers()
{
  int noiseFloor = AS3935.getNoiseFloor();
  int spikeRejection = AS3935.getSpikeRejection();
  int watchdogThreshold = AS3935.getWatchdogThreshold();
  Serial.print("Noise floor is: ");
  Serial.println(noiseFloor,DEC);
  Serial.print("Spike rejection is: ");
  Serial.println(spikeRejection,DEC);
  Serial.print("Watchdog threshold is: ");
  Serial.println(watchdogThreshold,DEC);  
}

// this is implementation of SPI transfer that gets passed to AS3935
// you can (hopefully) wrap any SPI implementation in this
byte SPItransfer(byte sendByte)
{
  return SPI.transfer(sendByte);
}




void sleepNow()         
{

  sleep_enable();
  attachInterrupt(ARDUINOPIN, AS3935Irq, RISING);
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);   
  sleep_mode();           

  attachPinChangeInterrupt(ARDUINOPIN, AS3935Irq, RISING);
}

void Wakeloop()
{
 
   count++;  
   
   if (count >= 100000){ 
      Serial.println("Timer: Entering Sleep mode");
      delay(100);    
      
      sleepNow();    
      count = 0;      
 
      
  }
}

I also attached the libraries.

AS3935.ino (14 KB)

PinChangeInt.h (21.9 KB)

AS3935n.cpp (4.88 KB)

AS3935n.h (2.47 KB)