problem when use the GPS and Pulse Sensor in same time

Hi guys. I’m making a program that is showing heart rate and time on same LCD. but it doesn’t work… Before I made it, I made clock program and to measure the heart rate program. I mean, I made each single functions. These are worked well. This program(clock_HR) works as just heart rate measure. If I remove “interruptSerup()”, it works as clock.
I made this program in reference to http://pulsesensor.myshopify.com/ (PulseSensorAmped_Arduino_1dot2).
clock_HR.ino and Interrupt.ino must in same folder. I also refer to Gps_clock_tinygps.ino. it is the single clock program with GPS by me.

I know, the messages are so crazy, because my 1st language isn’t English. sorry.
I need your help. Thanks a lot.

clock_HR.ino (2.47 KB)

Interrupt.ino (5.61 KB)

Gps_clock_tinygps.ino (1.52 KB)

I'm making a program that is showing heart rate and time on same LCD. but it doesn't work..

Please give more details of what it should and what it actually does.

ISR(TIMER2_COMPA_vect){                         // triggered when Timer2 counts to 124
  cli();                                      // disable interrupts while we do this

Interrupts are already disabled when an ISR is called.

An interrupt every 2 milliseconds is going to play hell with the interrupts that SoftwareSerial uses to read the GPS data.

The only solution is see is to use an Arduino with multiple hardware serial ports.

I wanna show time and heart rate on same LCD. If I run "Clock_HR", clock function doesn't work... The LCD shows only heart rate. If I run that besides "interruptSetup()", it shows only time. I just want to show heart rate and time on LCD. I also tried to fix, I couldn't fix it but I wanna share more info with you. If the program has "interruptSetup()", software serial doesn't work well. because I tried to check the time on serial monitor, serial monitor didn't show anything.

thank you for your cooperation. I still need your help and I wanna solve it. feel free to ask me anything if you have any questions.

If the program has "interruptSetup()", software serial doesn't work well.

Of course it doesn't.

I still need your help and I wanna solve it. feel free to ask me anything if you have any questions.

When are you getting the Mega?

To PaulS I appreciate you. I could understand why it doesn't work a bit. I'm not very good at in English. so I need more time to understand it clearly. I'm not sure, how can I solve it finally? Impossible?? "When are you getting the Mega?" I'm using UNO R3. sorry I can't understand what do you mean...

I'm not sure, how can I solve it finally? Impossible??

You can do something that takes nearly all the time, getting heartbeat data, or you can do something else that takes nearly all the time, getting GPS data. If you are spending more than 100% of your time processing interrupts, you will have problems. As you are having now.

You need to stop using SoftwareSerial to read serial data from the GPS. The only way to do that is to use a HardwareSerial instance. Your UNO has one. A Mega has 4.

If you need to communicate with the PC, via the hardware serial port, you can not use the hardware serial port to communicate with the GPS. If you need to communicate with the PC and the GPS, you MUST use a device that has 2 or more hardware serial ports.

If you can't use a Mega, you can't complete your project. Although what the relationship is between heart rate and location is is a mystery. So, why you are working on this particular project is too.

Thanks so much. I got it mostly now. I'll work it for later because it's already day off in here. and then I may ask something again in here.

ok, I tell you about my project. I develop a alarm clock. The clock is cared about sleep cycle. Do you know sleep cycle?? that is about REM sleep and NREM sleep. I'd like to wake up more comfortably. don't you?? when it's in REM, we can wake up easily and comfortable. the sleep cycle is possible to discriminated by heartbeat. so I used pulse sensor for discriminate the heart rate. and I used GPS for getting exactly time. actually i don't need location data. but the time data in NMEA is very precise so I used GPS. If you don't know very much about sleep cycle, you can google it;)

I used GPS for getting exactly time

Does the GPS work reliably indoors ?

Yes GPS worked well indoors. I'm using LS20031.

It doesn’t seem likely that you need to read the time from the GPS continuously - once at startup ought to do and you can keep track with the DateTime library or roll your own with millis. You might choose to sync up again daily or whatever frequency suits you. Then you can spend your time on the pulsin and perhaps avoid the need to purchase a Mega.

Using a GPS to get time is like using a sledge hammer to kill mosquitoes.

Get a real time clock.

I already tried to use time library. however, the error was not so small for daily use. So I found that way to sync by GPS on some websites. anyway, I know what you guys wanna say. I agree. But it must fit some way of sync up the time.