2026-10-02
Portable single-channel ECG monitor based on ESP32
With ECG viewing on the display and in a web browser
A cardiograph records the heart's electrical activity and displays it as an electrocardiogram (ECG), enabling the analysis of heart rhythm and the waveform of individual contractions. A portable single-channel device makes monitoring more convenient: it is easy to carry and does not require bulky equipment. Its compact size, battery-powered operation, and simple setup make it ideal for home monitoring and for getting started with electrocardiography.
This cardiograph is built around an ESP32 microcontroller and an AD8232 module. It records a single-lead ECG and displays it in real-time on a built-in screen, while also transmitting the data via Wi-Fi to a computer, smartphone, tablet, or TV equipped with a compatible browser. The device creates its own wireless network; no internet access, special app installations, or password entries are required, and the operating system does not matter. The browser interface also calculates heart rate (pulse) and the estimated duration of the QRS complex. Features include signal filtering, electrode disconnection alerts, a display-pause function for examining specific segments, and a battery level indicator. A single charge provides approximately 24 hours of continuous operation.
Reusable medical clips serve as the electrodes; they are easy to attach and remove, allowing for quick setup and immediate ECG recording. This design is convenient for regular, short-term measurements and eliminates the need for disposable adhesive electrodes, thereby simplifying use and reducing the cost of consumables.
Device Circuitry
The device is based on the AD8232 ECG acquisition module (P1) and an ESP32 microcontroller board (U1). The electrical signal is picked up by two measurement electrodes connected to the RA and LA inputs. A third electrode, connected to the RL terminal, helps suppress common-mode noise and stabilize the signal. The AD8232 module amplifies and filters the weak potential difference between the measurement electrodes; the resulting analog signal from its OUTPUT pin is then fed to the GPIO34 input of the ESP32's built-in analog-to-digital converter.
The microcontroller converts the signal into a sequence of digital samples and performs additional software-based filtering. The LO− and LO+ pins of the AD8232 module are connected to GPIO32 and GPIO33, respectively, allowing the program to detect if the measurement electrodes become disconnected. The processed ECG trace is displayed on a 1.54-inch OLED display (U2), which connects to the ESP32 via the I²C interface: the SDA line connects to GPIO23, and the SCL line connects to GPIO22. A button (KEY1) connected to GPIO25 controls the display mode: pressing the button pauses or resumes the ECG trace on the screen.
Simultaneously, the ESP32 creates its own Wi-Fi network and hosts a built-in web page. Upon connecting to this network, the user can open the device's page in a web browser and view the ECG on an external device's screen. The heart rate and estimated QRS complex duration are calculated in the browser based on the acquired data samples. Thus, the built-in display allows for standalone viewing, while the web interface enables the cardiogram to be viewed on a larger screen.
| Fig. 1 Schematic diagram of the portable single-channel ECG based on ESP32 |
Power is supplied by the battery module U4, which generates a 5 V output voltage (at pin 2) and charges the lithium battery (not shown in the diagram). Its output powers the ESP32 board and a separate L78L33-type voltage regulator (U3), which provides 3.3 V to the AD8232 module. A 22 µF capacitor (C1) smooths voltage fluctuations at the regulator's output. The OLED display is powered by the ESP32 board's 3V3 pin. Switch SW1 interrupts the common power line and serves to turn the device on and off.
To monitor the charge level, the battery voltage is fed via a resistive divider (R1–R2) to the GPIO35 analog input. Resistor R1 (330 kΩ) is connected to the positive battery terminal, while resistor R2 (100 kΩ) is connected to the common line. The calculated divider ratio is 4.3. The program also employs a calibration factor, which is refined based on the actual battery voltage. Readings are averaged over a 10-second period; the voltage is then converted into an estimated remaining charge and displayed as a percentage.
Device Implementation Option
The device's design allows for the selection of a custom enclo...layout and module arrangement based on available components and ease of use. It is recommended to place the ESP32 board (U1) and the AD8232 ECG sensing module (P1) as far apart as possible to minimize interference from the microcontroller and its radio module affecting the measured signal.
The modules should be securely fastened inside the enclosure to prevent shifting or accidental short circuits. Electrode wires should be kept short and routed away from the power supply module, the ESP32 antenna, and the digital display lines. A partition between compartments helps organize the assembly, but if made of plastic, it does not act as a shield against electrical interference.
It is convenient to place the display and control button on the top panel, while the power switch and electrode connector are best located on accessible side walls of the enclosure. Access to the charging and programming ports must also be provided. Metal parts and the battery should not be placed near the ESP32 antenna, as this could degrade Wi-Fi signal quality.
Fig. 2 Module placement inside the enclosure in the author's version of the device. Bottom view | Fig. 3 Device in operation. Top view |
In the original design, modules U1–U3 and P1 are located in the left section of the enclosure, while the power supply module U4 is in the right section (Figures 2–3). The compartments are separated by a partition that serves as a structural element for mounting and securing the device's components.
Developing a custom printed circuit board (PCB) for this device is not necessary; the limited number of connections allows for assembly on a solderable breadboard. When positioning the modules, maintain some distance between the ESP32 and the AD8232, and keep signal connections as short as possible. This approach simplifies assembly and makes it easy to adapt the layout to the chosen enclosure.
Components
The ESP32-DEVKITC board, based on the ESP32-WROOM-32D, is used as the microcontroller module (U1). Its appearance is shown in Figure 4. If a different board is selected, it is necessary to verify the availability and pinout of all the terminals used in the circuit.
Module P1, based on the AD8232 chip, is designed for ECG recording; it features OUTPUT, LO+, and LO− pins, as well as connections for RA, LA, and RL electrodes. The module operates on a 3.3 V power supply. Its appearance is shown in Figure 5.
An OLED display (U2) is used, featuring a 128×64 pixel resolution, an SSD1309 controller, and a 4-pin I²C interface. The original design utilizes a 1.54-inch display. Its appearance is shown in Figure 6. Displays of different sizes may be used, provided they share the same resolution, controller, and interface, and are compatible with a 3.3 V power supply.
Battery module U4 provides charging for two lithium batteries and generates a 5 V output voltage to power the device. Its appearance and wiring connections are shown in detail in Figure 7. You can find it on AliExpress using the following search terms: 15W 18650 Lithium Battery Charger Module Step Up Booster. Make sure to select the module with a 5 V output. A version of the module designed for a single battery is also available there. It is also suitable, but when choosing a replacement, you must verify the pinout, battery compatibility, and the ability to power the load from the battery when USB power is disconnected.
Note: To reduce power consumption, you can desolder the module's always-on LED (U4) that indicates the presence of installed batteries. Disconnect the USB cable and remove the batteries before desoldering.
The U3 voltage regulator (type L78L33) supplies 3.3 V power to the AD8232 module. The electrolytic capacitor C1 following it smooths out voltage spikes from the regulator. It must be rated for a voltage of at least 10 V. Any brand is acceptable.
The switch SW1 and button KEY1 are selected based on the enclosure design and ease of use. SW1 must be a latching switch, while KEY1 must be a momentary switch with normally open contacts.
Software and Firmware
The software integrates signal acquisition, display control, and data transmission to the browser. It monitors the connection of the measurement electrodes and displays the device's status, making it possible to distinguish between a lack of contact and normal ECG recording. The STOP mode halts graph updates, allowing the user to examine a selected segment at leisure. The web page is stored directly in the ESP32's flash memory and served by the device itself; consequently, neither an internet connection nor a separate app is required to view the cardiogram. Additionally, the software measures battery voltage and smooths the charge level readings to reduce indicator fluctuations.
The software leverages the ESP32's dual-core architecture: the high-priority ECG signal sampling task is assigned to core **1**, while system Wi-Fi tasks run on core **0**. This allocation minimizes the impact of network activity on sampling regularity and helps maintain a stable cardiogram recording rate while data is being transmitted to the browser.
To improve cardiogram readability, the software employs digital signal filtering. A high-pass filter reduces slow baseline drift, while a low-pass filter suppresses high-frequency noise. A notch filter attenuates power line interference. The filters are implemented as IIR biquad stages, which require minimal computational resources and enable real-time signal processing. This processing facilitates ECG viewing and the detection of QRS complexes for calculating additional parameters.
The program is loaded onto the ESP32 as a ready-to-use firmware image containing both the device's operating code and a web page for viewing the ECG. Installation is performed via USB using a flashing tool and requires no programming skills. You can view the flashing instructions here and download the firmware code below.
Program or firmware code (open)
This option involves loading the code into the editor and the firmware code into the flashing program.
Circuit Setup
A correctly assembled device with the appropriate firmware requires no further adjustment. It is recommended to verify its operation in the following order.
1. Microcontroller and Wi-Fi check. After flashing, power up the ESP32 board. The network "MADRA-ECG-MONITOR" should appear in the list of available wireless networks. Connect to it and open http://192.168.4.1 in your browser; the device's web page, including the ECG graph area, should load. The page does not need to open automatically. This check can be performed without connecting the other circuit components; note that without the AD8232 module, the displayed signal will not be a valid ECG.
2. Testing the assembled device. Power up the entire circuit: status indicators and a graph should appear on the display, and the power LED on module P1 should light up. Before connecting the electrodes, be sure to disconnect the USB cable and switch the device to battery power. Plug the electrode cable connector into module P1 and attach the electrodes to your body according to the operating instructions. If contact is good, the "LO!" electrode disconnection indicator should change to "OK." Relax your arms and remain still; once any initial transients have settled, a stable cardiogram should appear on the display and in the browser.
Operating Instructions
Before taking a measurement, position the cardiograph - and yourself - at least 1 meter away from active household electrical appliances, especially computers and monitors. This helps reduce electromagnetic interference and minimizes noise in the ECG signal.
Disconnect the USB cable and switch the device to battery power. Connect the electrodes: red to the right hand, green to the left, and yellow to any finger or other skin area that ensures reliable contact. While recording the ECG, sit comfortably, relax your arms, and remain still. You can view the cardiogram on the built-in display or in the browser of a device connected to the unit's Wi-Fi network.
During the first few seconds after attaching the electrodes, the signal may be unstable due to the process of establishing skin contact and filter settling times. Relax your arms and remain still; with good contact, the cardiogram becomes stable and clear. Stabilization typically takes no more than 10 seconds.
Electrodes may only be attached and measurements performed when the USB cable is disconnected and the device is powered by the battery. This is a mandatory safety requirement that also reduces mains-borne interference entering via the USB connection. Disconnect all electrodes before connecting the USB cable for charging or firmware updates. Detailed operating instructions are provided on the separate “Operating Instructions” page.







