Labs / Electronic modules

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

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

Contents
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

I. Module Introduction

R60ABD1-based millimeter-wave radar module for respiratory and sleep monitoring that adopts FMCW frequency modulated continuous wave technology, can simultaneously sense human respiratory and heart rate within a distance of ≤1.5 meters, record historical sleep quality data, and also realize human presence detection (typical reporting time: 30 seconds).The power supply range of this module is compatible with 5V to 3.3V conversion, and it is equipped with MCU interfaces, power filtering and indicator lights. It is free from interference by environmental factors such as temperature, humidity and noise. With a radar output power of less than 0.5 W and a requirement for long-term power supply, this module is suitable for scenarios including sleep monitoring and health management, and provides a reliable technical solution for non-contact human vital sign monitoring.

II. Introduction to Major Chips

The module adopts R60ABD1 respiratory sleep radar module.

2.1 Chip Overview

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

2.2 Pin Definition

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

2.3 Functional Block Diagram

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

2.4 Performance Parameters

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

2.5 Reference Circuit

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

2.6 Chip Configuration

This module is of Plug and Play type, requiring no hardware configuration or software register settings. R60ABD1 performs data interaction with other devices via a serial port for communication.

2.7.1 Description of Vital Sign Parameters Actively Posted Back by Radar

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
FunctionFunction / data typeReporting methodState change time / periodData range / description
DP1Occupied / unoccupiedReported on state changeUnoccupied→occupied: ≤0.5s; occupied→unoccupied: about 40s0=unoccupied, 1=occupied
DP2Occupied stationary / occupied activeReported on state changeStationary↔active: ≤0.5s0=stationary, 1=active
DP3Human body distanceActively reportedOutput every 2sUnit cm, 0~65535
DP4Body movement amplitude parameterActively reportedOutput every 1s0~100
DP5Human body orientationActively reportedOutput every 2s6 bytes (2 bytes each for X, Y, Z axes); the first bit is the sign (0 = negative, 1 = positive), the remaining 15 bits are the coordinate value
DP6Heartbeat valueActively reportedOutput every 3 s60~120 bpm
DP7Heart rate waveformActively reportedOutput every 1 s (5 bytes)Range 0-2; data = true value + 128 (centered display)
DP8Respiration valueActively reportedOutput every 3 s0-35 breaths/min
DP9Respiration informationReported on state changeReal-time0 = no one present, 1 = normal (10-25), 2 = too low (<10), 3 = too high (>25)
DP10Respiration waveformActively reportedOutput every 1 s (5 bytes)Range 0-153; data = true value + 128 (centered display)
DP11Enter bed / leave bedReported on state changeEnter bed: reported immediately when conditions are met; leave bed: about 30 s0 = left bed, 1 = in bed
DP12Sleep stateActively reportedOutput every 10 min while in bed0 = deep sleep, 1 = light sleep, 2 = awake, 3 = left bed
DP13Sleep duration (awake/light/deep)Actively reportedUpdated every 10 min while in bedRange 0-65535 minutes
DP14Sleep quality scoreActively reportedAt the end of the sleep session0100 points; 0 when abnormal; valid result is output only after 412 h
DP15Comprehensive sleep statusActively reportedOutput once every 10 minIncludes: presence, sleep state, average heartbeat/respiration, number of turnovers, percentage of large/small body movements, number of apnea events (not available yet)
DP16Sleep quality analysisActively reportedOutput at the end of sleepIncludes: sleep score, total duration, percentage of awake/light/deep sleep, time/number of times out of bed, number of turnovers, average respiration/heartbeat, number of apnea events (not available yet)
DP17Sleep abnormalityReported on state changeReal-time0 = no abnormality, 1 = too short (<4 h), 2 = too long (>12 h), 3 = abnormal, no one present
DP18Abnormal strugglingReported on state changeReal-time0 = none, 1 = normal, 2 = abnormal (struggle conditions met)
DP19No-presence timerReported on state changeReal-time0 = none, 1 = normal, 2 = abnormal
DP20Sleep quality ratingReported on state changeWhen the sleep score changes>0: 1-60 = poor, 61-75 = fair, 76~100 = good

2.7.2 Custom Protocol Frame

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

2.7.3 Query and Setting of Basic Instruction Information

2.7.4 Query and Setting of Human Presence Command Information

Note: All information related to human presence can only be parsed based on actively reported data after the human presence function is enabled.

On the following version numbers, the usage logic for enabling or disabling the human presence function differs from that on the G60SM1SYv010107 version:

