Labs / Electronic modules

GraftSense: An Integrated ECG Signal Acquisition Module Based on AD8232 (Open Version)

Author: Li Zisheng · Source: FreakStudio open documentation, v1.2 · License: CC BY 4.0 · Driver code (sensors/ad8232_driver): MIT License

Contents
AD8232
AD8232 R19 U1 U2 J1 J2 v1.0

I. Module Introduction

The integrated ECG signal acquisition module based on AD8232 is an integrated ECG acquisition module based on AD8232 and RP2040 main controller, which achieves high-precision ECG signal capture at a fixed 100Hz sampling rate. Its core highlight lies in the professional filtering scheme built into the RP2040: through DC removal preprocessing with a sliding window, paired with three-stage cascaded IIR digital filtering and amplitude calibration, it can effectively suppress various types of interference and output ECG signals that are both stable and accurate.

The core functions are as follows:

Compared with the traditional AD8232 module, this module has the following advantages:

This module is applicable to scenarios such as biomedical electronics teaching and electrocardiogram principle demonstration, and has the dual values of stable acquisition and convenient debugging.

II. Introduction to Main Chips

AD8232 is a dedicated single-lead ECG signal conditioning chip launched by ADI. It operates on a single 2.0~3.5V power supply with low power consumption, integrates an instrumentation amplifier, filter circuit and lead-off detection, supports 2/3 electrode configurations, can accurately extract and amplify weak ECG signals, and is designed specifically for low-power medical devices such as portable and wearable ECG monitors.

2.1 Chip Overview

AD8232 A1 A2 A3 A4 A5 A6 A7 A8

AD8232 is a dedicated single-lead ECG signal conditioning chip launched by ADI. It operates on a single 2.0~3.5V power supply, with a typical quiescent current of only 170μA. The chip integrates an instrumentation amplifier with a gain of 100, a dual-pole high-pass filter, a lead-off detection circuit, and a right-leg drive amplifier, supporting 2 or 3-electrode configurations. It can accurately extract, amplify and filter weak ECG signals in noisy environments such as during exercise, and can also construct a three-pole low-pass filter via an unused operational amplifier. Featuring a high common-mode rejection ratio and fast recovery function, it is suitable for low-power wearable scenarios including portable ECG monitors, fitness heart rate devices, and remote health monitoring, and adopts a 20-pin LFCSP package.

2.2 Pin Definition

AD8232 OUT0 1
AD8232 20

2.3 Functional Block Diagram

AD8232

AD8232 features an RFI -filtered instrumentation amplifier (IA) as its core, adapts to AC and DC input signals via an AC / DC switch, and uses a charge pump to power the high-voltage drive module for electrode driving. The chip integrates a lead-off detection circuit that monitors the electrode connection status in real time through a synchronous rectifier and a comparator, and switches operating modes via a switch timing control module;The input signal is amplified by the instrumentation amplifier, then processed and output by the configurable gain network and the output operational amplifier. Meanwhile, it also integrates auxiliary functions such as reference voltage buffering, fast recovery and shutdown, which can realize high-interference-resistance acquisition, amplification and condition monitoring of physiological signals.

AD8232 GM1 GM2 A1 100 C1
AD8232 C1
AD8232 R10M 10M R10M1
AD8232 100k 10k 100kHz 50
AD8232 15pF 10k

AD8232 adopts a dedicated instrumentation amplifier as its core, and amplifies weak ECG signals via an indirect current feedback architecture consisting of a transconductance amplifier and a DC-blocking amplifier, while suppressing electrode half-cell potential and common-mode noise; it also utilizes a charge pump to expand the common-mode voltage range to prevent saturation. The right-leg drive amplifier injects a reverse current to cancel common-mode interference, further improving noise immunity; the reference voltage buffer creates a virtual ground to provide a stable reference for signals.When signal saturation or lead-off is detected, the fast recovery circuit switches the resistor path to shorten the signal settling time, while the lead-off detection function monitors the electrode connection status via AC or DC mode; in addition, the unused operational amplifier can also be used to construct an additional low-pass filter, which collectively realizes accurate conditioning and reliable acquisition of ECG signals.

