0
\$\begingroup\$

I am working on a prototype that requires use of an Arduino Uno, digital humidity sensor, heart rate monitor, temperature probe, and GPS unit. My issue, I believe is with trying to implement to the two serial devices (GPS and Temperature) with the software serial library. I've read in other posts that such issues may arise if the code tries to talk with both devices at once. I don't think I'm doing that, but might be mistaken.

I am achieving viable sensor output, but the Temperature output and GPS readings are inconsistent. Specifically, The GPS readings display often enough but not regularly and although the temperature data is mostly good, sporadically the code will print -1000. I can filter this nonsense data, but I'd rather solve the problem. Any ideas?

Main Code Loop:

 void loop(void) {

  //Read the serial port to see if GPS data is available
   while(uart_gps.available()){
     byte c = uart_gps.read();

   //If incoming data is GPS data, process it
     if(gps.encode(c)){
       Serial.println(F("Reading"));
       getgps(gps);
     }
   }

  int heartRate = getHeartRate();
  float temperature = getTemp();
  float hum_temp = getTemperature();
  float humidity = getHumidity(); 

  // ... print statements
\$\endgroup\$
2
\$\begingroup\$

You probably have clashing interrupts.

While there isn't really any reason this couldn't work, you are going to need to dump the arduino environment, and probably spend some time refining and modifying the ISR (interrupt service routines) in the various libraries.

Basically, the arduino stuff lets the libraries do a lot of set-up work that's effectively hidden from you. Unfortunately, some of the libraries are stomping on each other.
The only solution to this is to actually understand what the libraries are actually doing, and modify one or both of them to prevent them from having conflicts over the AVR's resources.

\$\endgroup\$
0
\$\begingroup\$

Are you using the pulse sensor from http://pulsesensor.com/ or something similar? If yes, then the issue is probably due to the interrupts of the pulse sensor happening every millisecond. I had a similar situation to yours, with garbled input/output from the GPS. Unfortunately I couldn't find a good solution. Consider using a separate Arduino just for the pulse sensor.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.