On the new firmware version (G60SM1SYv010309), an abnormal operation sequence has been identified:

  1. The N-th operation: After sequentially disabling the active reporting of the four functions of human presence, heart rate, respiration and sleep, power off the millimeter-wave radar module and then power it on again.
  2. The (N+ 1)-th operation: After the module is restarted, if any single one of its functions is enabled separately at this point, no corresponding active reported data can be received.
  3. The (N+ 2)-th operation: Enable all active reporting functions of the four features, and then power off and restart the module again. After that, all active reporting functions resume normal operation, and during this power-on cycle, any expected response can be obtained no matter a single function is enabled or disabled.

The following is the testing procedure conducted on the new firmware (G60SM1SYv010309):

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

Below are the same tests conducted on the old firmware version (G60SM1SYv010107):

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

2.7.5 Query and Setting of Heart Rate Monitoring Command Information

Note that in actual tests, the heart rate waveform reporting switch setting and heart rate waveform reporting switch query in the commands related to heart rate monitoring information are unavailable on certain versions, and the relevant version numbers are as follows:

while it is available in some other versions, with the relevant version numbers as follows:

The usage logic for enabling the heart rate monitoring function on the following version numbers differs from that on the G60SM1SYv010107 version:

On the new firmware version (G60SM1SYv010309), an abnormal operation sequence has been identified:

  1. The N-th operation: After sequentially disabling the active reporting of the four functions of human presence, heart rate, respiration and sleep, power off the millimeter-wave radar module and then power it on again.
  2. The (N+ 1)-th operation: After the module is restarted, if any single one of its functions is enabled separately at this point, no corresponding active reported data can be received.
  3. The (N+ 2)-th operation: Enable all active reporting functions of the four features, and then power off and restart the module again. After that, all active reporting functions resume normal operation, and during this power-on cycle, any expected response can be obtained no matter a single function is enabled or disabled.

Note: Among the heart rate monitoring information, only the heart rate waveform can be obtained through query-response inquiry when the heart rate waveform reporting switch is turned off (with the heart rate monitoring function enabled), while all other heart rate monitoring information (such as heart rate value) can only be parsed from the actively reported data after the heart rate monitoring function is turned on.

2.7.6 Query and Setting of Respiratory Monitoring Instruction Information

Note that, except for the respiratory waveform in the respiratory monitoring information which can be obtained through query-response inquiry when the respiratory waveform reporting switch is turned off (while the respiratory monitoring function is enabled), all other respiratory monitoring information (such as respiratory values) can only be parsed based on actively reported information after the respiratory monitoring function is turned on.

The usage logic for enabling/disabling the breathing monitoring function on the following version numbers differs from that on the G60SM1SYv010107 version:

On the new firmware version (G60SM1SYv010309), an abnormal operation sequence has been identified:

  1. The N-th operation: After sequentially disabling the active reporting of the four functions of human presence, heart rate, respiration and sleep, power off the millimeter-wave radar module and then power it on again.
  2. The (N+ 1)-th operation: After the module is restarted, if any single one of its functions is enabled separately at this point, no corresponding active reported data can be received.
  3. The (N+ 2)-th operation: Enable all active reporting functions of the four features, and then power off and restart the module again. After that, all active reporting functions resume normal operation, and during this power-on cycle, any expected response can be obtained no matter a single function is enabled or disabled.

2.7.7 Query and Setting of Sleep Monitoring Instruction Information

On the following version number, the usage logic for toggling the sleep monitoring function differs from that on the G60SM1SYv010107 version:

On the new firmware version (G60SM1SYv010309), an abnormal operation sequence has been identified:

  1. The N-th operation: After sequentially disabling the active reporting of the four functions of human presence, heart rate, respiration and sleep, power off the millimeter-wave radar module and then power it on again.
  2. The (N+ 1)-th operation: After the module is restarted, if any single one of its functions is enabled separately at this point, no corresponding active reported data can be received.
  3. The (N+ 2)-th operation: Enable all active reporting functions of the four features, and then power off and restart the module again. After that, all active reporting functions resume normal operation, and during this power-on cycle, any expected response can be obtained no matter a single function is enabled or disabled.

On the following version numbers, a deviation between the actual observed communication sequence and the manual specification was noted when attempting to enable the unattended timing function!!!

  • Expected behavior (according to the manual):
    1. Host sends configuration command: 53 59 84 14 00 01 01.. .
    2. Slave device response acknowledgment frame: 53 59 84 14 00 01 01.. .(returned as-is, serving as confirmation of successful operation)
  • Observed actual behavior:
    1. Host sends setting command: 53 59 84 14 00 01 01 46 54 43 (enable unattended timing function)
    2. The slave device has replied with two messages:
      • Article 1:53 59 84 15 00 01 1E 64 54 43 (This is a response to the command word 0x15 —— "Unmanned Duration Query", and the data 1E indicates that the duration is 30 minutes)
      • Article 2:53 59 84 14 00 01 01 46 54 43 (This is the correct acknowledgment frame for the setting command as described in the manual)
    GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

    This behavior does not conform to the typical "command-response" mode; when the unattended timing function is enabled, the firmware automatically triggers a query operation for the unattended timing duration internally.

    GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

