Custom sensor using NodeMCU and RCWL-0516 [Solved]

Hi,

I am trying to make my own motion sensors using NodeMCU & RCWL-0516 sensors and did following steps:

  1. On a breadboard connected a FTL card set to 5V

  2. Connected NodeMCU as follows:
    a. VIN to 5V from FTL card
    b. GND to GND from FTL card
    The flashed NodeMCU works and I can access the webGUI and set the template to “Generic(18)”

  3. Connected RCWL-0516 as follows:
    a. VIN to 5V from FTL card
    b. GND to GND from FTL card
    c. OUT to D1 pin on NodeMCU (GPIO5)

  4. In webGUI for Tasmota I set GPIO5 to “Switch(1)” and now can see “Switch=ON” in the console

But if I leave it alone or move away from the board and then it should show “Switch=OFF” as there is no motion occurring but it stays 'Switch=ON" all the time.

Did I miss anything in the configuration or did it incorrectly?

3 Likes

Surely it is a sensor, not a switch.

It is treated as a switch as it reports motion(1) or motion(0) states.

Here is more explanation - RCWL-0516 microwave radar motion sensor - Tasmota

But unlike this example, I just keep seeing “Switch1=ON” all the time!

OK I see now, a strange way of describing a sensor (as a switch!) but I guess that is the tasmota way.

You do realise these things usually detect motion/presence up to 7m?

Perhaps a pullup resistor or something is needed?

1 Like

Thanks @nickrout, I saw few other DIY tutorial and they all used a pull up resistors so perhaps that is the next step. I am also thinking that might as well add a bypass capacitor at the same time while I am ordering resistors on Amazon.

yes I am aware of the range so left the setup in a room and went far away for few minutes but console did not log anything different when I was away.

I am using this sensor with ESPHome, and made 2 small tweaks to make it detect motion better:

  • 1mF capacitor between VIN and GND on the RCWL-0516 board.
  • 10kΩ resistor between OUT and GND.
2 Likes

@exxamalte appreciate adding your input!

In my case I want to add this motion sensor to a light in my home office so that if I walk into office past sunset, the light should come on. The RCWL-0516 seems to have good sensitivity to get the job done but there is a problem with my setup. The wall which has the power socket, behind this wall is a toilet which is not connected or accessible from my office.

So if there is motion in the toilet then RCWL-0516 would still get activated as it works on doppler which can penetrate through the wall. So I am contemplating adding a HC-SR501 to the NodeMCU board as there are free GPIOs. Since HC-SR501 is direction sensitive (in front), taking a boolean from both the sensors would make the motion detection restricted to office space.

So two questions comes to my mind:

  1. Is the logic for adding RCWL-0516 & HC_SR510 correct?
  2. Would HC-SR501 also need a bypass resistor and a balance capacitor the same way as you described above?

Thanks.

PS: I am still waiting for resistors, capacitors and HC-SR501 to arrive so cannot test my premise.

Wouldn’t a pir solve the problem?

Yes HC-SR501 is a PIR sensor. In the comments section of few of the DIY tutorials for motion sensors, folks mentioned that combing HC-SR501 with RCWL-0156 gives much more reliable performance so was curious.

PS: here is a good video on both the sensor types and does a decent job of explaining the pros/cons - RCWL-0516 Microwave & HC-SR501 PIR Motion sensors | Tutorial with ESP32 and LoRa Project - YouTube

Sorry I was confusing with hc-sr04 which is an ultrasonic distance sensor

Thanks @nickrout & @exxamalte both PIR (HC-SR501) and RCWL-0516 are working like a charm for me now :sunglasses:

1 Like

Do you have a diagram of your connections? Maybe a picture of your device to see how you connected the capacitor and resistor? Thank you!

I did find some schematics, I am posting them here in case someone needs them.

I found them at: RCWL-0516 Microwave Motion Sensor - Let's Control It

1 Like

Sure, here you go:

5 Likes

Most boards (NodeMCU, D1 etc) have built-in pull up resistors and all you have to do is activate it - one less thing to solder!

Here is how I have done it using ESPHome:

binary_sensor:
  - platform: status
    name: ${name_of_board} Status
  - platform: gpio
    pin: 
      number: D2
      mode: INPUT_PULLUP
    name: ${name_of_board} Doppler
    id: doppler
    internal: true
    device_class: motion
  - platform: gpio
    pin: 
      number: D4
      mode: INPUT_PULLUP 
    name: ${name_of_board} PIR
    device_class: motion
    id: PIR

In the above code " mode: INPUT_PULLUP" would do the trick.

5 Likes

I’ve just set one of these up as an experiment. The problem in having is that it never seems to register as off. Even tucked away somewhere or if site.

1 Like

Put it in a metal box to test?

Or stick w/ the DFRobot. Which seems to have spoiled our expectations because it works so well :wink:

2 Likes

Yeah, the DFRobot one is definitely better. But I got 5 of these for £4.99 so it would be a shame to waste an opportunity to play!

I think it is actually working. It’s just even more sensitive

1 Like

Same here!! Just ordered 5 of them to play…

Andyjacobs you are always one step ahead of me, Nspanel you were there before me, now this… I’m going to start following you!!!

Can’t wait to receive them and see if it’s true that they detect movement even though walls :star_struck:

1 Like

Hello, it’s my first time sharing here
I am in the rcwl-0516 radar sensor project, I was able to make it work, I integrated it into esphome, however, home assistant does not recognize the entity, only the device

We might be able to help if you share the ESPHome device’s configuration. If the entity does work in ESPHome but not in Home Assistant, then it either isn’t correctly set up as a binary sensor in ESPHome, or you accidentally set the sensor as internal which prevents it to manifest itself in Home Assistant.