For most of our Arduino projects that require knowing if someone has left or entered the area, the PIR sensor is an excellent choice. However, because they only detect movement from living things, they will generate fewer false alarms.
This is where a microwave sensor like the RCWL-0516 comes in handy. The RCWL-0516 microwave sensor detects any movement from any object and does not rely on heat signatures, making it more reliable in hot environments where a PIR sensor may not be as effective.
Before going into the nitty-gritty, let’s first understand how the RCWL-0516 sensor actually works.
How does Doppler radar work?
The RCWL-0516 module employs “Doppler Radar” – a specialized radar that makes use of the Doppler Effect (also known as Doppler shift) to detect motion and trigger proximity alerts.
What is the Doppler effect?
The Doppler effect, named after the Austrian physicist Christian Doppler who proposed it in 1842, describes the change in frequency observed by a stationary observer when the source of the frequency is moving. This holds true for all sorts of waves, such as water, light, radio, and sound.
This effect is something you’ve heard many times, perhaps without even realizing it, of the siren dropping in pitch as an ambulance passes by.
As the ambulance approaches you, the sound waves from the siren are squeezed into a shorter distance, increasing their frequency, which we hear as a higher pitch. The opposite happens when the ambulance moves away from you, causing the sound waves to become lower in frequency and lower in pitch. As a result, you hear a noticeable drop in the siren’s pitch as it passes.
A Doppler radar works by bouncing a microwave signal off a desired target and reading the frequency of the returned signal. By analyzing how the target’s motion has altered the frequency of the transmitted signal, the target’s velocity can be measured.
You may have seen police officers using radar speed guns to catch people driving too fast. These radar speed guns, like other types of radar, consist of a microwave transmitter and receiver. They send out a microwave signal and then receive it after it bounces off the target.
Due to the Doppler effect, if the object is moving towards or away from the gun, the frequency of the reflected microwave signal is different from that of the transmitted signal.
When a car approaches the radar, the frequency of the returned signal is greater than the frequency of the transmitted signal; when the car moves away, the frequency is lower.
Based on that difference, the radar speed gun calculates the speed of the car from which the signal bounced.
The RCWL-0516 Hardware Overview
The RCWL-0516 is an active sensor, not a passive one like the HC-SR501 Passive Infrared (PIR). It sends out microwaves at a frequency of about 3.18 GHz and measures the radiation that is reflected back.
The RCWL-0516 itself is pretty straightforward and works out of the box. Simply apply power between 4V–28V and ground. The sensor output goes HIGH for two seconds when motion is detected and goes LOW when idle (no motion detected).
And the best part is that it can detect motion up to 7 meters away while only consuming less than 3 mA of current.
RCWL-9196 IC
At the heart of the sensor is a doppler radar controller IC – RCWL-9196. This IC is very similar to the BISS0001 IC that is used in PIR sensors.
The chip also supports repeat triggers and has a 360-degree detection area without blind spots.
Microwave Antenna and RF Power Amplifier
At the heart of the RF circuitry is a MMBR941M RF power amplifier. It takes a low-power RF signal and boosts it to a higher power level. Typically, this RF power amplifier drives the sensor’s antenna.
Because the microwave antenna is integrated on the PCB itself, the RCWL-0516 has become a completely self-contained unit.
Power
The RCWL-0516 uses less than 3 mA of current and works between 4 and 28 volts, making it an ideal component for a battery-powered design.
In addition to this, it features a 3.3V voltage regulator that can supply up to 100 mA of current to power external circuits.
Technical Specifications
Here are the specifications:
Operating Voltage | 4-28V (typically 5V) |
Detection Distance | 5-7 meters |
Maximum Current Draw | ~ 2.7mA |
Operating Frequency | ~3.18GHz |
Transmission Power | 30mW (max.) |
Signal length | ~ 2s |
Regulated Output | 3.3V, 100mA |
Optional Component – LDR
The RCWL-0516 also has support for an optional light-dependent resistor (LDR), which enables the device to operate only in the dark. This is useful for building motion-sensitive lighting systems.
There are actually two ways you can connect an LDR to the sensor.
- By using the two CDS pads on the top of the sensor.
- By using the CDS pin on the bottom and connecting your LDR between it and ground.
What does CDS stand for?
CDS stands for cadmium sulphide, which is the photoactive component in the majority of LDRs. Because of this, LDRs are sometimes called CDS photoresistors.
RCWL-0516 Jumper Settings
If you look closely at the module, you’ll notice three solder jumpers on the back.
By populating these jumpers with appropriate resistors and capacitors, you can change the sensor’s default settings:
C-TM (Pulse length Adjustment): By populating C-TM with a suitable SMD capacitor, you can extend the output pulse length. The default pulse length is 2 seconds. Higher capacitor values result in longer pulses. For example, 0.2µF extends the output pulse to 50s, while 1µF extends it to 250s.
R-GN (Detection Range Adjustment): By populating R-GN with a suitable resistor, you can reduce the sensor’s detection range. By default, the detection range is set to 7m. A 1M resistor reduces the detection range to 5m, while a 270K resistor reduces it to 1.5m.
R-CDS (Light Sensitivity Adjustment): This is an alternative to soldering the LDR. Any resistor in the 47K – 100K range will suffice. The lower the value, the brighter the light must be in order to disable the trigger.
RCWL-0516 Sensor Pinout
The RCWL-0516 sensor brings out the following connections:
3V3 is the output from the onboard 3.3V regulator, not the power supply input. If you need a clean 3.3V output to power external logic circuitry, you can use it. It can provide up to 100mA of current.
GND is the ground pin.
OUT pin is the 3.3V TTL logic output. It goes HIGH for two seconds when motion is detected and goes LOW when idle (no motion detected).
VIN is the power supply for the sensor. You can connect an input voltage anywhere between 4 to 28V to this pin, although 5V is commonly used.
CDS pins are where you can attach a light dependent resistor (LDR). Adding this component allows the RCWL-0516 to operate only in the dark.
Experiment 1: Using the RCWL-0516 Sensor as a Standalone Unit
One of the reasons why the RCWL-0516 sensor is extremely popular is that it is a very versatile sensor that is quite capable on its own. You can increase its versatility even further by connecting it to a microcontroller like an Arduino.
For our first experiment, we’ll use the RCWL-0516 to show how useful it is on its own.
The wiring for this experiment is very simple. Connect the batteries to the sensor’s VIN and GND and a small red LED to the output pin via a 220Ω current limiting resistor. That’s all!
Now when the RCWL-0516 detects motion, the output pin will go “HIGH” and light up the LED!
You can connect this output directly to the relay module if you want to turn something ON/OFF based on motion.
Radar signals can penetrate non-conductive materials such as plastic. This means you can place one of these sensors inside a plastic enclosure if you want to hide it or protect it from accidental damage.
Experiment 2: Adding an LDR
For our next experiment, we will be using an LDR (or Light Dependent Resistor).
It’s very easy to hook up an LDR. You can either use the two CDS pads on the top of the sensor made specifically to attach the LDR, or use the CDS pin on the bottom and connect your LDR between it and ground.
You may use any LDR that you can get your hands on. Also, LDRs don’t have polarity, so you can connect them in any direction you want.
When the LDR is exposed to light, you will notice that the sensor produces no output. However, once the room is darkened, it resumes normal operation.
This has several real-world uses, such as controlling room lighting or spotting intruders at night.
Experiment 3: Reading RCWL-0516 with an Arduino
In our next experiment, we will use Arduino to poll the sensor pin continuously to see if it has detected any motion.
This project may, of course, be expanded to respond to motion in a variety of ways, such as turning lights on and off, activating a fan or a Halloween prop, or even taking a picture of an intruder.
Wiring
Connecting the RCWL-0516 sensor to the Arduino is really simple. Power the RCWL-0516 with 5V and connect ground to ground. Because the RCWL-0516 functions as a digital output, all you need to do is listen to the output pin. So connect the output to the digital pin #8 on the Arduino.
Now you are ready to upload some code and get the RCWL-0516 working.
Arduino Code
The code is very simple. It basically just keeps track of whether the input to pin #8 is HIGH or LOW.
int ledPin = 13; // choose the pin for the LED
int inputPin = 8; // choose the input pin (for Radar sensor)
int motionState = LOW; // we start, assuming no motion detected
int val = 0; // variable for reading the pin status
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare sensor as input
Serial.begin(9600);
}
void loop() {
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED ON
if (motionState == LOW) {
Serial.println("Motion detected!"); // print on output change
motionState = HIGH;
}
}
else {
digitalWrite(ledPin, LOW); // turn LED OFF
if (motionState == HIGH) {
Serial.println("Motion ended!"); // print on output change
motionState = LOW;
}
}
}
With the sensor pointing up, swipe your hand over the sensor. You should see a “Motion Detected” message printed on the serial terminal.