On the following version number, when attempting to test the sleep deadline query function, the actual communication sequence observed deviates from the description in the manual!!!

in firmware version

After setting the sleep timeout duration, an inconsistency is observed between the actual communication sequence during query operations and the description in the manual:

  1. Set sleep timeout duration (10 minutes):
    • Send command: 53 59 84 16 00 01 0A 51 54 43
    • Acknowledgment reply received: 53 59 84 16 00 01 0A 51 54 43 (as expected, the device returns the acknowledgment frame as-is).
  2. Subsequent query operations:
    • Send sleep deadline query command: 53 59 84 96 00 01 0F D6 54 43
    • Two replies have been received:
      • First response: 53 59 84 96 00 01 0A D1 54 43 (expected query response, the data 0A indicates that the sleep timeout duration is 10 minutes).
      • Second response: 53 59 84 9A 00 01 01 CC 54 43 (unexpected response, corresponding to command word 0x9A, i. e. the response to "struggle status interpretation query", the data 01 indicates medium sensitivity).
    GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

    After the sleep deadline query, the device additionally returned a response frame of "struggle state interpretation", while the host did not send this query command.

    GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

In the actual testing process, we have identified the following issues that require attention in the subsequent driver code development. I have documented the details of each issue and the corresponding specific version numbers here.

2.7.8.1 After disabling the four active reporting functions and restarting the device, enabling any single function individually yields no data response

On the new firmware version (G60SM1SYv010309), an abnormal operation sequence has been identified:

  1. The N-th operation: After sequentially disabling the active reporting of the four functions of human presence, heart rate, respiration and sleep, power off the millimeter-wave radar module and then power it on again.
  2. The (N+ 1)-th operation: After the module is restarted, if any single one of its functions is enabled separately at this point, no corresponding active reported data can be received.
  3. The (N+ 2)-th operation: Enable all active reporting functions of the four features, and then power off and restart the module again. After that, all active reporting functions resume normal operation, and during this power-on cycle, any expected response can be obtained no matter a single function is enabled or disabled.

The following is the testing procedure conducted on the new firmware (G60SM1SYv010309):

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

Below are the same tests conducted on the old firmware version (G60SM1SYv010107):

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

It can be seen that when all active reporting functions are disabled, the module fails to properly initialize its finite-state machine or configuration registers during the power-off and restart process, causing the system to enter an abnormal "silent" state of functions.

Here, the author speculates that the root cause may stem from a flaw in the firmware's state management logic. The detailed analysis is as follows:

2.7.8.2 The response when the unmanned timing function is enabled is inconsistent with that described in the manual

On the new firmware version (G60SM1SYv010309), an abnormal operation sequence has been identified. The version information is as follows:

  • Firmware Version: G60SM1SYv010309 (Hexadecimal: 47 36 30 53 4D 31 53 59 76 30 31 30 33 30 39 00)
  • Product Model: R60ASM1 (hexadecimal: 52 36 30 41 53 4D 31 00)
  • Hardware Version: R60A (hexadecimal: 52 36 30 41 00)

The questions are as follows:

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

This behavior does not conform to the typical "command-response" mode; when the unattended timing function is enabled, the firmware automatically triggers a query operation for the unattended timing duration internally.

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
2.7.8.3 Setting the sleep timeout duration results in inconsistent response with the manual description

On the new firmware version (G60SM1SYv010309), an abnormal operation sequence was detected, with the version details as follows:

The problem is as follows: after setting the sleep timeout duration, an inconsistency is observed between the actual communication sequence during the query operation and the description in the manual:

  1. Set sleep timeout duration (10 minutes):
    • Send command: 53 59 84 16 00 01 0A 51 54 43
    • Acknowledgment reply received: 53 59 84 16 00 01 0A 51 54 43 (as expected, the device returns the acknowledgment frame as-is).
  2. Subsequent query operations:
    • Send sleep deadline query command: 53 59 84 96 00 01 0F D6 54 43
    • Two replies have been received:
      • First response: 53 59 84 96 00 01 0A D1 54 43 (expected query response, the data 0A indicates that the sleep timeout duration is 10 minutes).
      • Second response: 53 59 84 9A 00 01 01 CC 54 43 (unexpected response, corresponding to command word 0x9A, i. e. the response to "struggle status interpretation query", the data 01 indicates medium sensitivity).

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

After the sleep deadline query, the device additionally returned a response frame of "struggle state interpretation", while the host did not send this query command.

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

2.8 PCB Routing Precautions

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

III. Circuit Engineering

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_Schematic1-R60ABD1-Based Respiration and Sleep Monitoring mmWave Radar Module-V1.1.0_2025-11-10.pdf 2.1 MB

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

The MRX (corresponding to the UART RXD pin of the MCU) of this module is actually connected to the R60ABD1 TXD pin, and the MTX (corresponding to the UART TXD pin of the MCU) is actually connected to the R60ABD1 RXD pin; this is because UART serial communication follows the "cross-transmit-receive" rule — the transmit terminal (TX) of both communication parties needs to be connected to the receive terminal (RX) of the counterpart, and this design ensures correct bidirectional UART serial data transmission between the MCU and R60ABD1.

It is particularly important to note that when using this module, MRX is directly connected to the UART RXD of the MCU, and MTX is directly connected to the UART TXD of the MCU. Do not cross-connect them under any circumstances.

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

This module leads out external expansion interfaces GP1 - GP6, SWC and SWD to facilitate subsequent function development and firmware upgrade. It should be noted that when soldering 2.54 header pins to the DEBUG interface, they need to be reversely connected to the back to avoid interference with the radar module.

And please note the following when using it:

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)
GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

3.3 Application Experiment

Here, we use the GraftPort-RP2040 development board for testing, and connect the R60ABD1-based millimeter-wave radar module for respiratory and sleep monitoring to communicate with the main controller via the UART interface.

Here, we first use the HY2.0-4P cable to connect the module to the GraftPort-RP2040 development board's UART0 interface:

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

The module connections are shown in the table below:

Development Board Pins

Module Pins

Description

Pin 16

MTX

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

Pin 17

MRX

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

When in use, place the module 20 centimeters directly in front of your chest:

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

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

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

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

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

Click to copy the local installation command:

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

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

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

After importing the MicroPython driver code for the R60ABD1-based respiratory sleep monitoring millimeter-wave radar, copy the following main.py code into our project:

# Python env   : MicroPython v1.23.0
# -*- coding: utf-8 -*-
# @Time    : 2025/11/4 5:33 PM
# @Author  : Li Qingshui
# @File    : main.py
# @Description : Code for testing the R60ABD1 radar device driver class
# @License : CC BY-NC 4.0

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

from machine import UART, Pin, Timer
import time
from data_flow_processor import DataFlowProcessor
from r60abd1 import R60ABD1, format_time

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

# Last print time
last_print_time = time.ticks_ms()
# Periodic print interval: print once every 2 seconds
print_interval = 2000

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

def print_report_sensor_data():
    """
    Print the data reported by the sensor to the Thonny console.

    Note: This function prints data actively reported by the device, not query results.
    The data comes from the attribute values of the R60ABD1 class, which are updated automatically in the timer callback.

    ==========================================

    Print sensor reported data to Thonny console.

    Note: This function prints data actively reported by the device, not query results.
    Data comes from R60ABD1 class attributes, which are automatically updated in timer callbacks.
    """
    # Declare global variables
    global device

    print("=" * 50)
    print("%s Sensor Data" % format_time())
    print("=" * 50)

    # Heart rate data
    print("Report Heart Rate: %d bpm" % device.heart_rate_value)
    print("Report Heart Rate Waveform: %s" % str(device.heart_rate_waveform))

    # Respiration data
    print("Report Breath Rate: %d bpm" % device.breath_value)
    print("Report Breath Status: %d" % device.breath_status)
    print("Report Breath Waveform: %s" % str(device.breath_waveform))

    # Human presence data
    print("Report Movement Parameter: %d" % device.movement_parameter)
    print("Report Presence Status: %s" % ("Someone" if device.presence_status == 1 else "No one"))
    print("Report Motion Status: %s" % ["No motion", "Static", "Active"][
        device.motion_status] if device.motion_status < 3 else "Unknown")

    # Distance and position
    print("Report Human Distance: %d cm" % device.human_distance)
    print("Report Human Position: X=%d, Y=%d, Z=%d" % (
    device.human_position_x, device.human_position_y, device.human_position_z))

    # Radar status
    print("Report Radar in Range: %s" % ("Yes" if device.radar_in_range else "No"))

    print("=" * 50)

