The goal of this project is to make a low-cost rhythmic Holter. It’s a medical device often used to detect cardiac abnormalities that the patient have to keep on him between 1 day and 3 weeks.There are a lot of problem to solve other that the price. The communication between patient and doctor and the comfort of the patient are insufficient in the actual Holter.We also want to reinforce the security of the patient during the diagnostic, particularly because the risk of infarct or serious heart problem can be important. To deal with that, we would like to implement a software which can directly detect heart rhythm problem. A message will be send to emergencies if there is a problem.This project is the following of one other, begin in the frame of the faculty. Please look at it if you want to understand where we stopped it. All the code used for this project are available on my github.
We want to reduce the size of the electronical part of the previous device. To do that, we use a Wemos D1R1. It’s an arduino-like with a wifi module ESP8266 incorporated. With that, we can remove the huzzah feather and the bread board.
Heart Monitor AD8232
The AD8232 is an integrated signal conditioning block for ECG and other biopotential measurement applications. It is designed to extract, amplify, and filter small biopotential signals in the presence of noisy conditions, such as those created by motion or remote electrode placement. This design allows for an ultralow power analog-to-digital converter (ADC) or an embedded microcontroller to acquire the output signal easily.
Arduino Leonardo pin (Arduino that I used previously) is different from Wemos D1R1. The LO- pin of the AD8232 have to be linked at D8 pin of Wemos. LO+ have to be linked at D2pin.
So we have these connections between AD8232 and Wemos D1R1:
Moreover, the previous code has to be changed. The nomination of Wemos pin is different in Arduino code. pin 2 is named in 4. Pin 8 is named in 15. So we obtained the code in the folder "Code Wemos USB" on github.
Here, we have a signal in serial and we can have a first graph with the tracer of arduino software.
We obtained the following graph depending where we put the electrodes.
Electrodes close to the heart in USB with serial tracer
LA and RA electrodes on the clavicle, ground on the hip
It seems that there is less interferences where electrodes are on a bone localisation. Compare to a normal electrocardiogram, the scale on x axis need to be change. However, we can easily see the different wave and detect an heart problem.
Have data in wifi with AD8232 and wemos
We search to have a wifi signal. So we use the following code on github called "Code Wemos wifi" to connect it to the computer via router. Don't forget to put the IP of your computer (line 20) and the name and password of your router ( line 43 ). You can use an external battery in USB to supply wemos.
Visualize data with python in wifi
Now we need a code to collect and make a graph with the data from the Wemos. For that, we use a python code called "ECG-live.py" in the folder "Code_python_wemos", which make an electrocardiogram in real time. Moreover, the code recorded the data in a csv file to see it later. You can use the code called "ECG-graph.py" to see the graph.
The fact that we used a battery in USB to powered the arduino prevent the interferences that we see if the arduino is charged directly by the computer. However, the battery doesn’t detect the arduino, so it turns off rapidly. You can try different battery in USB or use a lithium battery.
Moreover, there is a lag in transfer of data. The computer cannot plot the different point rapidly, so stock the data in the fast-memory. It’s because the code is not optimized, and a list is not a good way to deal with it. If we remove the line plt.pause, we can see all the data on the screen at the real-time, however there is no plot. It can be more interesting to use vispy to have a graph moving depending the time.