Measure Biopotential / ECG using Python on the Android Smartphone
Learn:
Analog Input
Biopotential
Warning: This application note is for learning and development only. It is not for Medical Diagnostic Use. Should be used solely by or under the supervision of qualified engineers and technicians who are familiar with the risks associated with handling electrical circuits.
An electrocardiogram (ECG or EKG, abbreviated from the German Elektrokardiogramm) records the electrical voltage in the heart in the form of a graph. It is the prime tool in cardiac electrophysiology, and its function is in the screening and diagnosis of cardiovascular diseases.
Requirements
Python Py4A
Bluetooth DAQ Starter Kit
Hand-held Biopotential Electrodes Assembly
Note:
Pair the EMANT380 to Android Smartphone.
You will be asked to select the bluetooth MAC address for your EMANT380 module.
You will have to change the MAINS_FREQ to 60 if your country mains frequency is 60Hz.
To understand this program, you will require a knowledge of html and javascript. For more information, please read the
guide to HTML scripts and using WebView APIs from code.google.com. There are 5 files in the Py4A folder
ecg_gui.py
peakdetect.py
graph.html
jquery.flot.min.js
jquery.min.js
The peak detection module is modified for Py4A and used for the heart rate calculation. You can find the description here of the peak detection code.
For the graph, we are using Flot, which is a pure Javascript plotting library for jQuery.
For Android smartphone, all five files in the py4A folder should be stored in the SD Drive->sl4a->scripts folder.
For Android emulator, only the the html and the 2 javascript files in the py4A folder should be stored in the SD Drive->sl4a->scripts folder.
When you press any button, the Toast notification is used to indicate that the button event has been successfully processed. If you don't see the notification, try again. This is a limitation of the Py4A WebView API.
Fig 1: Connecting the EMANT380 Bluetooth DAQ to the Hand-held Biopotential Electrodes Assembly
Fig 2: Connecting the Bluetooth Starter Kit to the Hand-held Biopotential Electrodes Assembly