def print_active_query_data(timeout=200):
    """
    Actively query and print sensor data (blocking query).

    Args:
        timeout: Timeout for a single query, in milliseconds.

    Note:
        - This function performs blocking queries and queries all sensor data in turn.
        - There is a 500ms delay between queries to keep the device from being overwhelmed.
        - A failed query displays a failure message; a successful one displays the specific data.

    ==========================================

    Actively query and print sensor data (blocking queries).

    Args:
        timeout: Single query timeout time in milliseconds.

    Note:
        - This function performs blocking queries, sequentially querying all sensor data.
        - Each query has 500ms delay to avoid overwhelming the device.
        - Failed queries display failure information, successful ones display specific data.
    """
    # Declare global variables
    global device

    print("=" * 50)
    print("%s Active Query Sensor Data" % format_time())
    print("=" * 50)

    # Query human body orientation
    success, direction_data = device.query_human_direction(timeout)
    if success:
        x, y, z = direction_data
        print("Query Human Position: X=%d, Y=%d, Z=%d" % (x, y, z))
    else:
        print("Query Human Position: Failed")

    time.sleep(0.5)

    # Query human body distance
    success, distance = device.query_human_distance(timeout)
    if success:
        print("Query Human Distance: %d cm" % distance)
    else:
        print("Query Human Distance: Failed")

    time.sleep(0.5)

    # Query motion information
    success, motion_status = device.query_human_motion_info(timeout)
    if success:
        motion_text = ["No motion", "Static", "Active"][motion_status] if motion_status < 3 else "Unknown"
        print("Query Motion Status: %s" % motion_text)
    else:
        print("Query Motion Status: Failed")

    time.sleep(0.5)

    # Query body movement parameters
    success, motion_param = device.query_human_body_motion_param(timeout)
    if success:
        print("Query Movement Parameter: %d" % motion_param)
    else:
        print("Query Movement Parameter: Failed")

    time.sleep(0.5)

    # Query presence status
    success, presence_status = device.query_presence_status(timeout)
    if success:
        status_text = "Someone" if presence_status == 1 else "No one"
        print("Query Presence Status: %s" % status_text)
    else:
        print("Query Presence Status: Failed")

    time.sleep(0.5)

    # Query heart rate value
    success, heart_rate = device.query_heart_rate_value(timeout)
    if success:
        print("Query Heart Rate: %d bpm" % heart_rate)
    else:
        print("Query Heart Rate: Failed")

    time.sleep(0.5)

    # Query heart rate waveform
    success, heart_rate_waveform = device.query_heart_rate_waveform(timeout)
    if success:
        print("Query Heart Rate Waveform: %s" % str(heart_rate_waveform))
    else:
        print("Query Heart Rate Waveform: Failed")

    time.sleep(0.5)

    # Query respiration value
    success, breath_rate = device.query_breath_value(timeout)
    if success:
        print("Query Breath Rate: %d bpm" % breath_rate)
    else:
        print("Query Breath Rate: Failed")

    time.sleep(0.5)

    # Query respiration waveform
    success, breath_waveform = device.query_breath_waveform(timeout)
    if success:
        print("Query Breath Waveform: %s" % str(breath_waveform))
    else:
        print("Query Breath Waveform: Failed")

    time.sleep(0.5)

    # Query respiration information
    success, breath_info = device.query_breath_info(timeout)
    if success:
        status_text = ["Normal", "High", "Low", "None"][breath_info - 1] if 1 <= breath_info <= 4 else "Unknown"
        print("Query Breath Info: %d - %s" % (breath_info, status_text))
    else:
        print("Query Breath Info: Failed")

    time.sleep(0.5)

    # Query bed status
    success, bed_status = device.query_bed_status(timeout)
    if success:
        status_text = ["Leave bed", "Enter bed", "None"][bed_status] if bed_status < 3 else "Unknown"
        print("Query Bed Status: %d - %s" % (bed_status, status_text))
    else:
        print("Query Bed Status: Failed")

    time.sleep(0.5)

    # Query no-presence timing status
    success, no_person_timing_status = device.query_no_person_timing_status(timeout)
    if success:
        status_text = ["None", "Normal", "Abnormal"][
            no_person_timing_status] if no_person_timing_status < 3 else "Unknown"
        print("Query No Person Timing Status: %d - %s" % (no_person_timing_status, status_text))
    else:
        print("Query No Person Timing Status: Failed")

    time.sleep(0.5)

    # Query sleep status
    success, sleep_status = device.query_sleep_status(timeout)
    if success:
        status_text = ["Deep sleep", "Light sleep", "Awake", "None"][sleep_status] if sleep_status < 4 else "Unknown"
        print("Query Sleep Status: %d - %s" % (sleep_status, status_text))
    else:
        print("Query Sleep Status: Failed")

    time.sleep(0.5)

    # Query awake duration
    success, awake_duration = device.query_awake_duration(timeout)
    if success:
        print("Query Awake Duration: %d min" % awake_duration)
    else:
        print("Query Awake Duration: Failed")

    time.sleep(0.5)

    # Query light sleep duration
    success, light_sleep_duration = device.query_light_sleep_duration(timeout)
    if success:
        print("Query Light Sleep Duration: %d min" % light_sleep_duration)
    else:
        print("Query Light Sleep Duration: Failed")

    time.sleep(0.5)

    # Query deep sleep duration
    success, deep_sleep_duration = device.query_deep_sleep_duration(timeout)
    if success:
        print("Query Deep Sleep Duration: %d min" % deep_sleep_duration)
    else:
        print("Query Deep Sleep Duration: Failed")

    time.sleep(0.5)

    # Query sleep quality score
    success, sleep_quality_score = device.query_sleep_quality_score(timeout)
    if success:
        print("Query Sleep Quality Score: %d/100" % sleep_quality_score)
    else:
        print("Query Sleep Quality Score: Failed")

    time.sleep(0.5)

    # Query overall sleep status
    success, sleep_comprehensive_status = device.query_sleep_comprehensive_status(timeout)
    if success:
        print("Query Sleep Comprehensive Status: Success")
        # Detailed data can be parsed and displayed further
        if len(sleep_comprehensive_status) >= 8:
            print("  - Presence: %s" % ("Someone" if sleep_comprehensive_status[0] == 1 else "No one"))
            print("  - Sleep Status: %s" % ["Deep sleep", "Light sleep", "Awake", "None"][sleep_comprehensive_status[1]] if sleep_comprehensive_status[1] < 4 else "Unknown")
            print("  - Avg Breath: %d bpm" % sleep_comprehensive_status[2])
            print("  - Avg Heart Rate: %d bpm" % sleep_comprehensive_status[3])
            print("  - Turnover Count: %d" % sleep_comprehensive_status[4])
            print("  - Large Movement Ratio: %d%%" % sleep_comprehensive_status[5])
            print("  - Small Movement Ratio: %d%%" % sleep_comprehensive_status[6])
            print("  - Apnea Count: %d" % sleep_comprehensive_status[7])
    else:
        print("Query Sleep Comprehensive Status: Failed")

    time.sleep(0.5)

    # Query sleep abnormalities
    success, sleep_anomaly = device.query_sleep_anomaly(timeout)
    if success:
        status_text = ["Short sleep (<4h)", "Long sleep (>12h)", "No person anomaly", "Normal"][sleep_anomaly] if sleep_anomaly < 4 else "Unknown"
        print("Query Sleep Anomaly: %d - %s" % (sleep_anomaly, status_text))
    else:
        print("Query Sleep Anomaly: Failed")

    time.sleep(0.5)

    # Query sleep statistics
    success, sleep_statistics = device.query_sleep_statistics(timeout)
    if success:
        print("Query Sleep Statistics: Success")
        # Detailed data can be parsed and displayed further
        if len(sleep_statistics) >= 11:
            print("  - Quality Score: %d/100" % sleep_statistics[0])
            print("  - Total Sleep Duration: %d min" % sleep_statistics[1])
            print("  - Awake Ratio: %d%%" % sleep_statistics[2])
            print("  - Light Sleep Ratio: %d%%" % sleep_statistics[3])
            print("  - Deep Sleep Ratio: %d%%" % sleep_statistics[4])
            print("  - Leave Bed Duration: %d min" % sleep_statistics[5])
            print("  - Leave Bed Count: %d" % sleep_statistics[6])
            print("  - Turnover Count: %d" % sleep_statistics[7])
            print("  - Avg Breath: %d bpm" % sleep_statistics[8])
            print("  - Avg Heart Rate: %d bpm" % sleep_statistics[9])
            print("  - Apnea Count: %d" % sleep_statistics[10])
    else:
        print("Query Sleep Statistics: Failed")

    time.sleep(0.5)

    # Query sleep quality rating
    success, sleep_quality_level = device.query_sleep_quality_level(timeout)
    if success:
        status_text = ["None", "Good", "Normal", "Poor"][sleep_quality_level] if sleep_quality_level < 4 else "Unknown"
        print("Query Sleep Quality Level: %d - %s" % (sleep_quality_level, status_text))
    else:
        print("Query Sleep Quality Level: Failed")

    print("=" * 50)

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

