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:
http://reactancelabs.com/?p=293
http://hackaday.com/2014/06/14/the-first-arduino-radar-shield/
But they’re quite big, because of their antennas.
The XeThru module fits in my hand:
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.
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.
Pitfall:
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….
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.
navidad says
Great tutorial! too bad, this little device costs 400$… which is too expensive, in my opinion. There are board based on HB 100 Microwave Sensor Module, at around 4$ that can detect movement through walls
admin says
I don’t know the HB 100 sensor. But I think it’s a lot less sensitive. I doubt that you can measure breathing with it. But yeah, the price difference is a bit high at the moment. But WiFi modules were also pricey a few years ago, and now you can find them for $5 =)
Oyvind
zert says
Do you have tested the device through walls ? Does it still work ?
Given that the X4M200 uses EM that can go through wall , that could be possible, depending on the frequency used.
admin says
Yes, it can work. But it depends on the material of the wall.
Best,
Oyvind
CHOUAIBOU NSANGOU says
Hi Oyvind,
What is the reference of the usb communication board and where to find it ?
Best regards,
Chouaibou NSANGOU.
admin says
Hi,
The USB communication board is custom made by XeThru. But their newer boards don’t need an external communication board.
Best,
Oyvind
Herman Bergwerf says
From the specs of the X2M200 sensor it should be able to feed it 5V (directly from the Arduino) and use a 3.3V to 5V level shifter for communication, is that right?
Thanks :-)
admin says
That sounds right, yes. I haven’t worked with this in a while though, so double check what I say ;)
Nanaui Amoros says
Hello Øyvind, great tutorial!
Do you know if it would work with the new X4M200 respiration sensor?
Thanks!
admin says
Hi Nanaui,
Thanks =)
I think the protocol should be the same, and in that case it should work. But I haven’t used that chip, so I can’t make any promises :)
Oyvind
Nanaui Amoros says
Thanks! I will try it!!
luanty says
Hi, I’d like to know if the USB communication board is included in the Rader or is needed to buy it in other ways.
admin says
Hey, they have different products with different features. Check out their webshop for the latest updates: https://www.xethru.com/shop/
Best,
Oyvind
Karen says
Such a great project and tutorial! I would like to ask what if there are multiple people in the same room? Will it pick up messy data?
admin says
Thanks =)
It could. But it all depends on how you process the data. The radar outputs raw radar data, which is lots of pulses, then you have to create algorithms to process it.
Detecting two persons breathing, could be easy or it could be hard, depending on their position and if they are moving a lot.
Best,
Oyvind
Sai Jyothi says
Hi,
At the beginning of the code, you mentioned that the definitions are for Arduino mega board what changes should I make for other Arduino boards and where can I find the reference for performing the same.