Sending ECG data using buffer in real time to the server without using delay

I am trying to make a ECG monitoring system using Arduino, GSM and ECG sensor which data should be sent to the private server in real time. Those data are then collected via Matlab on the remote computer and analysis should be executed in real time. When using delays in Arduino sketch GSM successfully sends data to the server but those data are sent in big delays (around 30 seconds) and the sketch doesn’t send the data of the whole buffer for some reason (it should be 300 samples, but I had to try to lower that number in order to see any results). After removing delays in the loop where data should be continuously sent, GSM is not executing send data command - AT+CIPSEND. Can anybody help me fix the timer issue and explain why is not the whole buffer sent? In the code, I just used the DHT sensor for the trial since I didn’t have an ECG sensor yet. Thanks in advance.

ekg2.ino (5.46 KB)

Nice idea, but the moment GSM starts sending, the ECG signal is pure noise.

Why is that?

Hunman body is not shielded. Well, you could wrap yout test persion in aluminum foil, this could help.