# ======================================== Initialization ==========================================

# Power-on delay
time.sleep(3)
# Print debug information
print("FreakStudio: Using R60ABD1 millimeter wave information collection")

# Initialize UART0: TX=16, RX=17, baud rate 115200
uart = UART(0, baudrate=115200, tx=Pin(16), rx=Pin(17), timeout=0)

# Create DataFlowProcessor instance
processor = DataFlowProcessor(uart)

# Create an R60ABD1 instance
device = R60ABD1(processor, parse_interval=200)

success, product_model = device.query_product_model()
if success:
    print("Product Model: %s" % product_model)
else:
    print("Query Product Model failed")

time.sleep(0.5)

success, product_id = device.query_product_id()
if success:
    print("Product ID: %s" % product_id)
else:
    print("Query Product ID failed")

time.sleep(0.5)

success, hardware_model = device.query_hardware_model()
if success:
    print("Hardware Model: %s" % hardware_model)
else:
    print("Query Hardware Model failed")

time.sleep(0.5)

success, firmware_version = device.query_firmware_version()
if success:
    print("Hardware Version: %s" % firmware_version)
else:
    print("Query Hardware Version failed")

time.sleep(0.5)

success, init_status = device.query_init_complete()
if success:
    print("Init Status: %s" % init_status)
