Preface:
I’ve already described in detail how to reduce the sensor range of the RCWL-0516 sensor by building it into a cardboard box, which is wrapped in a aluminum foil (Option 1). But I found another more advanced solution (Option 2) by replacing a specific resistor on the sensor with an adjustable trimmer resistor. This option requires some soldering, but thats’s not as difficult as it might appear. I also enhanced this tutorial with your feedback to have everything in one place.
Disclaimer: I’ll take of course no responsibility or liability, if anything breaks on your sensor, RPi or mirror. But I think this is a self-evident matter.
Like many of us, I have a PIR-Sensor installed on myMM to switch the display on and off and to save power while it is not in use.
For my MM i had an AM312 sensor mounted under the lower frame, bar pointing to the ground. That position was not ideal due to the limited viewing angle of 50 deg to the front. So I had to stand rather close to the mirror to switch the display on.
Further, such a PIR-sensors looks like an wart on the frame, especially when you have no real options to mount it unobstursively and it messes up the hole design.
While looking for an alternative, I stumbled over the RCWL-0516 microwave sensor, which detects motion via the Doppler principle. This sensor has following characterisics:
(more details here)
- it is rather small and thin and can be placed secretly everywhere inside the mirror
- very cheap (ca. 1-2€)
- easy to install with 3 pins
- works without any modifications with MMM-PIR-sensor module
- works through glass
- works omni-directional (360 deg)
- has a typical range of ca. 7m
But the last two bullets (omni-directional radiation and detection, long sensor range) are two issues you have to be aware of.
The RCWL-0516 works even through walls and can detect motions in adjacent rooms, which of course produces false positives and switches the display on when not desired.
So how to limit the range?
There are posibilities to replace the SMD resistor with a trimmer poti (200 Ohms and less) between GND and antenna as described here, but this requires some soldering skills as the SMD resistor is quite tiny.
Option1: The “Magic Box”:
I went a different way by putting the sensor in a small card box and wrapping some adhesive aluminum tape around it to damp the radiation around the sensor, except the front where the sensor points to the glass.
I made some test and found out that putting the aluminum tape directly on the sensor (of cours with a thin isolation layer inbetween) reduces the sensitivity of the sensor to about 1-2 cm, which renders the sensor useless.
Thus I figured there must be an air gap between the sensor and the aluminum tape of ca. 1cm. So I made a simple frame of card board, which holds the sensor inside the center of the box to provide enough space. I put the sensor intentionally in the middle of the box instead of directly to the “front” side to reduce the radiation and detection angle a bit more.
Here a some pictures of the housing:
You see, the front-side of the box is NOT covered with aluminum tape. This side will be pointing to the mirror glas. All other five surfaces of the box are taped.
This is the backside.
The simple frame construction which holds the sensor in the center of the box…
like this…
The box is then put inside the frame with the untaped side facing to the glass.
Cross-section through the box:
|| |
|| || |
|| 1 cm gap || 1cm gap |
|| |
taped sensor UN-taped
backside front to the mirror
Wireing of the sensor:
You only use Vin (5V), Vout and GND. CDS (for applying a photo diode) and 3V3 (delivers 3.3V output) remain unused. For Vout you can use also oher GPIO pins (labeled “Digital I/O” in the 2nd diagram), in case GPIO_4 is already used.
The ferrite bead is optional. It is a left over from the PIR sensor I had attached. If you may need one, you can dismantle an old VGA cable and use that one.
And thats it!
The sensor is wired like any conventional PIR sensor to the the RPi with Vin = 5V, GND and a Vout=I/O-Pin of your choice.
As mentioned, before you can continue to use your favourite PIR module, like e.g. MMM-PIR-Sensor without any modifications.
Option 2: Replacing the antenna to GND resistor:
On the sensor is a tiny SMD resistor soldered, wich is labeled with "221 (=220 Ohm).
To reduce the sensor range this resistor can be replaced with a smaller resistor value. The smaller the resistor, the shorter the range.
As the room layouts, characterisics of the walls (dry wall, concrete, stone, wood walls, tiles,….) differ from home to home and individual requirements, we’ll take an adjustable trimmer resistor to find the fitting value.
What we need:
- Soldering iron and some soldering braid
- Trimmer resistor, e.g. 3296 W201 with 200 Ohm (max. resitor value)
- Multi-meter, which can measure resistors
- Small screwdriver
- angled header pins
First we remove the “221” labeled resistor on the resistor (see red arrow)
This requires some soldering skill, but with a little exercise it can be removed very easily. There are hundreds of great tutorials on youtube, which you can follow. I used this simple method:
https://www.youtube.com/watch?v=NjswgMtwXaw
Before we solder the trimmer resistor, I’d recommend to adjust roughly the resistor value, as later it might be quite cumbersome. Take a multi-meter, which can measure electric resistors and adjust it to 150 Ohm. This value reduces to sensor range to ca. 1m. From there, you can then in creas or decreace the resistor until it fits you.
The next step is to solder the trimmer sesistor on the sensor like this. The third pin remains unused an can be clipped away later if desired.
Then solder the header pins on the left where you connect the sensor with the GPIO of the Rpi
The CDS (for applying a photo diode) and 3V3 pin (delivers 3.3V output) remain unused.
Then connect the sensor to the RPI
Again, you only use Vin (5V), Vout and GND. CDS (for applying a photo diode) and 3V3 (delivers 3.3V output) remain unused. For Vout you can use also oher GPIO pins (labeled “Digital I/O” diagram above), in case GPIO_4 is already used.
The ferrite bead is optional. It is a left over from the PIR sensor I had attached. If you may need one, you can dismantle an old VGA cable and use that one.
In the last step you mount the sensor in the frame, start MM and adjust the resistor with a small screw driver a few turns to more or less range. Probably you’ll need a second person, which moves outside the room to test if the range is good enough while you adjust the trimmer.
Conclusion?
Option 1:
The sensor inside that box works just as desired for me. I made “exhaustive tests” with my daughters jumping around in the adjacent rooms and floors and had no false positives. This of course applies to the layout of our house and your milage may vary. But I think that this simple approach could be useful for others, too.
Option 2:
This a more advanced and sophisicated approach, which works in my setup also as desired. Of course it depends very much on how your rooms are layed out and what characteristic your walls have. And you need a bit excercise in soldering. On the other hand you need no extra space inside the frame for the “Magic Box”.
Now it’s up to you which option you want to go. Start with Option 1 and see how your results are, and if you wish then go on with Option2.