First steps with the RCWL 0516 radar switch

How to power up and communicate with the cheap RCWL-0516 radar sensor module

Similar projects worth following
The RCWL-0516 module can be bought at numerous online retailers on eBay and Aliexpress, as well as others. It's intended for lamps and wall lights, where it can turn them on when motion is detected, and turn them off after a short timeout. Short-range (~~5m) radar modules such as this one are an alternative to PIR (passive infra-red) modules. Despite it being a very wide-spread and cheap module, documentation is scarce.

The module's pinout seems to be:

  • 3V3 - module power supply
  • GND - common ground
  • OUT - outgoing light voltage
  • IN - incoming light voltage
  • CDS - light detect / module disable feature

As far as I can currently tell, it works something like this: if the CDS is not pulled low, the module will send out pulses and measure their return times. If a change in return times is detected (i.e. something in the path of the radio waves has changed position), it will connect the IN and OUT lines (most likely with a MOSFET). So if there's a light connected to the OUT line, and an external power source (4V - 28V) is connected to IN, it will light up. The OUT line will go low after a short period of time (a few seconds) if movement stops. Of course, GND lines must be connected together.

I'll need to experiment with it some more.


A test sketch for Arduino

ino - 776.00 bytes - 01/12/2017 at 20:49


  • 1 × RCWL-0516 Microwave Radar Sensor Module Can be bought from numerous online vendors at a price of $1-$2.
  • 1 × Arduino Of your favourite flavour
  • 1 × XY-FST 433 MHz ASK transmitter If you want to run the attached sketch literally

  • Either a pinout problem, or a sensitivity issue

    ivoras01/19/2017 at 19:59 3 comments

    The module's OUT line was high too often, as if it has a huge amount of noise, so I Googled a bit and found a video by a Russian guy, who only connects the VIN, OUT and GND, ignoring the 3V3 pin. So I've also done that, connecting VIN to 5V, and it *seems* to be more stable. I'll leave it running for a while so I'll collect more data. If someone knows Russian enough to verify what he was doing, please write up some info in the comments.

View project log

Enjoy this project?



Michdo93 wrote 07/29/2020 at 18:45 point

Here the Python equivalent code for Raspberry Pi

import os
import sys
import getpass
import time
import pigpio
import RPi.GPIO as GPIO

# #include <VirtualWire.h>

env=os.path.expanduser(os.path.expandvars('/home/' + getpass.getuser() + '/lib'))
sys.path.insert(0, env)

import piVirtualWire.piVirtualWire as piVirtualWire

PIN_RADAR = 4 # #define PIN_RADAR 2
PIN_TX = 17 # #define PIN_TX 9
# PIN_LED = 13 # #define PIN_LED 13 # print instead

# void setup()
baud_rate = 1000 # baud rate instead of bps connection speed


# not needed
# pinMode(PIN_LED, OUTPUT);

pi = pigpio.pi()

# vw_set_tx_pin(PIN_TX); # and
# vw_setup(6000);
tx = piVirtualWire.tx(pi, PIN_TX, baud_rate)

rv = -1 # int rv = -1; # "unused"

# void loop()
while True:
#print("PIN_LED would be HIGH if you want to use it")
# GPIO.output(PIN_LED, GPIO.HIGH) # LED on # digitalWrite(PIN_LED, HIGH);
v = GPIO.input(PIN_RADAR) # int v = digitalRead(PIN_RADAR);

if(v != rv):
rv = v
# char msg[20];
# sprintf(msg, "R %lu %d", millis() / 1000, v);
msg = "R %f %d" % (time.time(), v)
tx.put(msg) # vw_send((uint8_t *)msg, strlen(msg));
print(msg) # Serial.println(msg);
tx.waitForReady() # vw_wait_tx();
#print("PIN_LED would be LOW if you want to use it")
# GPIO.output(PIN_LED, GPIO.LOW) # LED off # digitalWrite(PIN_LED, LOW);

except KeyboardInterrupt: # press Ctrl + C to stop

  Are you sure? yes | no

Roy wrote 10/02/2017 at 21:59 point

OUT is digital logic high with motion. There is no point trying to use this with an analog input.

  Are you sure? yes | no

Roy wrote 10/02/2017 at 21:52 point

Throw away your Arduinos (not because it was then a great platform back in 2003) and stick any LED on OUT to GND. It is current limited (according to my tests) with the entire spectrum of LED, from Red to Blue, White and UV and none require a current limiting resistor. A single LED will show the status and then attach this OUT to a GPIO on a Raspberry Pi Zero W (wifi). Running node-RED I have my cat-detector logging time and date to a file, emailing and tweeting me at any motion.

My 80 yr neighbor was worried about people coming in her apartment upstairs, so I put a 'cat-detector' in a plastic box with a Pi0W powered by a USB power bank and left it (with her permission) just before she went away for a few days. I logged into the Pi with ssh and looked at the log file and gave her a printed report the moment I got emailed when she came home. Her departure data showed a final event and arrival a few days later with no other activity in between.

VIN is 4 to 28 volts, OUT is a logic 3.3 volt digital output on motion detection and GND of course. The confusing part is 3V3 which is a 100 mA voltage regulated output which can be used to power external devices only.

I put a load resistor on 3V3 for 100 mA and increased VIN from 5 to 16 volts and got stable regulated voltage out, but it got hot beyond specs at 16 v for a full load. Below 5 v it was not able to regulate at full load. Consider this a very inexpensive freebee but ignore 3V3 if you don't need to power anything else.

Also ignore the CDS (CaDmium-Sulfide) and added LDR photocell, input and just let it float, the intent is to inhibit the OUT signal at light/dark, who cares, it is a very stupid feature (or bug) and does not shut off the RF transmission as the thing draws 3.15 mA irregardless. (not a word :D)