else:
    print("Query Init Status failed")

time.sleep(0.5)

success, boundary_status = device.query_radar_range_boundary()
if success:
    status_text = "out of range" if boundary_status else "in range"
    print("Boundary Status: %s" % status_text)
else:
    print("Query Boundary Status failed")

time.sleep(0.5)

success, presence_switch_status = device.query_human_presence_switch()
if success:
    status_text = "ON" if presence_switch_status else "OFF"
    print("Boundary Status: %s" % status_text)
else:
    print("Query Boundary Status failed")

time.sleep(0.5)

success, heart_rate_monitor_switch_status = device.query_heart_rate_monitor_switch()
if success:
    status_text = "ON" if heart_rate_monitor_switch_status else "OFF"
    print("Heart Rate Monitor Switch: %s" % status_text)
else:
    print("Query Heart Rate Monitor Switch failed")

time.sleep(0.5)

success, heart_rate_waveform_report_switch_status = device.query_heart_rate_waveform_report_switch()
if success:
    status_text = "ON" if heart_rate_waveform_report_switch_status else "OFF"
    print("Heart Rate Waveform Report Switch: %s" % status_text)
else:
    print("Query Heart Rate Waveform Report Switch failed")

time.sleep(0.5)

# Query respiration monitoring switch status
success, breath_monitor_switch_status = device.query_breath_monitor_switch()
if success:
    status_text = "ON" if breath_monitor_switch_status else "OFF"
    print("Breath Monitor Switch: %s" % status_text)
else:
    print("Query Breath Monitor Switch failed")

time.sleep(0.5)

# Set the low-slow respiration threshold to 15 breaths/min
success, set_result = device.set_low_breath_threshold(15)
if success:
    print("Set Low Breath Threshold: Success (15 bpm)")
else:
    print("Set Low Breath Threshold failed")

time.sleep(0.5)

# Query the current low-slow respiration threshold
success, low_breath_threshold = device.query_low_breath_threshold()
if success:
    print("Query Low Breath Threshold: %d bpm" % low_breath_threshold)
else:
    print("Query Low Breath Threshold failed")

time.sleep(0.5)

# Query respiration waveform reporting switch status
success, breath_waveform_report_switch_status = device.query_breath_waveform_report_switch()
if success:
    status_text = "ON" if breath_waveform_report_switch_status else "OFF"
    print("Breath Waveform Report Switch: %s" % status_text)
else:
    print("Query Breath Waveform Report Switch failed")

# Query sleep monitoring switch status
success, sleep_monitor_switch_status = device.query_sleep_monitor_switch()
if success:
    status_text = "ON" if sleep_monitor_switch_status else "OFF"
    print("Sleep Monitor Switch: %s" % status_text)
else:
    print("Query Sleep Monitor Switch failed")

time.sleep(0.5)

# Turn on sleep monitoring function
success, result = device.enable_sleep_monitor()
if success:
    print("Enable Sleep Monitor: Success")
else:
    print("Enable Sleep Monitor failed")

time.sleep(0.5)

# Query the abnormal struggle monitoring switch status
success, abnormal_struggle_switch_status = device.query_abnormal_struggle_switch()
if success:
    status_text = "ON" if abnormal_struggle_switch_status else "OFF"
    print("Abnormal Struggle Monitor Switch: %s" % status_text)
else:
    print("Query Abnormal Struggle Monitor Switch failed")

time.sleep(0.5)

# Enable the abnormal struggle monitoring feature
success, result = device.enable_abnormal_struggle_monitor()
if success:
    print("Enable Abnormal Struggle Monitor: Success")
else:
    print("Enable Abnormal Struggle Monitor failed")

time.sleep(0.5)

