Custom sensor using NodeMCU and RCWL-0516 [Solved]

Hi, I have ordered 5 of these sensors. I am using a D1 mini and the RCWL sensor. I have soldered a 10 KOhm resistor between the sensor output and GND and have also included the 1 mF capacitor between the Vin and Gnd of the sensor. I am able to see my sensor in my Home Assistant, however, it shows “DETECTED” all the time. I have left it a day with an aluminum foil cover to see if it goes from “DETECTED” to “CLEAR” state, however, it does not change. The only difference I have with your diagram is that I am connecting the sensor output to my D1 pin. My code is as follows:

type or paste code here

esphome:
  name: presence-sensor-1

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "6be121c9fbc94c61d241c78c81d9cc48"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Presence-Sensor-1"
    password: "MwpiaTWoFAFo"

captive_portal:
binary_sensor:
  - platform: gpio
    pin: 1
    name: "Kitchen Sensor"
    device_class: motion
    #filters:
      #- delayed_on_off: 4000ms

Ah, I found the problem. The GPIO pinout is different. I did not realize that the pinout for D1 is GPIO5… I replaced the pin:1 to pin:5 and it worked fine!!! I hope my mistake can help others that might be having the same issue.

1 Like

pin: D1 would work just as fine, FYI.

The weird thing is that it did not allow me to put D1. But anyways :slight_smile: it is working now.

This is a working configuration for me for over one year now:

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

Also notice that you do NOT need to put a pull up resistor as D1-Mini board has a built in resistor which can be activated as shown above. Since you are not running a load like say a motor, not sure if balance capacitor is needed for a doppler/PIR motion sensor.

3 Likes

Hi All

I also have a problem, I connected the radar to nodemcu and the detection range is very short

Hi,

Just tested it. It does work, but the range is a few centimeters.
Any ideas?

Thanks.

Here are the specs of the board, there is nothing to tweak for range and also likely that your board may be defective - have you tried another one?

@PanMat , I have seen the specs.
Didn’t try another board.
A question regarding sensor’s behavior.
Should it report motion as long as it detects an object (lets say a person) or detect and report not detected after two seconds?
And another question regarding its “beam” width?
It detects in a straight line, almost no width. Is that correct?
Thanks.

I’m also experimenting with the rcwl-0516 sensor and my findings are:

As long it detects movement of a object big enough the signal stays high. The default re-trigger time is 2 seconds but can be adjusted in esphome easily.

The datasheet claims something like 360° but it’s less sensitive on wards the edges and one side of the pcb (“the front”) is a bit more sensitive.

No

You are welcome :+1:

Last I experimented, there was a blind zone of about 20 degrees or so in the plane of the board but otherwise it detected almost 160 degrees field of view.

Hope you know that doppler sensors can detect motion through walls and other obstructions. This is a double edged sword and can have adverse effect on its intended utility.

@Tarrus @PanMat Thank you very much for the detailed response.
Obviously, my module does not act as it is supposed to act.
I will try to replace with another sensor and update whether there is a change in behavior.

Just replaced the sensor, it works exactly as the first one.
I have tried to add a 10 ohms resistor in series to a capacitor sitting on vin-GND pins (1mF), same behavior.
Any thing else I could try, or this is just the quality of this sensor?

I also bought 5 of these boards and I have the same problem - range of just a few centimetres.

How is it wired?

Wiring is pretty simple.
Supply of 5V (for the testing supplied via USB).
1mF capacitor in the VIN and GND pins of the sensor (tried also via a 10 ohm resistor, same result).
Output pin is wired to the D1 Mini D6.
Tried to play with the pull-up setting of the port, same result.
The detection does work, but works as a motion sensor, not as a radar sensor.
Meaning, it reports motion when I close it with my finger, and back to no motion after 2 seconds.
The distance is very small as well, nowhere near the 7 meters.
Beam width is very narrow as well.

The thread suggests supplying the rcwl with a higher voltage might increase the range.

Had some spare time today.
I have fed the sensor with 24V.
Exactly the same result, no change.

1 Like

I am not sure if that can help but I read somewhere that those sensors need at least 15" wires between the sensor and main circuitry

@PanMat , so if I have just the RCWL-0516 I need to use this one:

binary_sensor:
  - platform: gpio
    pin: 
      number: D2
      mode: INPUT_PULLUP
    name: ${name_of_board} Doppler
    id: doppler
    device_class: motion

Or do I have to use the both codes? I mean the doppler and PIR lines at the same time progamming