Browse over 10,000 Electronics Projects

Arduino Radar Tutorial: Fading an LED With My Breath

Arduino Radar Tutorial: Fading an LED With My Breath

I built this Arduino radar project, where I control the brightness of an LED with my breath. In this tutorial, I will show you exactly how to do it.

It was an experiment to get the XeThru radar to work with Arduino. I plan to expand on this later, and build more useful applications.

And I will share with you how to connect the hardware, and how to create the Arduino code.

Just to be clear: This is not a sonar pretending to be a radar. This is a radar. With electromagnetic waves.

The Hardware

XeThru is a radar module from Novelda. You can use it to detect movement in a room, and even measure the breath of a person, without contact.

Since it’s using electromagnetic waves, you could build it into your wall or some other object, to create an invisible intruder alarm sensor.

For example:

You could build it into an alarm clock, and place it on your night stand. Without anything connected to your body or your bed.

Then it would monitor your breathing pattern, and your movements throughout the night. This information can help you understand the quality of your sleep. Are you getting the sleep cycles you need?

Or, you could build it into a handheld device for the police. They can place it on a door to see if there is anyone in the room before entering.

There are other radars available, like these:

But they’re quite big, because of their antennas.

The XeThru module fits in my hand:

XeThru Radar Module

How To Connect

You control the XeThru radar module with two UART pins.

I used an Arduino UNO, with an RGB LED and three 100 Ohm resistors.

The module uses 2.8V levels. Since my Arduino use 5V levels, I needed a voltage level converter. Other than that, it was pretty straight-forward.


Circuit diagram for the arduino radar

The level shifter I used, was a BSS138 board from Tinkersoup here in Berlin.

To make it work, I also needed a 2.8V supply. Luckily, the USB-module for the XeThru radar has a 2.8V supply pin that I could use.

I spent a lot of time scratching my head in the beginning. I didn’t get any response from the radar! The reason was that I had forgot to connect the ground….

Arduino radar on a breadboard

Writing Code for the Arduino Radar

From the documentation of the serial protocol of the radar, I found out how to get the radar to send me respiration data:

-Reset the radar
-Load an app
-Set configurations (if any)
-Start the app

In the beginning, I had some problems. I just didn’t get any respiration data from the radar. After discussing the problem on the XeThru forum, I found that I had the wrong byte order for the application code.

I fixed that, and data came streaming in!

Type Conversion

Another thing I was struggling with, was type conversion. And with only an RGB LED as my output, it was a bit hard to debug. So I connected another Arduino with SPI, that I could use as a debugging console for a while, and got the type conversion sorted out.

I parsed the data that was coming in, and used the movement-value to set the brightness of the LED. This way, the LED faded in and out with the tiny movement of my body when breathing in and out.

Really cool to experience!

The Arduino did not process the data fast enough, so I also added a function to empty the buffer and sync the data for every time I fetched a new measurement. This way, I always got fresh data.

I’ve created a github repository for the arduino radar code, where you can find the latest version of the code. The plan is to turn it into a proper Arduino library for the XeThru radar.

Click here to see the code I used in the beginning.

What’s next?

Next up, is to create a useful device with the arduino radar. I’ll be sharing my experiences, code and hardware connections on my blog and newsletter.

Sign up below to get updates.

Copyright Build Electronic Circuits