ESP32 LD2410B Human Presence Sensor
Overview
The LD2410B is a millimeter-wave radar sensor for human presence detection with enhanced Bluetooth-based configuration support. It maintains UART communication while offering wireless setup and tuning via BLE.
About LD2410B Human Presence Sensor
The LD2410B is an upgraded version of the popular LD2410 millimeter-wave radar sensor. It includes all the presence detection features of the original model—such as stationary and moving human detection using 24GHz radar technology—while adding integrated Bluetooth Low Energy (BLE) for wireless configuration. This eliminates the need for wired UART access during setup, simplifying installation and tuning. Like its predecessor, the LD2410B is ideal for smart home applications such as lighting automation, security, and HVAC systems. Learn more about the original sensor at LD2410.
Where to Buy
Prices are subject to change. We earn from qualifying purchases as an Amazon Associate.
Technical Specifications
Pinout Configuration
The VCC
pin is used to supply power to the sensor, and it typically requires 3.3V or 5V (refer to the datasheet for specific voltage requirements). The GND
pin is the ground connection and must be connected to the ground of your ESP32.
The LD2410B module shares the same fundamental pinout as the original LD2410, with the addition of integrated Bluetooth Low Energy (BLE) functionality for wireless configuration and diagnostics. The primary interface remains UART, with clearly defined pins for power, communication, and optional logic output:
VCC
– Power input pin. Connect to a regulated 5V source. Supplying correct voltage is essential for stable radar operation.GND
– Ground pin. This must be tied to the common ground of the ESP32 or any other host controller for proper data signaling.TX
– UART transmit line. This pin sends serial data from the LD2410B to the ESP32 (connect to ESP32 RX).RX
– UART receive line. Used to receive serial commands from the host (connect to ESP32 TX).OUT
– An optional GPIO output that goes HIGH when presence is detected. Can be used to trigger hardware interrupts or simple presence-based logic without using UART.
Note: While BLE is internally supported, it does not require external pin access and functions independently once configured.
Wiring with ESP32
To wire the LD2410B to an ESP32 for UART-based presence sensing and configuration, follow these connection steps. Ensure you are using UART2 (or another free UART interface) on the ESP32, and use level-shifting components if your board is not 5V tolerant (though most ESP32s are compatible):
VCC
(red wire) → 5V pin on ESP32. Provides power to the sensor. Required even when using BLE.GND
(black wire) → GND on ESP32. Must be connected to the common ground for stable communication.TX
(green wire) → GPIO16 on ESP32. This is the receive pin (RX) on the microcontroller side.RX
(blue wire) → GPIO17 on ESP32. This is the transmit pin (TX) on the microcontroller side.OUT
(optional, yellow wire) → GPIO18 if you plan to use presence-triggered interrupts or visual indicators (like LEDs).
While BLE can be used to configure the LD2410B without these connections, a full UART setup is recommended for real-time presence sensing in embedded environments. BLE and UART cannot be used simultaneously on most firmware versions, so use BLE for setup, then switch to UART for continuous operation.
Troubleshooting Guide
Common Issues
📶 Bluetooth Not Detected
Issue: The sensor does not appear in the BLE scanner app during setup.
Ensure the module is powered and not actively communicating via UART. BLE is typically disabled during UART operation. Power cycle the sensor without a UART connection and scan again.
🚫 No Data Over UART
Issue: ESP32 receives no UART data from the sensor.
Confirm correct wiring of TX/RX and check that BLE mode is not interfering. BLE and UART should not operate simultaneously in some firmware versions.
⚠️ Detection Delay
Issue: Presence detection is delayed or inconsistent.
Use the Bluetooth configuration app to adjust sensitivity gates and energy thresholds. Ensure no large obstacles block the radar field.
🔌 Cannot Access Configuration
Issue: Neither BLE nor UART configuration is working.
Reset the device using a hardware reset if available, or power cycle while holding a configuration button (if present). Consult the datasheet for boot behavior.
Debugging Tips
🔍 Serial Monitor
Use the Serial Monitor to check for error messages and verify the sensor's output. Add debug prints in your code to track the sensor's state.
⚡ Voltage Checks
Use a multimeter to verify voltage levels and check for continuity in your connections. Ensure the power supply is stable and within the sensor's requirements.
Additional Resources
Code Examples
Arduino Example
#if defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_AVR_LEONARDO)
//ARDUINO_SAMD_NANO_33_IOT RX_PIN is D1, TX_PIN is D0
//ARDUINO_AVR_LEONARDO RX_PIN(RXI) is D0, TX_PIN(TXO) is D1
#define sensorSerial Serial1
#elif defined(ARDUINO_XIAO_ESP32C3) || defined(ARDUINO_XIAO_ESP32C6)
//RX_PIN is D7, TX_PIN is D6
#define sensorSerial Serial0
#elif defined(ESP32)
//Other ESP32 device - choose available GPIO pins
#define sensorSerial Serial1
#if defined(ARDUINO_ESP32S3_DEV)
#define RX_PIN 18
#define TX_PIN 17
#else
#define RX_PIN 16
#define TX_PIN 17
#endif
#else
#error "This sketch only works on ESP32, Arduino Nano 33IoT, and Arduino Leonardo (Pro-Micro)"
#endif
// User defines
// #define DEBUG_MODE
#define ENHANCED_MODE
#define SERIAL_BAUD_RATE 115200
//Change the communication baud rate here, if necessary
//#define LD2410_BAUD_RATE 256000
#include "MyLD2410.h"
#ifdef DEBUG_MODE
MyLD2410 sensor(sensorSerial, true);
#else
MyLD2410 sensor(sensorSerial);
#endif
unsigned long nextPrint = 0, printEvery = 1000; // print every second
void printValue(const byte &val) {
Serial.print(' ');
Serial.print(val);
}
void printData() {
Serial.print(sensor.statusString());
if (sensor.presenceDetected()) {
Serial.print(", distance: ");
Serial.print(sensor.detectedDistance());
Serial.print("cm");
}
Serial.println();
if (sensor.movingTargetDetected()) {
Serial.print(" MOVING = ");
Serial.print(sensor.movingTargetSignal());
Serial.print("@");
Serial.print(sensor.movingTargetDistance());
Serial.print("cm ");
if (sensor.inEnhancedMode()) {
Serial.print("
signals->[");
sensor.getMovingSignals().forEach(printValue);
Serial.print(" ] thresholds:[");
sensor.getMovingThresholds().forEach(printValue);
Serial.print(" ]");
}
Serial.println();
}
if (sensor.stationaryTargetDetected()) {
Serial.print(" STATIONARY= ");
Serial.print(sensor.stationaryTargetSignal());
Serial.print("@");
Serial.print(sensor.stationaryTargetDistance());
Serial.print("cm ");
if (sensor.inEnhancedMode()) {
Serial.print("
signals->[");
sensor.getStationarySignals().forEach(printValue);
Serial.print(" ] thresholds:[");
sensor.getStationaryThresholds().forEach(printValue);
Serial.print(" ]");
}
Serial.println();
}
if (sensor.inEnhancedMode() && (sensor.getFirmwareMajor() > 1)) {
Serial.print("Light level: ");
Serial.println(sensor.getLightLevel());
Serial.print("Output level: ");
Serial.println((sensor.getOutLevel()) ? "HIGH" : "LOW");
}
Serial.println();
}
void setup() {
Serial.begin(SERIAL_BAUD_RATE);
#if defined(ARDUINO_XIAO_ESP32C3) || defined(ARDUINO_XIAO_ESP32C6) || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_AVR_LEONARDO)
sensorSerial.begin(LD2410_BAUD_RATE);
#else
sensorSerial.begin(LD2410_BAUD_RATE, SERIAL_8N1, RX_PIN, TX_PIN);
#endif
delay(2000);
Serial.println(FILE);
if (!sensor.begin()) {
Serial.println("Failed to communicate with the sensor.");
while (true) {}
}
#ifdef ENHANCED_MODE
sensor.enhancedMode();
#else
sensor.enhancedMode(false);
#endif
delay(nextPrint);
}
void loop() {
if ((sensor.check() == MyLD2410::Response::DATA) && (millis() > nextPrint)) {
nextPrint = millis() + printEvery;
printData();
}
}
The LD2410B is fully compatible with the same Arduino code used for the LD2410 sensor. You can refer to the MyLD2410
library and use identical UART wiring and commands. No code changes are required aside from ensuring BLE is disabled or inactive during UART communication. See LD2410 Arduino Example for implementation details.
ESPHome Example
esphome:
name: ld2410_sensor
platform: ESP32
board: esp32dev
logger:
uart:
id: uart_bus
tx_pin: GPIO17
rx_pin: GPIO16
baud_rate: 256000
ld2410:
uart_id: uart_bus
binary_sensor:
- platform: ld2410
has_target:
name: "Presence Detected"
has_moving_target:
name: "Moving Target Detected"
has_still_target:
name: "Still Target Detected"
sensor:
- platform: ld2410
moving_distance:
name: "Moving Distance"
still_distance:
name: "Still Distance"
moving_energy:
name: "Moving Energy"
still_energy:
name: "Still Energy"
detection_distance:
name: "Detection Distance"
text_sensor:
- platform: ld2410
version:
name: "LD2410 Firmware Version"
mac_address:
name: "LD2410 MAC Address"
ESPHome configurations for the LD2410B are identical to those used for the LD2410. You can use the same UART settings, component definitions, and binary/sensor blocks. Just make sure BLE is not active during UART communication to avoid conflicts. Refer to the LD2410 ESPHome Integration for YAML examples.
PlatformIO Example
platformio.ini
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
iavorvel/MyLD2410@^1.0.2
monitor_speed = 115200
PlatformIO Example Code
#include <MyLD2410.h>
MyLD2410 radar;
void setup() {
Serial.begin(115200);
Serial2.begin(256000, SERIAL_8N1, 16, 17); // RX=16, TX=17
if (!radar.begin(&Serial2)) {
Serial.println("Failed to initialize LD2410 sensor");
while (true) {}
}
Serial.println("LD2410 initialized successfully");
}
void loop() {
radar.read();
if (radar.presenceDetected()) {
Serial.println("Presence detected");
Serial.print("Still distance: ");
Serial.println(radar.stillDistance());
Serial.print("Moving distance: ");
Serial.println(radar.movingDistance());
} else {
Serial.println("No presence");
}
delay(1000);
}
The LD2410B is fully compatible with the same MyLD2410
PlatformIO library and example code used for the LD2410. You can use identical UART wiring (TX=17, RX=16) and no code changes are necessary to support LD2410B functionality. The sensor will operate normally over UART as long as Bluetooth is not actively connected. Refer to the LD2410 PlatformIO Example for a complete implementation using the PlatformIO environment.
MicroPython Example
from machine import UART
import time
# Initialize UART2: TX=17, RX=16, baud rate 256000
uart = UART(2, baudrate=256000, tx=17, rx=16)
# Function to read and print data from LD2410
def read_ld2410():
while True:
if uart.any():
data = uart.read()
if data:
print(data)
time.sleep(0.1)
read_ld2410()
LD2410B supports the same UART communication protocol as the original LD2410, making it fully compatible with existing MicroPython code. You can use the same UART setup (TX=17, RX=16, baudrate=256000) and raw data reading scripts. Note that BLE should not be active while using UART. For the base script and driver link, see the MicroPython section of the LD2410 documentation.
Conclusion
The ESP32 LD2410B Human Presence Sensor is a powerful Human Presence sensor that offers excellent performance and reliability. With support for multiple development platforms including Arduino, ESP-IDF, ESPHome, PlatformIO, and MicroPython, it's a versatile choice for your IoT projects.
For optimal performance, ensure proper wiring and follow the recommended configuration for your chosen development platform.
Always verify power supply requirements and pin connections before powering up your project to avoid potential damage.