Millimeter-wave (mmWave) sensors are advanced radar-based sensing devices that operate in the 30 GHz to 300 GHz frequency range. Unlike traditional motion detection technologies such as infrared (PIR) or ultrasonic sensors, mmWave sensors use radio waves to detect objects, motion, and even micro-movements (like a heartbeat) with high precision.
These sensors can distinguish between static and moving objects, detect motion at different distances, and provide real-time data about detected targets. Intelligent automation based on motion presence, rather than just movement alone, is ideal for home automation, security, and smart lighting.
What You'll Build
A presence detector with a visual indicator light.
Prerequisites
A computer with MacOS, Windows, or Linux to flash your Raspberry Pi and configure the device's components using the Viam app
1 - optional: solder, heat shrink tubing, and electrical tape
1 - optional 3-D printed (or store bought) enclosures for the sensor and LED
What You'll Need
All the hardware components listed in prerequisites.
Sign up for a free Viam account, and then sign in to the Viam app
What You'll Learn
How to configure and test hardware components using Viam
How to configure and test a service using Viam
How to use modules from the Viam registry
Watch the Video
See a demonstration of detecting presence in this video.
The Raspberry Pi boots from a USB flash drive (or microSD card). You need to install Raspberry Pi OS on a USB flash drive that you will use with your Pi. For more details about alternative methods of setting up your Raspberry Pi, refer to the Viam docs.
Install Raspberry Pi OS
Connect the USB flash drive (or microSD card) to your computer.
Click CHOOSE DEVICE. Select your model of Pi, which is Raspberry Pi 4.
Click CHOOSE OS. Select Raspberry Pi OS (64-bit) from the menu.
Click CHOOSE STORAGE. From the list of devices, select the USB flash drive you intend to use in your Raspberry Pi.
Configure your Raspberry Pi for remote access. Click Next. When prompted to apply OS customization settings, select EDIT SETTINGS.
Check Set hostname and enter the name you would like to access the Pi by in that field, for example, test.
Select the checkbox for Set username and password and set a username (for example, your first name) that you will use to log into the Pi. If you skip this step, the default username will be pi (not recommended for security reasons). And specify a password.
Connect your Pi to Wi-Fi so that you can run viam-server wirelessly. Check Configure wireless LAN and enter your wireless network credentials. SSID (short for Service Set Identifier) is your Wi-Fi network name, and password is the network password. Change the section Wireless LAN country to where your router is currently being operated.
Select the SERVICES tab, check Enable SSH, and select Use password authentication.
Save your updates, and confirm YES to apply OS customization settings. Confirm YES to erase data on the USB flash drive. You may also be prompted by your operating system to enter an administrator password. After granting permissions to the Imager, it will begin writing and then verifying the Linux installation to the USB flash drive.
Remove the USB flash drive from your computer when the installation is complete.
Connect with SSH
Place the USB flash drive into your Raspberry Pi and boot the Pi by plugging it in to an outlet. A red LED will turn on to indicate that the Pi is connected to power.
Once the Pi is started, connect to it with SSH. From a command line terminal window, enter the following command. The text in <> should be replaced (including the < and > symbols themselves) with the user and hostname you configured when you set up your Pi.
ssh <USERNAME>@<HOSTNAME>.local
If you are prompted "Are you sure you want to continue connecting?", type "yes" and hit enter. Then, enter the password for your username. You should be greeted by a login message and a command prompt.
Update your Raspberry Pi to ensure all the latest packages are installed
sudo apt update
sudo apt upgrade
Add your RGB LED
Review the wiring diagram: The LED can be controlled via a GPIO pin on the Raspberry Pi. Refer to the following wiring diagram to see how to connect the Raspberry Pi to the RGB LED, using the breadboard and also resistors to control the flow of electricity.
Board
RGB LED
Pin 12 (GPIO 18)
Blue leg
Pin 32 (GPIO 12)
Green
Pin 33 (GPIO 13)
Red
Pin 34 (GND)
Common
Review the LED orientation: A common cathode RGB LED has four legs:
Common Cathode (GND): The longest leg should be connected to ground.
Red (R): Typically the leg next to the common cathode (to the left as shown below).
Green (G): The leg on the other side of the cathode (to the right as shown below).
Blue (B): The farthest leg from the cathode.
Wire the RGB LED to the Raspberry Pi: The breadboard simplifies the wiring process by providing a secure platform to connect components without soldering. Connect the longest leg of the LED (common cathode) to the ground (GND) pin (physical pin 34) on the Raspberry Pi. Then, connect the red, green, and blue legs of the LED to resistors (68Ω for red, 10Ω for green, and 10Ω for blue). These resistors should then be connected to pins 33, 32, and 12, respectively. Double-check connections to ensure correct polarity and avoid miswiring.
Add your LD2410 mmwave sensor
Connect the CP2102 serial adapter: Plug the adapter into the USB-A port of the Raspberry Pi.
Wire the LD2410 sensor to the adapter: Refer to the following wiring diagram to see how to connect the adapter to the LD2410 mmwave sensor. Make sure the transmitting pin (TX) on the adapter is connected to the receiving pin (RX) on the sensor, and vice versa. Refer to the sensor product specifications for additional details.
CP2102
LD2410
Transmitting (TXO)
Receiving (RX)
Receiving (RXI)
Transmitting (TX)
Power (+5V)
VCC
Ground (GND)
GND
Now that you have physically connected the hardware components, let's configure the software in the next section.
Configure your machine
In the Viam app under the LOCATIONS tab, create a machine by typing in a name and clicking Add machine.
Click View setup instructions.
To install viam-server on the Raspberry Pi device that you want to use to communicate with and control your webcam, select the Linux / Aarch64 platform for the Raspberry Pi, and leave your installation method as viam-agent.
Use the viam-agent to download and install viam-server on your Raspberry Pi. Follow the instructions to run the command provided in the setup instructions from the SSH prompt of your Raspberry Pi.
The setup page will indicate when the machine is successfully connected.
Configure your Raspberry Pi board
To access the GPIO pins, let's add our Raspberry Pi board to our machine in the Viam app.
Click the + icon in the left-hand menu and select Component.
Select board, and find the raspberry-pi:rpi4 module. This adds the module for working with the Raspberry Pi 4's GPIO pins. Leave the default name board-1 for now.
Notice adding this module adds the board hardware component called board-1. The collapsible card on the right corresponds to the part listed in the left sidebar.
Click Save in the top right to save and apply your configuration changes.
Expand the TEST section of the panel to experiment with writing to physical pin 12. For example, try setting a High signal.
Set the signal to Low (for each pin previously set to High) to turn off the LED.
You can manually and programmatically use the GPIO pins of the board component to send PWM signals to control your LED. However, to streamline the following steps, let's use a prebuilt module from the Viam registry in the next section.
Configure your RGB LED
In the Viam app under the CONFIGURE tab, click the + icon in the left-hand menu and select Component.
Select generic, and find the led:rgbled module. This adds the module for controlling your RGB LED. Name the component rgb-led.
Name the component rgb-led.
In the new rgb-led panel, configure your component by adding the following attributes in the CONFIGURE field. This tells your LED component to use specific pins on a specific board (called board-1 in the Viam app).
Click Save to apply your configuration changes. This may take a moment.
Since we are using a generic component, let's test it out under the CONTROL tab. Find your rgb-led component on this page. Expand the DO COMMAND field, input the following code, and hit Execute.
You are executing a DoCommand on a generic component that has been predefined to accept parameters within a control_rgb_led command, such as red, green, blue, and duration. With these values, red will be at 80% brightness, green at 50% brightness, blue at 20% brightness - displaying a pulsating mixed color for a total duration of 2 seconds.
Configure your mmwave sensor
In the Viam app under the CONFIGURE tab, click the + icon in the left-hand menu and select Component.
Select sensor, and find the mmwave:mmwave module. This adds the module for getting readings from your LD2410C mmwave sensor.
Name the component mmwave-sensor.
Click Save to apply your configuration changes. This may take a moment.
Expand the TEST section to view the readings detected by the mmwave sensor.
Now that we've connected and configured both the RGB LED and the mmWave sensor, let's program the LED to change color dynamically based on the sensor's detected states.
We've already learned how to use a prebuilt Viam module to work with hardware components. In the next section, we'll set up a presence detection service using a prebuilt Viam module that contains the control code for working with the hardware that we've already configured.
Configure the presence detection service
In the Viam app under the CONFIGURE tab, click the + icon in the left-hand menu and select Service.
Select generic, and find the presence-detector:mmwave-rgbled module. This adds the module for controlling the LED based on detected presence.
Name the service presence-detector.
In the new presence-detector panel, configure your service by adding the following attributes in the CONFIGURE field. This tells your presence detector service to use specific components within your Viam machine (identified by component names in the Viam app).
Click Save to apply your configuration changes. This may take a moment. The LED will display a ripple effect when the program begins.
Once the program begins, the LED should display the following colors according to the state detected by the sensor. You can view the logs under the LOGS tab for more details about what's happening behind the scenes, and the detected states as they correspond to the LED.
Now that your presence detector is working, it's time to tidy up our project so it's not a loose jumble of wires and parts.
Provide enclosures
Assemble an enclosure for the Pi: 3D print (or buy) an enclosure for your Raspberry Pi. I found an existing design that I liked to fit a Raspberry Pi 4 Model B that provides access to the GPIO pins. You can additionally modify an existing design to include a built-in mount for your sensor and LED.
Assemble an mmwave sensor enclosure: I found an existing design that I liked. Since the design had enough space to accommodate wires, I simply switched from female-to-male to female-to-female jumpers. You could also solder the connections if you wish. The enclosure includes a slot to securely slide the mmWave sensor into place, ensuring it is oriented correctly for detecting motion and presence.
Assemble an LED display: I found an existing design that I liked to contain the soldered LED and wires, and also function as a lamp shade to illuminate more surface area.
Position the sensor enclosure: If you're using presence detection for smart lighting, consider mounting the sensor in a case on the wall, ceiling, or a desktop enclosure. Position the sensor to best fit your automation needs. For example, if you want a light to turn on when someone enters a room, place the sensor above a doorway or in clear line of sight of the entrance for optimal detection.
Customize the detection lights
Configure colors: The presence-detector module accepts optional parameters to change the color of the lights to your liking. Update the configuration in the Viam app, by adding a color_attributes property, formatted like the following:
Use a different module: If you want to further customize the controller's logic, such as turning lights on when you enter a room and off when you leave, you can use a prebuilt module like this one, which works with a TP-Link Kasa smart plug. Alternatively, you can replace the presence-detector:mmwave-rgbled module by creating your own custom module
What you learned
How to configure and test hardware components using Viam
How to configure and test a service using Viam
How to use modules from the Viam registry
Advanced scenarios for this presence detector
At this point, you have configured and tested your presence detector and have a helpful visual indicator light. There are more possibilities to explore to enhance this project.
Alternative sensors: The LD2410C is only one type of mmwave sensor. Other mmwave sensors are designed for fall detection, sleep monitoring, or expansive exterior spaces.
Scale up using affordable boards: Manage a fleet of mmwave sensors throughout your home to automatically turn on (and turn off) lights throughout your home. To do this more cost effectively, you can migrate the project to an alternative board, such as an ESP32 or Raspberry Pi Zero W.
In addition to the project ideas mentioned above, consider other ways to continue your journey with Viam.
Real-world applications and projects for mmwave sensors
Providing high precision and reliability in a variety of environmental conditions, mmWave sensors are widely-used in industrial and home automation, safety, and real-time decision-making across multiple domains.
Smart Home & Security: mmWave sensors enhance motion detection and presence sensing in security systems, lighting automation, and fall detection for elderly care—working accurately even through walls or furniture.
Automotive & Transportation: Used in collision avoidance and blind-spot detection, mmWave sensors improve safety and efficiency in modern vehicles.
Healthcare & Medical Monitoring: These sensors enable contactless vital sign monitoring, tracking heart rate, respiration, and sleep patterns without requiring wearables.
Industrial & Robotics: In warehouses and manufacturing, mmWave sensors assist in object tracking, people counting, and automation workflows, helping robots navigate and interact safely with humans.