# Query struggle sensitivity
success, struggle_sensitivity = device.query_struggle_sensitivity()
if success:
    sensitivity_text = ["Low", "Medium", "High"][struggle_sensitivity] if struggle_sensitivity < 3 else "Unknown"
    print("Struggle Sensitivity: %d - %s" % (struggle_sensitivity, sensitivity_text))
else:
    print("Query Struggle Sensitivity failed")

time.sleep(0.5)

# Set struggle sensitivity to medium
success, result = device.set_struggle_sensitivity(1)  # 1 = medium sensitivity
if success:
    print("Set Struggle Sensitivity: Success (Medium)")
else:
    print("Set Struggle Sensitivity failed")

time.sleep(0.5)

# Query the no-presence timing feature switch status
success, no_person_timing_switch_status = device.query_no_person_timing_switch()
if success:
    status_text = "ON" if no_person_timing_switch_status else "OFF"
    print("No Person Timing Switch: %s" % status_text)
else:
    print("Query No Person Timing Switch failed")

time.sleep(0.5)

# Turn on unoccupied timing function
success, result = device.enable_no_person_timing()
if success:
    print("Enable No Person Timing: Success")
else:
    print("Enable No Person Timing failed")

time.sleep(0.5)

# Query unoccupied timing duration
success, no_person_timing_duration = device.query_no_person_timing_duration()
if success:
    print("No Person Timing Duration: %d minutes" % no_person_timing_duration)
else:
    print("Query No Person Timing Duration failed")

time.sleep(0.5)

# Set the no-presence timing duration to 30 minutes
success, result = device.set_no_person_timing_duration(30)
if success:
    print("Set No Person Timing Duration: Success (30 minutes)")
else:
    print("Set No Person Timing Duration failed")

time.sleep(0.5)

# Query sleep cutoff duration
success, sleep_end_duration = device.query_sleep_end_duration()
if success:
    print("Sleep End Duration: %d minutes" % sleep_end_duration)
else:
    print("Query Sleep End Duration failed")

time.sleep(0.5)

# Set the sleep cutoff duration to 10 minutes
success, result = device.set_sleep_end_duration(10)
if success:
    print("Set Sleep End Duration: Success (10 minutes)")
else:
    print("Set Sleep End Duration failed")

time.sleep(0.5)

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

try:
    while True:
        current_time = time.ticks_ms()

        # Print sensor data periodically
        if time.ticks_diff(current_time, last_print_time) >= print_interval:

            # print_report_sensor_data()

            success, presence_status = device.query_presence_status()
            if success:
                print("Presence Status: %s" % ("Someone" if presence_status == 1 else "No one"))
            else:
                print("Query Presence Status failed")
            last_print_time = current_time

            time.sleep(0.2)

            success, heartbeat_status = device.query_heartbeat()
            if success:
                print("Heartbeat Status: %s" % ("Normal" if heartbeat_status == 1 else "Abnormal"))
            else:
                print("Query Heartbeat failed")

        # Small delay to avoid using too much CPU
        time.sleep_ms(10)

except KeyboardInterrupt:
    print("%s Program interrupted by user" % format_time())

finally:
    # Clean up resources
    print("%s Cleaning up resources..." % format_time())
    # Stop the instance
    device.close()
    # Destroy the instance
    del device
    print("%s Program exited" % format_time())

Burn the code, open the terminal, and use the mpremote tool to connect to the main controller. The output is as follows:

Its content includes the current heart rate value, heart rate status, presence/absence detection, etc. :

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)

For the specific usage instructions of this module and the guidelines for writing the driver library, please refer to:

Practice of Serial Port Protocol Parsing: Taking the R60ABD1 Radar as an Example, a Detailed Explanation of the Separation Design of Data and Business Logic in MicroPython Drivers

IV. Drivers

r60abd1_driver.zip 44 KB

None.

VI. Revision History

Document Version

Date of Modification

Modifier

Modified Content

v1.0

2025-11-10

Ling Gaoxing

Initialize the document

v1.1

2025-12-29

Li Zisheng

Added application experiments and production files

v1.2

2025-12-31

Xin Ruili

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

v1.3

2026-03-29

Xin Ruili

Modified the application experiment section

VII. Relevant Materials

7.1 Chip Datasheet

hardware related

R60ABD1 Datasheet.pdf 1.1 MB

Relevant technical documents

Protocol Related.pdf 598 KB

Internal Firmware

G60SM1SYv010309-tongyong-250826-off.bin 1.0 MB

G60SM1SYv010209-tongyong-250703.bin 1.0 MB

G60SM1SYv010107-tongyong-230627.bin 1.0 MB

7.2 Unique Icons for PCB Silkscreen

GraftSense - R60ABD1-Based Millimeter-Wave Radar Module for Respiratory Sleep Monitoring (Open Version)