ECG module ad8232

Hello everyone. Im stuck in my project. When im trying to gcc -0 compile heart.c and ad8232.h no errors but file compiles badly and cause this when i`m trying to make fbt fap.

#include <ad8232.h>
#include <time.h>

int main()
// Initialize the AD8232 and configure the gain and filtering settings
ad8232::init();
ad8232::setGain(64);
ad8232::setFilter(0.75);

while (true) {
// Read the electrical activity of the heart from the AD8232
int heart_activity = ad8232::read();

// Calculate the heart rate from the heart activity data
int heart_rate = calculateHeartRate(heart_activity);

// Display the heart rate on the Flipper Zero's screen
displayHeartRate(heart_rate);

// Wait for a moment before reading the heart rate again
sleep(1);

}

return 0;
}

Original code. My file ad8232 is empty.

Project on github - GitHub - sparkfun/AD8232_Heart_Rate_Monitor: AD8232 Heart Rate Monitor

Can someone help me with transfering software from adruino to flipper


3 Likes

I can’t help with this problem but thank you for sharing and if you figure it out I would love to hear more.

1 Like

This would be pretty epic

Flipperscope app can be used to measure output signal from adb232

GND to pin 18
3.3v to pin 9
output to pin 16

time period : 1ms
measurement : capture

window is only 256 sample by default, so you may want to ADC_CONVERTED_DATA_BUFFER_SIZE to 4096 in scope_app_i.h , and recompile & upload
you will observe the measured data contain sine noise, which can be removed by postprocessing,

postprocessing code, and some result
you can get the .dat file from the flipper app > options > experimental options > file manager
/ext/apps_data/flipperscope

import matplotlib.pyplot as plt
import pandas as pd 
import numpy as np
import struct

with open("./Q03.dat", "rb") as f:
    data = f.read()

y = [(float(x[0]) / 2500) * 2.5 for x in struct.iter_unpack("<H", data)]
x = np.arange(len(y))

n = len(y)
df_fft =  pd.Series(np.fft.fft(y, n=n), index= np.fft.fftfreq(n))
df_fft[(abs(df_fft.index)>0.045) & (0.065>abs(df_fft.index))]=0
df_result = np.fft.ifft(df_fft.values)
pd.Series(df_result).plot()

ekg

1 Like