Hello,
It seems ports clash between SoftwareSerial and PinChaneInt libraries that I met. Following the reference on https://code.google.com/p/arduino-pinchangeint/issues/detail?id=7, I delete some ISR information in each .cpp file and just remain PCINT2 for SoftwareSerial (for GPS) and
#if defined(PCINT2_vect)
ISR(PCINT2_vect)
{
SoftwareSerial::handle_interrupt();
}
#endif
PCINT0 for PinChangeInt (Pulse sensor)
#ifndef NO_PORTB_PINCHANGES
ISR(PCINT0_vect) {
PCintPort::pcIntPorts[0].PCint();
}
#endif
They work separately when I separately upload GPS and Pulse sensor code. But the problem is when I combine them together (insert both libraries and both codes), I met this note as below. So I think the Pin or Port clash is still there.
SoftwareSerial\SoftwareSerial.cpp.o: In function
__vector_5': C:\Program Files (x86)\Arduino\libraries\SoftwareSerial/SoftwareSerial.cpp:306: multiple definition of__vector_5'
PinChangeInt\PinChangeInt.cpp.o:C:\Program Files (x86)\Arduino\libraries\PinChangeInt/PinChangeInt.cpp:163: first defined here
COuld you give me some advice how to overcome this problem which has taken me so long time to deal.
Thanks so much in advance.
Here attaching my combination code (GPS and Pulse sensor)
#include <PinChangeInt.h>
#include <PinChangeIntConfig.h>
#include <SoftwareSerial.h>
#include <eHealthNew.h>
#include <TinyGPS.h>
int cont=0;
TinyGPS gps;
SoftwareSerial dline_gps(2, 3);
void getgps(TinyGPS &gps);
void setup(){
Serial.begin(115200);
//delay(1000);
eHealthNew.initPulsioximeter();
dline_gps.begin(4800);
//Attach the inttruptions for using the pulsioximeter.
PCintPort::attachInterrupt(6, readPulsioximeter, RISING);
}
void loop(){
//readPulsioximeter();
Serial.print("PRbpm : ");
Serial.println(eHealthNew.getBPM());
Serial.print(" %SPo2 : ");
Serial.println( eHealthNew.getOxygenSaturation());
//Serial.print("\n");
Serial.println("=============================");
delay(1000);
getTemperature();
delay(1000);
getAirFlow();
delay(1000);
Serial.println("-----Start GPS------");
Serial.println("\n");
while(dline_gps.available()) // While there is data on the RX pin...
{
Serial.println("available");
int c = dline_gps.read(); // load the data into a variable...
if(gps.encode(c)) // if there is a new valid sentence...
{
getgps(gps); // then grab the data.
}
}
Serial.println("----GPS END----");
Serial.println("\n");
}
//Include always this code when using the pulsioximeter sensor
//=========================================================================
void readPulsioximeter(){
cont ++;
if (cont == 50) { //Get only of one 50 measures to reduce the latency
eHealthNew.readPulsioximeter();
cont = 0;
}
}
void getTemperature(){
float temperature = eHealthNew.getTemperature();
Serial.print("Temperature (ºC): ");
Serial.print(temperature, 2);
Serial.println("");
}
void getAirFlow(){
for(int i=0; i<5; i++){
int air = eHealthNew.getAirFlow();
eHealthNew.airFlowWave(air);
delay(1000);
}
Serial.print("\n");
}
void getgps(TinyGPS &gps)
{
// To get all of the data into varialbes that you can use in your code,
// all you need to do is define variables and query the object for the
// data. To see the complete list of functions see keywords.txt file in
// the TinyGPS and NewSoftSerial libs.
// Define the variables that will be used
float latitude, longitude;
// Then call this function
gps.f_get_position(&latitude, &longitude);
// You can now print variables latitude and longitude
Serial.print("Lat/Long: ");
Serial.print(latitude,5);
Serial.print(", ");
Serial.println(longitude,5);
// Same goes for date and time
int year;
byte month, day, hour, minute, second, hundredths;
gps.crack_datetime(&year,&month,&day,&hour,&minute,&second,&hundredths);
// Print data and time
Serial.print("Date: "); Serial.print(month, DEC); Serial.print("/");
Serial.print(day, DEC); Serial.print("/"); Serial.print(year);
Serial.print(" Time: "); Serial.print(hour, DEC); Serial.print(":");
Serial.print(minute, DEC); Serial.print(":"); Serial.print(second, DEC);
Serial.print("."); Serial.println(hundredths, DEC);
//Since month, day, hour, minute, second, and hundr
// Here you can print the altitude and course values directly since
// there is only one value for the function
Serial.print("Altitude (meters): "); Serial.println(gps.f_altitude());
// Same goes for course
Serial.print("Course (degrees): "); Serial.println(gps.f_course());
// And same goes for speed
Serial.print("Speed(kmph): "); Serial.println(gps.f_speed_kmph());
// Serial.println();
// Here you can print statistics on the sentences.
unsigned long chars;
unsigned short sentences, failed_checksum;
gps.stats(&chars, &sentences, &failed_checksum);
//Serial.print("Failed Checksums: ");Serial.print(failed_checksum);
//Serial.println(); Serial.println();
}