2.4 Performance Parameters

0.35V 2.85V 0V 80dB 2.0V 3.5V 76dB 5 100 1kHz
AD8232
AD8232 A2 A3
AD8232 0 70 170 230 210 500nA 40nA 2.0 3.5V
AD8232

AD8232 's performance parameters cover core modules and system characteristics: with a typical 3V power supply, the instrumentation amplifier has a typical common-mode rejection ratio of 86dB, a typical input offset voltage of 5μV, a fixed gain of 100, a typical bandwidth of 1kHz, and an input noise of 14μVp-p over the 0.5Hz to 40Hz bandwidth; both the operational amplifier and the right-leg drive amplifier feature low offset and high gain-bandwidth characteristics;The typical quiescent current of the system is only 170μA, it supports a wide power supply voltage range of 2.0~3.5V, and the operating temperature ranges from -40℃ to + 85℃; in terms of absolute ratings, the upper limit of the power supply voltage is 3.6V, and it has an 8kV human body model ESD protection capability, whose overall parameters adapt to the requirements of low-power, high-precision ECG signal conditioning.

AD8232 100 120dB 0.5
AD8232 0.5V 3V 300mV
AD8232 9 10 12 0.5Hz 40Hz 120 13
AD8232 0.1 10 22 470 1
AD8232 15 18 16 19
AD8232

The instrumentation amplifier performance curves of AD8232 demonstrate its excellent suitability for ECG signal conditioning:

AD8232
AD8232 0.1Hz 10Hz 22pF 470pF 1nF 5
AD8232 27 0.5Hz 40Hz 30 28 31
AD8232 40 25
AD8232 40 1pA 80 1000pA

AD8232 The performance curve of its built-in operational amplifier reflects its excellent characteristics suitable for ECG signal processing:

AD8232 0.1 10 0.5 40
AD8232 0.1Hz 100kHz 10 10k

AD8232 Right Leg Drive (RLD) amplifier performance curve, which reflects its key role in suppressing common-mode interference and ensuring the quality of ECG signals:

AD8232 100

AD8232 reference voltage buffer performance curve reflects its key capability to provide a stable virtual ground for ECG signal conditioning:

AD8232 43 2V 3V 3.5V 100 230 44

AD8232 's system performance curves mainly reflect its core feature of low power consumption:

2.5 Reference Circuit

AD8232 2.5 10M 180k 0.22 0.1 1nF 7Hz 24Hz
0.1Hz 10Hz 100Hz 55dB 1kHz AD8232
AD8232 7Hz 24Hz 11 1100

This AD8232 reference circuit is specifically designed for bi-hand heart rate measurement in sports scenarios: it takes AD8232 as the core, and builds a 7Hz two-pole high-pass filter and a 24Hz two-pole low-pass filter via external resistors and capacitors to form a narrow-band filtering characteristic, thereby suppressing motion artifacts and common-mode interference; meanwhile, it integrates an RLD (right leg drive) circuit to further cancel common-mode noise, and the low-pass filter can also provide additional gain to amplify the weak ECG signal measured from both hands.Its narrowband frequency response is only suitable for heart rate determination and cannot support complete ECG waveform analysis, and its overall design adapts to the needs of heart rate monitoring in sports scenarios.

2.6 Chip Configuration

None.

None.

2.8 PCB Routing Precautions

AD8232 15pF 10k

III. Instructions for Circuit Engineering and Module Usage

3.1 Circuit Source Engineering

To obtain the source project of the circuit, please follow the official account [Freak Embedded].

3.2 Module Usage Instructions

The schematic diagram of this module is shown below:

SCH_AD8232-Based Integrated ECG Signal Acquisition Module-v1.0.pdf 2.9 MB

AD8232 v1.0

