Enthernet Code
Enthernet Code
DIIDevHeads IoT Integration Server
Created by Razali Abdelrahmen on 8/19/2024 in #firmware-and-baremetal
Which MicroPython libraries should I use for ECG with ESP32?
Thonny is not suitable for matplotlib based plotting, Spyder is a good alternative where you can easily plot your ECG data using matplotlib. You can manually transfer your ECG data to Spyder or load it from a file and then use matplotlib to create the plots. If you're plotting your ecg data directly from a list
import matplotlib.pyplot as plt

ecg_data = [100, 120, 130, 110, 115, 140, 150, 130, 125, 135, 120, 110]

plt.figure(figsize=(10, 5))
plt.plot(ecg_data, marker='o', linestyle='-', color='b', label='ECG Signal')
plt.title('ECG Data Visualization')
plt.xlabel('Time (s)')
plt.ylabel('Amplitude (mV)')
plt.grid(True)
plt.legend()
plt.show()
import matplotlib.pyplot as plt

ecg_data = [100, 120, 130, 110, 115, 140, 150, 130, 125, 135, 120, 110]

plt.figure(figsize=(10, 5))
plt.plot(ecg_data, marker='o', linestyle='-', color='b', label='ECG Signal')
plt.title('ECG Data Visualization')
plt.xlabel('Time (s)')
plt.ylabel('Amplitude (mV)')
plt.grid(True)
plt.legend()
plt.show()
If you're using a csv file
import matplotlib.pyplot as plt
import csv

ecg_data = []
with open('ecg_data.csv', 'r') as file:
reader = csv.reader(file)
for row in reader:
ecg_data.append(float(row[0]))

plt.figure(figsize=(10, 5))
plt.plot(ecg_data, marker='o', linestyle='-', color='g', label='ECG Signal')
plt.title('ECG Data Visualization')
plt.xlabel('Time (s)')
plt.ylabel('Amplitude (mV)')
plt.grid(True)
plt.legend()
plt.show()
import matplotlib.pyplot as plt
import csv

ecg_data = []
with open('ecg_data.csv', 'r') as file:
reader = csv.reader(file)
for row in reader:
ecg_data.append(float(row[0]))

plt.figure(figsize=(10, 5))
plt.plot(ecg_data, marker='o', linestyle='-', color='g', label='ECG Signal')
plt.title('ECG Data Visualization')
plt.xlabel('Time (s)')
plt.ylabel('Amplitude (mV)')
plt.grid(True)
plt.legend()
plt.show()
Hope this helps
19 replies