MR60BHA2 Breath-Heartbeat Sensor with Home Assistant
Introduction
The MR60BHA2 is a 60GHz mmWave Breathing and Heartbeat Detection Sensor module designed for integration with the XIAO ESP32C6 microcontroller. This advanced sensor utilizes millimeter-wave technology to provide non-invasive monitoring of vital signs and presence detection.
This guide aims to provide a clear and comprehensive walkthrough for integrating the MR60BHA2 mmWave Sensor with Home Assistant using the XIAO ESP32C6 microcontroller. By following this guide, users will learn how to set up the sensor for heartbeat detection, connect it to their Home Assistant environment, and utilize ESPHome to manage and monitor the device effectively.
This integration empowers users to enhance their smart home systems with advanced sensing capabilities, enabling automated responses and real-time monitoring for various applications.
Product Overview
MR60BHA2 mmWave Sensor |
---|
MR60BHA2 mmWave Sensor with XIAO ESP32C6
To effectively integrate the MR60BHA2 mmWave Sensor with Home Assistant using the XIAO ESP32C6, follow these essential steps:
- Set Up Home Assistant: Begin by installing and configuring Home Assistant to manage your smart home devices, ensuring a seamless connection with the sensor.
- Connect the MR60BHA2 Sensor: Learn how to discover and add the MR60BHA2 Sensor to your Home Assistant setup, enabling real-time monitoring of vital signs.
- Monitor Sensor Data: Once integrated, you can monitor sensor data effectively, allowing for insights into heart rate and breathing patterns.
- Implement Automation: Explore the powerful automation features of Home Assistant to create responsive actions based on the sensor data, enhancing your smart home environment.
- Modify Firmware with ESPHome: Utilize ESPHome to customize the sensor's functionality, tailoring it to meet your specific needs for greater flexibility and control.
These steps will guide you through the integration process, helping you make the most of your MR60BHA2 mmWave Sensor and XIAO ESP32C6 setup.
Getting Started
Please note that when we refer to firmware updates or modifications, we are specifically addressing the firmware on the XIAO ESP32C6.
To successfully integrate the MR60BHA2 mmWave Sensor with Home Assistant, you will need the following components:
- Home Assistant: A smart home platform that will manage the sensor data.
- ESPHome Add-on: Firmware that enables easy configuration and management of ESP32 devices.
Step 1: Setting Up Home Assistant
- Installation: For optimal performance, it's recommended to install Home Assistant OS on a Virtual Machine or Raspberry Pi. Follow the official installation guide on the Home Assistant website.
- Enabling ESPHome Add-on:
- Access the Home Assistant dashboard.
- Navigate to the "Add-ons" section and search for the ESPHome add-on.
- Click "Install" and then "Start" to enable it.
- Once installed, configure the add-on to ensure proper communication with the XIAO ESP32C6.
By gathering the necessary components and setting up Home Assistant with the ESPHome add-on, you'll be ready to proceed with the integration of the MR60BHA2 mmWave Sensor.
We have also written how to install Home Assistant for some of Seeed Studio products, please refer to them.
Step 2: Preparing the Kit
By default, your device (XIAO ESP32C6) comes pre-flashed with firmware for breathing and heart rate detection. However, there are two scenarios where you may need to update the firmware:
- Re-flashing the Firmware: If the existing firmware is corrupted or you need to start fresh.
- Upgrading the Firmware: If there is a newer version of the firmware with improved functionality.
There are two simple methods for flashing the firmware:
- Web Tool
- ESPHome Web
You can use this Web Tool for an easy and direct method to flash your firmware. Simply follow the on-screen instructions.
- Click the
CONNECT
button to initiate the connection. The tool will automatically update the firmware.
If something goes wrong, follow the on-screen troubleshooting steps or switch to the ESPHome Web
method to complete the process.
For this method, you'll need to download the bin
firmware file from here(you'll need to unzip the downloaded file).
- Connect the sensor kit to your PC.
- Visit the ESPHome Web page.
- Select the firmware file with the
*.factory.bin
suffix.
Watch the following video for a detailed walkthrough of flashing the firmware via ESPHome Web:
With either method, you'll have your firmware updated and ready for integration with Home Assistant.
Connect to the kit's hotspot
With the firmware, you could power on the sensor kit, and a Wi-Fi access point will appear: seeedstudio-mr60bha2
.
Navigate to 192.168.4.1
to configure your Home Assistant server's local network settings.
Step 3: Discovering and Adding the Device in Home Assistant
In this section, we'll go through the process using the Home Assistant app, where the logic is the same as on the web.
Open the App: Once you launch the app, select your Home Assistant server. The app will automatically find your server.
Create an Account: If you haven't created an account, you'll need to do so. After that, log in with your credentials.
Navigate to the Integration Page: Once logged in, go to the "Integrations" page in Home Assistant. If you have installed the ESPHome add-on and both the XIAO ESP32C6 and your Home Assistant server are on the same network, you should see the device
Seeed Studio MR60BHA2 Kit {device-mac-address}
appear under discovered devices.Add the Device: Click to add the device to your Home Assistant setup.
Click the
CONFIGURE
button, confirm by pressing theSUBMIT
button, and assign the device to your preferred area (e.g., Bedroom). After this, the device will be managed through your ESPHome integration, enabling full control and monitoring in Home Assistant.
Monitoring and Control
By following the steps above, you'll have successfully discovered and added the MR60BHA2 Sensor to your Home Assistant, enabling real-time monitoring and control.
Sensor data Monitoring
Now that the sensor is added to the "Bedroom," navigate to the "Overview" tab. You will see the mmWave card displayed in the Bedroom section.
RGB light Controlling
In this section, we will explore how to control an RGB light.
Click on the corresponding box to directly control the RGB light:
Next Steps
Now that you have successfully integrated the MR60BHA2 mmWave Sensor with the XIAO ESP32C6 and Home Assistant, you can explore further enhancements to make the most out of your setup. Here are two essential avenues to consider:
Implementing Automation in Home Assistant
Home Assistant's powerful automation features allow you to create a more responsive smart home environment based on the data collected from your MR60BHA2 Sensor. This means you can set up actions that occur automatically based on specific triggers related to motion or heartbeat detection.
Here's how to implement automations step-by-step:
- Navigate to the Automations Section: In your Home Assistant dashboard, find and click on the "Automations" tab. This area is dedicated to creating and managing automated actions within your home.
- Create a New Automation: Click on the "Add Automation" button. Home Assistant offers a user-friendly wizard that guides you through the process of setting up an automation.
- Define the Trigger: Choose a trigger based on the MR60BHA2 Sensor's data. For example, you can set the automation to trigger when the sensor detects motion or a specific heartbeat pattern. This means your automation can respond immediately to the sensor's readings.
- Set Conditions (Optional): Conditions allow you to refine when the automation should execute. For instance, you might want the lights to turn on only when it's dark outside or if a specific user is home.
- Determine the Action: Specify what action should occur when the trigger conditions are met. Actions can include turning on lights, sending notifications, or even adjusting thermostat settings. For example, you could create an action that turns on an RGB light when motion is detected, enhancing both security and comfort.
- Save and Test: After configuring your automation, save it and test its functionality. Walk past the sensor to see if the lights turn on as expected. If any issues arise, you can return to the automation settings to troubleshoot and adjust.
By leveraging Home Assistant's automation capabilities, you can create a truly smart environment that responds to your movements and health metrics, ensuring that your living space adapts to your lifestyle seamlessly.
Modifying the Firmware with ESPHome
One of the significant advantages of using the XIAO ESP32C6 is its compatibility with ESPHome, a powerful tool for managing and customizing your microcontroller firmware. With ESPHome, you can directly modify the firmware to tailor the functionality of the MR60BHA2 mmWave Sensor to your specific needs.
To get started with ESPHome, follow these steps:
Access the ESPHome Dashboard: In Home Assistant, navigate to the ESPHome add-on. You should see your XIAO ESP32C6 listed among the devices.
Create a New Configuration: Click on the device to open its configuration. Here, you can adjust settings such as the sensor's sensitivity, reporting intervals, and output formats. ESPHome uses a YAML configuration format, which is user-friendly and allows you to define various parameters. You can use the following template YAML file as a starting point for your configuration, which is designed specifically for the MR60BHA2 Sensor:
example/mr60bha2.yaml# template from https://github.com/limengdu/MR60BHA2_ESPHome_external_components
substitutions:
name: "seeedstudio-mr60bha2-kit"
friendly_name: "Seeed Studio MR60BHA2 Kit"
esphome:
name: "${name}"
friendly_name: "${friendly_name}"
name_add_mac_suffix: true
project:
name: "seeedstudio.mr60bha2_kit"
version: "1.0"
platformio_options:
board_upload.maximum_size: 4194304
min_version: "2024.3.2" # Fix logger compile error on ESP32-C6
esp32:
board: esp32-c6-devkitc-1
variant: esp32c6
flash_size: 4MB # upload.flash_size
framework:
type: esp-idf
platform_version: 6.5.0 # Minimum version required for ESP32-C6
external_components:
- source:
type: git
url: https://github.com/ssieb/esphome
ref: adc
components: [ adc ]
refresh: 1min
- source:
type: git
url: https://github.com/limengdu/MR60BHA2_ESPHome_external_components
ref: main
components: [ seeed_mr60bha2 ]
refresh: 0s
logger:
hardware_uart: USB_SERIAL_JTAG
level: DEBUG
api:
ota:
- platform: esphome
wifi:
ap:
ssid: "seeedstudio-mr60bha2"
light:
- platform: esp32_rmt_led_strip
id: led_ring
name: "Seeed MR60BHA2 RGB Light"
pin: GPIO1
num_leds: 1
rmt_channel: 0
rgb_order: GRB
chipset: ws2812
i2c:
sda: GPIO22
scl: GPIO23
scan: true
id: bus_a
uart:
id: uart_bus
baud_rate: 115200
rx_pin: 17
tx_pin: 16
parity: NONE
stop_bits: 1
seeed_mr60bha2:
id: my_seeed_mr60bha2
sensor:
- platform: bh1750
name: "Seeed MR60BHA2 Illuminance"
address: 0x23
update_interval: 1s
- platform: seeed_mr60bha2
breath_rate:
name: "Real-time respiratory rate"
heart_rate:
name: "Real-time heart rate"
distance:
name: "Distance to detection object"Customize Functionality: You can enhance the sensor's capabilities by exploring various features available in ESPHome, allowing for flexible adjustments to suit your specific needs.
Upload the Updated Firmware: After making your modifications, save the configuration. The ESPHome dashboard allows you to upload the firmware directly over the air. Simply click the
Upload
button, and follow the prompts to complete the process. This streamlined method makes it easy to keep your firmware up to date.Test and Iterate: Once the upload is complete, test your changes in real-time. Monitor the sensor's performance to ensure it operates as expected. If you encounter any issues, revisit the ESPHome dashboard to refine your settings. This iterative approach enables you to continually improve your firmware, ensuring it meets your requirements effectively.
By utilizing ESPHome, you empower yourself to make ongoing improvements to your sensor setup, adapting it to suit your evolving needs. This capability not only enhances your project's functionality but also provides a platform for learning and experimentation with IoT development.
Through these steps, you can maximize the functionality of your MR60BHA2 mmWave Sensor and XIAO ESP32C6 setup, transforming it into a highly customized and responsive smart home system tailored to your preferences and needs.
Resources
Tech Support & Product Discussion
Thank you for choosing our products! We are here to provide you with different support to ensure that your experience with our products is as smooth as possible. We offer several communication channels to cater to different preferences and needs.