This module provides a serial port UART interface MRX and MTX: here M stands for the host, meaning it is the MCU 's RX corresponding to the module' s TX, so as to realize bidirectional data transmission between the module and the host computer.

The module is equipped with 5V IN 's PH2.0-2P terminals, which provide 5V input for the entire module; it also supports power supply via the RP2040-Zero ' s Type-C interface. To avoid power frequency noise introduced by the USB interface and improve the quality of ECG signals, it is recommended to prioritize power supply using a battery plus a boost unit.

Lead interface LEAD, serving as the input channel for ECG signals, is used to connect lead wires. If you have high requirements for waveform accuracy, it is recommended to replace it with shielded lead wires to further reduce electromagnetic interference.

GraftSense: An Integrated ECG Signal Acquisition Module Based on AD8232 (Open Version)

In practical use, simply connect a 5V power supply (or power via a battery + boost unit) to the module, and connect the lead wires to the LEAD interface, then the module can work with the UART communication interface to complete ECG signal acquisition and data transmission.

3.2.1 Introduction to ECG Electrocardiogram Signals

You can think of an ECG as the "electrical activity diary" of the heart, which records the electrical signals generated with each heartbeat in the form of waveforms. Just like the red grid waveform on the left in the figure, each up-and-down fluctuation corresponds to a "discharge-contraction" process of the heart. Through this "diary", doctors can tell whether your heartbeat is regular and your heart rate is normal, help you screen for heart problems such as arrhythmia and myocardial infarction, and even evaluate the working status of the pacemaker.

10mm 1mV

The waveform in the diagram is divided into several key segments, each corresponding to a specific "action" of the heart:

By observing the shape, interval and height of these waveforms, doctors can detect "abnormal signals" of the heart. For example, an excessively long interval from the P wave to the QRS complex may indicate that the electrical signal transmission from the atria to the ventricles is slowed down; an overly wide QRS complex may suggest a problem with ventricular contraction; an abnormal T wave morphology may reflect myocardial ischemia or a previous myocardial infarction. Just as one can understand the "health status" of the heart from the details of its "diary", these pieces of information serve as an important basis for the diagnosis and treatment of heart diseases.

3.2.2 Preparations before using the module

Before using the module, we first need to flash the corresponding firmware:

AD8232 3s

First press the BOOT button, a window will pop up on the computer, then drag the firmware below into it:

GraftSense-AD8232.uf2 913 KB

RPI-RP2 0

Then open the Thonny software, and download all the files in the Compressed Packet below to the main control board on the module:

GraftSense: An Integrated ECG Signal Acquisition Module Based on AD8232 (Open Version)

Then press the RESET button, and the main control board on the module will start working. It is particularly noted that the first 3 seconds after power-on are reserved for filter initialization, during which no data will be output.

3.2.3 Lead Mode of ECG Module

The "lead configuration" for ECG acquisition refers to the method of capturing the potential difference formed by cardiac electrical activity on the body surface by attaching electrodes to specific positions on the human body. The module we developed adopts dual leads (differential acquisition) + reference electrode configuration, with the red, yellow and green electrodes having clear respective responsibilities to jointly achieve accurate ECG signal acquisition and interference suppression.

Here, we first need to insert the lead wires into the LEAD interface of the module, and then connect the lead patches to the electrode snaps:

GraftSense: An Integrated ECG Signal Acquisition Module Based on AD8232 (Open Version)
Electrode colorFunctionRecommended placement
Red (positive)ECG signal positive input; captures positive potential changes of the heart's electrical activityUpper right chest (below the clavicle) or inner right arm (e.g., above the right elbow)
Yellow (negative)ECG signal negative input; forms a potential difference with the red electrode to extract the core ECG waveforms (e.g., P wave, QRS complex)Upper left chest (below the clavicle, near the heart) or inner left arm (e.g., above the left elbow)
Green (reference electrode)Ground electrode; eliminates common-mode interference on the body surface (e.g., power-line noise) and improves the signal-to-noise ratioLower right abdomen (below the right ribs) or inner right leg (e.g., above the right knee)
GraftSense: An Integrated ECG Signal Acquisition Module Based on AD8232 (Open Version)