If you want to control the RF output then drive the sensor VIN from a transistor (4 volt minium, better 5) and allow at least 10 seconds for the device to stabilize on powerup.

The device is at the very lowest limits of S band microwaves (upper UHF) and is not radar as an object-detection system that uses radio waves to determine the range, angle, or velocity. All it does is detect reflections or interference between out and in and eventually turns on OUT by internal analog circuitry. It can not be used to detirmine distance, velocity or whatever but relative motion of an incoming cat or lion. Luxury!

sign up to view photos.

If you want the latest inexpensive systems then buy an STM8S103 MINDEV board, a TTL UART dongle for console I/O, a one-time USB Programmer, an RCWL-0516 and get the latest free eForth software from:

  Are you sure? yes | no

chupo_cro wrote 08/31/2017 at 20:47 point

3V3 is not module power supply, it is 3.3 V OUTPUT. Module power supply is IN (4 - 28 V) and you get 3.3 V at OUT pin when the module detects motion. You can use 3V3 pin as power supply for something requiring 3.3 V.

  Are you sure? yes | no

Tachyon wrote 07/12/2017 at 23:58 point

Hey, just wanted to point out the similar efforts going on at:

Maybe you could contact that maintainer and collaborate?

  Are you sure? yes | no

kidddrock wrote 05/02/2017 at 14:54 point

Sorry - I was changing a few items, this one works:

int sensorPin = 8; 
int ledPin = 3; 
int motion; // Variable to read detection of movement

void setup() {
  pinMode (sensorPin, INPUT); 
  pinMode (ledPin, OUTPUT); 
void loop() {
  motion = digitalRead(sensorPin); // Read digital OUT value
  if(motion == 1){ // motion is detected
    digitalWrite(ledPin, HIGH); // light up LED
    Serial.println("MOVEMENT DETECTED"); //print to serial
    digitalWrite(ledPin, LOW); // No motion, so LED is off
    Serial.println("NO MOVEMENT DETECTED"); //print to serial

  Are you sure? yes | no

kidddrock wrote 04/30/2017 at 15:38 point

To follow up on this, these sensors are pretty sweet for how inexpensive they are..  Basically all I had wrong initially was to read the OUT digitally instead of analog and it works great.  No resistors, quite sensitive, and less dense objects won't prevent detection.  All you need is 3 wires, Vin (Supply), Gnd (Ground), and OUT (Output indicating motion), really simple -- here's my script, if this helps: 

const int sensorPin = 8; 
const int ledPin = 3; 
int motion; // Variable to read detection of movement

void setup() {
  pinMode (sensorPIN, INPUT); 
  pinMode (buzzerPIN, OUTPUT); 
void loop() {
  motion = digitalRead(sensorPin); // Read digital OUT value
  if(motion == 1){ // motion is detected
    digitalWrite(ledPIN, HIGH); // light up LED
    Serial.println("MOVEMENT DETECTED"); //print to serial
    digitalWrite(ledPIN, LOW); // No motion, so LED is off
    Serial.println("NO MOVEMENT DETECTED"); //print to serial

  Are you sure? yes | no

kidddrock wrote 04/24/2017 at 23:46 point

After reading some on these, I think I strongly over-simplified their operation... I'm sort-of new to tinkering, so not surprised.  At least I've seen enough to say they're working.  I believe we'll need to incorporate some resistors/capacitors to fine tune the sensing.

  Are you sure? yes | no

kidddrock wrote 04/24/2017 at 22:38 point

It doesn't seem to pick up motion/movement like I expect, however if I pick up the breadboard it's attached to and move it - I get a clear change in readings.  It looks like I'm getting between 0-1023 from the OUT pin, so I set 600 as my trigger to turn an led on - this is working at least to indicate the sensor is moving so far (I also haven't soldered the pins yet, just have the sensor sitting on the pins).

  Are you sure? yes | no

kidddrock wrote 04/24/2017 at 22:05 point

I purchased some of these and there's a bunch of documentation on the site.  For reference, here's the link:

It appears the 3.3v is maybe to power another controller, but not needed in this sensor's use.  It seems to follow other sensor's in that Vin and GND power the sensor, OUT gives you the reading to indicate motion, and the CDS is used to power (or trigger) sensing.  That said, I just threw mine in a breadboard and am testing with an Arduino nano - I'm getting analog readings from OUT, but they don't appear to be very consistent yet.

  Are you sure? yes | no

Euler Oliveira wrote 04/24/2017 at 09:51 point


I wrote one article about this sensor:

I put many details on the plate. I have done many researches and tests to write this article.

It's in Portuguese because I'm from Brazil. (Use Google Translate).

I hope you can help everyone.

  Are you sure? yes | no

Arie wrote 02/22/2017 at 09:31 point

I think Yann is close, but it's not Doppler but reflections of the radio wave changing the oscillator operating point. Just like the radio fuses in the WW2 bombs, see

  Are you sure? yes | no

darth_llamah wrote 01/20/2017 at 09:33 point

If I'm right- Russian is not my native language- the module worked reliably on 3.3V from Arduino only if nothing else draw power from that line.

  Are you sure? yes | no

Yann Guidon / YGDES wrote 01/13/2017 at 04:35 point

Some more there :

BTW I don't think it sends pulses, it's probably a CW (Continuous Wave) that receives reflected signal. When the object moves, Dopler effect shifts the frequency. This frequency shift is measured by subtracting the reflected and the emitted wave, which should create a low-frequency signal, which is then decoded...

I'm trying to find more informations because these are usually microwave systems that are pretty interesting...

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates