LD2412 Human Presence Sensor

View on Amazon
Overview
About LD2412 Human Presence Sensor
The HLK-LD2412 is a 24GHz FMCW radar sensor designed for human presence detection with a wide sensing angle of ±75° and a range up to 9 meters. It offers both UART communication and a digital output signal, and supports flexible power supply options (3.3V or 5V). This makes it highly adaptable for smart home, automation, and occupancy detection use cases.
Get Your LD2412
Prices are subject to change. We earn from qualifying purchases as an Amazon Associate.
LD2412 Specifications
Complete technical specification details for LD2412 Human Presence Sensor
📊 Technical Parameters
LD2412 Pinout
The **LD2412** is a 6-pin 24GHz mmWave radar with wide-angle detection and flexible power:
Visual Pinout Diagram

Pin Types
Quick Tips
**Interface**: UART (115200 baud),📡 **Technology**: 24GHz FMCW radar,👤 **Detection**: Human presence (stationary and moving targets),📏 **Range**: Up to 9 meters (longest in LD series)
**Field of View**: ±75° (widest in LD series),⚡ **Power**: Flexible - choose 5V or 3.3V (do NOT power both simultaneously),📊 **Pin Spacing**: 2.54mm (standard breadboard-compatible)
**OUT Logic**: 3.3V compatible, safe for ESP32 GPIO,🎯 **Applications**: Wide-area occupancy detection, smart lighting, security systems,⚠️ **Power Warning**: Only connect ONE power source (5V or 3V3), never both
Pin Descriptions
| Pin Name | Type | Description | Notes |
|---|---|---|---|
1 OUT | Communication | Digital presence output | 3.3V HIGH when presence detected |
2 TX | Communication | UART transmit | Sends data from sensor (connect to ESP32 RX) |
3 RX | Communication | UART receive | Receives commands (connect to ESP32 TX) |
4 5V | Power | 5V power input | Use either 5V OR 3V3 (not both) |
5 3V3 | Power | 3.3V power input | Use either 5V OR 3V3 (not both) |
6 GND | Power | Ground connection |
Wiring LD2412 to ESP32
To interface the **LD2412** with an **ESP32** for wide-angle presence detection via UART:
Visual Wiring Diagram

Connection Status
Protocol
Pin Connections
| LD2412 Pin | Connection | ESP32 Pin | Description |
|---|---|---|---|
1 5V (or 3V3) Required | 5V (or 3.3V) | Power supply (choose one voltage) | |
2 GND Required | GND | Ground | |
3 TX Required | GPIO16 (RX2) | Sensor transmit to ESP32 receive | |
4 RX Required | GPIO17 (TX2) | Sensor receive from ESP32 transmit | |
5 OUT Optional | GPIO18 | Digital presence output (optional) |
**UART2**: Use UART2 on ESP32 (GPIO16/17 are default UART2 pins)
**Baud Rate**: 115200 bps - must match in firmware configuration
**Power**: Choose either 5V or 3.3V (do NOT connect both)
**TX/RX**: Connect sensor TX to ESP32 RX, sensor RX to ESP32 TX
**OUT Pin**: 3.3V logic level, safe for direct ESP32 GPIO connection
**Wide Angle**: ±75° field of view provides excellent room coverage
**Long Range**: 9-meter detection range ideal for large spaces
**Breadboard**: 2.54mm pitch allows easy prototyping
LD2412 Troubleshooting
Common issues and solutions to help you get your sensor working
Common Issues
Issue: The ESP32 receives no data from the LD2412 sensor.
Ensure TX/RX lines are correctly wired. Check that only one power source (either 5V or 3V3) is connected. Confirm UART baud is 115200 and no conflicting components use the same UART.
Issue: The OUT pin never changes even when motion is detected.
Check power supply voltage. Try reinitializing the sensor with a UART command. Ensure OUT is not floating and that detection parameters are configured properly via UART.
Debugging Tips
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.
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
LD2412 Programming Examples
Ready-to-use code examples for different platforms and frameworks
#include <HardwareSerial.h>
#include "LD2412.h"
LD2412 radar;
void setup() {
Serial.begin(115200);
Serial2.begin(115200, SERIAL_8N1, 16, 17);
radar.begin(Serial2);
}
void loop() {
radar.read();
if (radar.presenceDetected()) {
Serial.println("Presence detected");
} else {
Serial.println("No presence");
}
delay(1000);
}This Arduino code uses the LD2412 library to communicate with the sensor over UART2 (GPIO16/17). It continuously polls for presence and prints the result to the Serial Monitor. The LD2412 library handles packet parsing and state tracking. See ginkel/LD2412 for library details.
external_components:
- source: "github://Rihan9/LD2412"
refresh: 0s
uart:
id: uart_bus
tx_pin: GPIO17
rx_pin: GPIO16
baud_rate: 115200
ld2412:
uart_id: uart_bus
binary_sensor:
- platform: ld2412
presence:
name: "LD2412 Presence"
sensor:
- platform: ld2412
distance:
name: "LD2412 Distance"This ESPHome configuration connects the LD2412 sensor using an external component from GitHub. UART2 is used at 115200 baud with GPIO16/17. It exposes presence detection as a binary sensor and measured distance as a sensor entity. Full documentation available at Rihan9/LD2412.
platformio.ini
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
ginkel/LD2412
monitor_speed = 115200main.cpp
#include <LD2412.h>
LD2412 radar;
void setup() {
Serial.begin(115200);
Serial2.begin(115200, SERIAL_8N1, 16, 17);
radar.begin(Serial2);
}
void loop() {
radar.read();
if (radar.presenceDetected()) {
Serial.println("Presence detected");
} else {
Serial.println("No presence");
}
delay(1000);
}This PlatformIO example communicates with the LD2412 radar using the LD2412 library. It initializes UART2, polls the sensor for presence detection, and logs results via Serial. Use GPIO16/17 for UART2, and install the library via PlatformIO Registry at ginkel/LD2412.
There is currently no official MicroPython driver for the LD2412. Developers may implement a custom UART parser based on the protocol in the datasheet.
Wrapping Up LD2412
The ESP32 LD2412 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.
Best Practices
For optimal performance, ensure proper wiring and follow the recommended configuration for your chosen development platform.
Safety First
Always verify power supply requirements and pin connections before powering up your project to avoid potential damage.
Ready to Start Building?
Now that you have all the information you need, it's time to integrate the LD2412 into your ESP32 project and bring your ideas to life!