There are two common lead placement methods:

Also note that before applying the electrode pads:

3.2.4 Description of Module Communication Protocol

Here, we adopt a fixed structure for the serial port to ensure communication reliability, and all frames conform to the following format:

FieldBytesValue / DescriptionNotes
Frame header20xAA 0x55Fixed identifier used to distinguish valid data frames
Type10x01: command frame (host → module)
0x02: data frame (module → host)
Distinguishes frame direction and purpose
Length1Number of bytes in the following "Data" field (0~255)Makes data parsing easier for the host
DataNCommand content / data content (as defined by the protocol)Variable length
Checksum1XOR of Type + Length + Data (low 8 bits)Used to verify frame integrity
Frame tail20x0D 0x0A (carriage return + line feed)Simplifies host parsing and debugging

The format definition of its query/setting mode is as follows:

Command code (hex)Function typeFunction descriptionData lengthData format / value rangeNotes
0x01Query / ReportRaw ECG data2 bytes16-bit unsigned integer (0~65535, corresponding to −1V ~ 2V)Both active reporting and passive query are supported
0x02Query / ReportFiltered ECG data2 bytes16-bit unsigned integer (0~65535, corresponding to −1V ~ 2V)Both active reporting and passive query are supported
0x03Query / ReportLead connection status1 byte0 = normal, 1 = lead offBoth active reporting and passive query are supported
0x04Set (with response)Set active reporting frequency1 byte50 / 100 / 125 (unit: Hz)Passive setting only; returns a confirmation after setting
0x05Set (with response)Set active reporting mode1 byte0 = off, 1 = onPassive setting only; returns a confirmation after setting
0x06Set (with response)Control AD8232 start/stop (working state)1 byte0 = stop, 1 = runPassive setting only; returns a confirmation after setting
0x07Query / ReportModule working status1 byte0 = stop, 1 = runBoth active reporting and passive query are supported
0x08Query / ReportHeart rate value1 byte0~255 (unit: beats/min)Both active reporting and passive query are supported

In the active output mode, the module pushes a 5-byte combined data frame at the set frequency, and the format of the data segment is as follows:

Byte positionContentDescription
0Raw ECG data8-bit ADC value, high byte first; returns 0xFFFF in shutdown state
1Filtered ECG data8-bit filtered value, high byte first; returns 0xFFFF in shutdown state
2Lead-off detection status0x00 = normal, 0x01 = lead off
3Module working status0x00 = working normally, 0x03 = shutdown
4Heart rate valueCurrently calculated heart rate value (unit: bpm, 0~255); returns 0xFFFF in shutdown state

Here are some references (note that all are in hexadecimal format!!!):

5 55 0xFFFF

3.3 Application Experiment

Here, we use the GraftPort-RP2040 development board for testing, and the integrated ECG signal acquisition module based on the AD8232 uses the UART interface to communicate with the main controller.

Here, we first use the HY2.0-4P cable to connect the module to the GraftPort-RP2040 development board's UART1 interface. We use a polymer lithium battery and the GraftSense - SY7656-based lithium battery charge-discharge module to power the module, connect the lead wires and corresponding ECG electrodes as described above, and also need to connect the MiniUSB data cable to the UART interface on the underside of the main control board:

AD8232 HY2.0-4P GraftPort-RP2040 UART1

The module connections are shown in the following table:

development board pins

Module Pins

Description

Pin 8

MTX

UART data transmission line, corresponding to the transmit pin of the development board

Pin 9

MRX

UART data transmission line, corresponding to the receiving pin of the development board

Here, we need to search for the relevant driver packages on uPyPI: https://upypi.net/zh/

106

Enter ad8232_driver to search, and the following will be displayed:

ad8232_driver 1.0.0 AD8232

Click to copy the local installation command:

ad8232_driver AD8232 1.0.0 2024 02 12 upypi.net/api/v1/pypi

