I’ve been trying to plot AD8232 and ESP32 ECG data using Blynk, but what is displayed is smooth, clear hospital monitor electrocardiograms. The wave is nosey, unstable, or does have any clear peaks and patterns of an authentic ECG. What I am looking for is clear, live plots of accurate representation of cardiac activity, such as on medical monitors. No amount of pushing, either the signal is unstable or does plot on Blynk. In dire need of help in optimizing data treatment, eliminating nosey signals, and optimizing plots to have clear and accurate ECG waveforms. Can you give please give me a code that can show an authentic ECG data.
#define BLYNK_TEMPLATE_ID "YOUR_TEMPLATE_ID"
#define BLYNK_TEMPLATE_NAME "YOUR_TEMPLATE_NAME"
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
char auth[] = "YOUR_BLYNK_AUTH_TOKEN";
char ssid[] = "YOUR_WIFI_SSID";
char pass[] = "YOUR_WIFI_PASSWORD";
#define ECG_PIN 32 // AD8232 OUTPUT connected to GPIO 32
#define THRESHOLD 500 // Adjust based on ECG signal strength
BlynkTimer timer;
void sendECG() {
static int lastValue = 0;
static bool peakDetected = false;
int ecgValue = analogRead(ECG_PIN);
Serial.println(ecgValue); // Print ECG data to serial monitor
// Detect peaks
if (ecgValue > THRESHOLD && !peakDetected) {
peakDetected = true;
Blynk.virtualWrite(V1, ecgValue); // Send ECG peak to Blynk
}
else if (ecgValue < THRESHOLD - 50) {
peakDetected = false; // Reset peak detection
}
}
void setup() {
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
timer.setInterval(10L, sendECG); // Send ECG data every 10ms
}
void loop() {
Blynk.run();
timer.run();
}
}