Here, we can import the module driver library code via the mip tool. The following are the usage commands for the mpremote tool:

mpremote mip install github:FreakStudioCN/GraftSense-Drivers-MicroPython/sensors/ad8232_driver
ad8232 FreakStudioCN/GraftSense-Drivers-MicroPython/sensors/ad8232_driver

Import the integrated ECG signal acquisition module based on AD8232 - MicroPython driver code, then copy the following main.py code into our project:

# Python env   : MicroPython v1.23.0
# -*- coding: utf-8 -*-
# @Time    : 2026/1/19 PM 5:33
# @Author  : hogeiha
# @File    : main.py
# @Description : Usage example of the serial heart rate detection module

# ======================================== Import Modules =========================================

from machine import UART, Pin, Timer
import micropython
import time
from data_flow_processor import DataFlowProcessor
from ad8232_uart import AD8232_DataFlowProcessor

# ======================================== Global Variables ============================================

# ======================================== Functions ============================================

# ======================================== Custom Classes ============================================

# ======================================== Initialization configuration ===========================================

time.sleep(3)
print("FreakStudio: Serial Port Heart Rate Detection Module Usage Example")
# Module communication UART1
uart1 = UART(1, baudrate=115200, tx=Pin(8), rx=Pin(9))
# Waveform output UART0
uart = UART(0, baudrate=115200, tx=Pin(0), rx=Pin(1), bits=8, parity=None, stop=1)
# Data frame construction example
processordata = DataFlowProcessor(uart1)
# AD8232 serial module command send/parse example
ad8232 = AD8232_DataFlowProcessor(processordata)

# ========================================  Main Program  ============================================

# Start the ad8232
ad8232.control_ad8232_start_stop(True)
# Enable active reporting
ad8232.set_active_output(True)

while True:
    # Enable active reporting; the automatic timer parses and updates instance attributes
    raw_val_dc = ad8232.ecg_value
    filtered_val = ad8232.filtered_ecg_value

    # Active reporting does not include lead status; it must be queried and returned, and attributes are updated at the same time
    lead_status = ad8232.query_off_detection_status()
    heart_rate = ad8232.heart_rate

    # Output waveform information, view with the serial plotter
    uart_str = f"{raw_val_dc},{filtered_val}\r\n"
    uart.write(uart_str.encode('utf-8'))  # Explicit encoding to avoid truncation
    # Print heart rate and lead status to the terminal
    print(f"lead_status:{lead_status},heart_rate:{heart_rate}\r\n")
    time.sleep_ms(10)

The code above mainly performs the following tasks:

When flashing the code, the terminal outputs the following:

0 72 62

Next, we need to complete the configuration of SerialPlot the serial port plotter:

  1. Configure serial port parameters: On the Port tab, select the correct serial port (e. g. COM4), set the baud rate to 115200, data bits to 8, stop bits to 1, and no parity bit
  2. Click "Open" : After confirming the configuration is correct, click the " Open " button in the upper right corner to open the serial port
COM4 CH340 1a86 7523 115200 8 1
  1. Select the data format: switch to the Data Format tab and select the " ASCII " format. In the case of single-channel data transmission, the comma is selected as the default data delimiter
3

As can be seen, the corresponding waveform is output:

COM4 115200
0 130 1

It can be observed that:

IV. Drivers

master_code.rar 13 KB

device_code.rar 7 KB

GraftSense-AD8232.uf2 913 KB

None.

VI. Revision History

Document Version

Date of Revision

Modifier

Modify Content

v1.0

2026-01-29

Zero High-Luck

Initialize the document

v1.1

2026-02-12

Xin Ruili

Create an open version of the document based on the internal document version v1.0.

v1.2

2026-03-29

Xin Ruili

Modified the application experiment section

VII. Relevant Materials

7.1 Chip Datasheet

AD8232ACPZ-RL.pdf 849 KB

7.2 Unique Icons for PCB Silk Screen

7.2 AD8232