This is only a preview of the February 2018 issue of Silicon Chip. You can view 37 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Items relevant to "A Water Tank Level Meter with WiFi and More!":
Items relevant to "El Cheapo Modules 13: sensing motion and moisture":
Items relevant to "Highly versatile & accurate dot/bar 10-LED Bargraph":
Items relevant to "The Arduino Mega Box Music Player revisited":
Purchase a printed copy of this issue for $10.00. |
Motion Sensor
& Soil Moisture
Sensing Modules
Using
Cheap
Asian
Electronic
Modules
Part 13
This month we look at two low-cost modules from Elecrow. One is a
motion sensor which uses microwave Doppler radar technology rather
than passive IR sensing, while the other module is designed to sense the
soil moisture level in a garden or pot plant. Both modules can be easily
interfaced with an Arduino or Micromite device.
L
et’s start by looking at the Elecrow
RCWL-0516 Microwave Radar
Motion Sensor module first. It measures only 36 x 17 x 4.5mm, including the on-board transmit/receive antenna.
Essentially, this module is designed
as a replacement for passive IR movement sensors as used in intruder
alarms, movement-actuated lighting
and movement-sensing toys.
It’s designed to work on any DC supply voltage between 4V and 28V, with
an operating current under 3mA. The
UHF oscillator/mixer transmits a signal at around 3.2GHz, with an output
of between 20mW and 30mW.
This is claimed to provide movement sensing at distances of up to 7
metres, with close to 360° of coverage
from the front of the module.
Additional features include the ability to adjust the trigger repeat time and
the sensing distance, plus the ability
to use a CdS (cadmium sulphide) LDR
(light dependent resistor) to disable
the sensor at night if desired.
The trigger repeat time is nominal44
Silicon Chip
ly about two seconds, but an optional
SMD capacitor labelled “C-TM” can
be added on the back of the PCB to
increase this time if desired.
Similarly, a 1MW resistor “R-GN”
can be added on the back of the board
to reduce the sensing range from 7m
to 5m.
The optional LDR is added to the
front of the board if it’s desired to disable the sensor at night. This would
probably only be used for applications like movement sensing toys because for many other applications,
the main use of the sensor would be
at night anyway.
This motion sensor’s circuit
The circuit for the RCWL-0516 sensor module is shown in Fig.1. The UHF
oscillator/mixer is on the left, using
Q1, an MMBR941 NPN transistor. The
low-frequency Doppler signal output
from Q1 is fed to pin 14 of IC1, which
forms the triggering circuit.
By JIM ROWE
Celebrating 30 Years
IC1 is an RCWL-9196 device, for
which no data seems to be available.
However, it’s claimed to be very similar to the BISS0001 “micropower PIR
motion detector” IC used in many of
the passive IR motion sensors.
The oscillator/mixer circuit around
Q1 is interesting because of the use of
PCB track components rather than discrete ones. It appears to be a Colpitts
circuit, with capacitors CBE and CCB
formed by inter-track capacitance and
the inductor/antenna comprising an
S-shaped track forming a microstrip
line on the top of the PCB.
Notice that the microstrip inductor
not only forms a key part of the oscillator circuit but also serves as the antenna for both transmission and reception.
The circuit around Q1 is not just
an oscillator and transmitter but also
serves as a mixer, to combine the transmitted and received signals and deliver the resulting Doppler difference
frequency.
This appears as a relatively small
low-frequency signal across the 2.0kW
siliconchip.com.au
Fig.1: complete circuit diagram for the Elecrow RCWL-0516 microwave radar motion sensor module. The track inductor
forms the antenna for both transmission and reception of microwave signals and has a range of approximately 7m.
resistor connecting the “cold” end
of the inductor/antenna to ground,
which then passes through a low-pass
RC filter before being fed to input pin
14 of IC1.
Inside IC1, the signal apparently
passes through two stages of amplification and filtering and is then used
to trigger one of a pair of timers. This
timer provides the module’s “movement sensed” pulse at pin 2 (VO),
while the other timer sets the trigger
repeat time.
Optional resistor R-GN is connected between the output (1OUT) and
inverting input (1IN-) of the first gain
op-amp inside IC1, so clearly, the sensing range is reduced by lowering the
gain of this stage. On the other hand,
optional capacitor C-TM is used to increase the capacitance from the RC1
pin (pin 4) to ground, to extend the
trigger repeat time.
IC1 has an internal 3.3V regulator.
This is used to step down the supply
voltage fed to the module via the VIN
pin (4) of CON1 and then into IC1 itself via pin 8.
The output of the regulator not only
powers IC1’s internal circuitry but is
also made available via pin 11 (VDD),
where it’s used in this case to power
the microwave oscillator/mixer stage
around Q1. It can supply up to 100mA
of current to external loads, via pin 1
of CON1.
Another point to note is that pin 9
of IC1 allows the chip’s triggering to be
disabled. As you can see, this pin (VC)
is pulled high to 3.3V, as well as being
brought out to pin 5 (CDS) of CON1.
So triggering is normally enabled
but it can be disabled quite easily,
either by shorting pin 5 of CON1 to
ground or by fitting the optional CdS
LDR to the module.
When an LDR is fitted, its resistance
drops when the ambient light level
increases, pulling the voltage at pin 9
of IC1 down. Once it drops to below
0.2V, triggering is disabled.
The purpose of optional resistor RCDS is presumably to allow fine tuning
of the light level at which triggering is
disabled when the LDR is fitted. This
is useful since LDRs vary quite a bit
in their light/resistance characteristic.
Both photos show the microwave-based motion sensor
module at just over twice normal size (36 x 17mm). The
PCB has numerous vias to connect the top and bottom
layer ground planes. An odd feature of this module is
that nearly all the optional parts (R-GN, R-CDS & C-TM)
are soldered to the bottom of the PCB instead of the top;
with the exception of the LDR (marked CDS).
siliconchip.com.au
Celebrating 30 Years
February 2018 45
Fig.2: wiring diagram for the
motion sensor module to an
Arduino or compatible device.
Connecting to a micro
Fig.2 shows a very simple way of
connecting the RCWL-0516 motion
sensor module to an Arduino micro.
The VIN and GND lines connect to the
+5V and GND pins of the Arduino,
while the OUT pin (pin 3 of CON1)
connects to pin D3. That’s all there
is to it.
It’s just as easy to connect the module to a Micromite, as you can see from
Fig.3. Here the VIN and GND lines
again connect to the corresponding
pins on the Micromite, while the OUT
pin connects to pin 16.
In both cases, the actual pin of the
micro to which the OUT pin of the
module is connected is purely to suit
the program you’ll be using to monitor
the sensor’s output. We’ve shown the
connections in Fig.2 and Fig.3 merely
because they are intended to match the
simple programs we will now discuss.
find that moving anything within the
module’s sensing area will immediately
result in the “Movement detected”
message.
To use the module with a Micromite,
download “RCWL0516 motion sensor
check.bas” and use MM Edit to upload
it to your Micromite.
You’ll find that it works in much the
same way as the Arduino program but
with one exception; as well as sending messages back to your PC, this one
also provides a display on the Micromite’s LCD screen (assuming you have
the LCD BackPack).
Elecrow’s soil moisture sensor
Now let us take a quick look at the
Elecrow CT0007MS Soil Moisture
Sensor module, which is essentially
an updated version of earlier analog
soil moisture sensors.
Although this module is much simpler than the microwave movement
sensor we’ve just looked at, it’s on a
somewhat larger PCB because its two
sensor probes form about 70% of the
PCB area. The overall size of the module is 60mm long by 20mm wide.
Each probe is formed by gold-plated
tracks on both sides of the PCB, connected together with 11 vias in each
case. You can see this fairly clearly
from the lead photo of the module.
Also visible in the photo is the
210mm long three wire lead which is
supplied with the module and used
to hook it up to a micro. The connecting lead is provided with a 3-way line
socket at each end, one of which mates
Programming it
It’s easy to get the RCWL-0516 module working with either an Arduino
or a Micromite, as all it needs in each
case is a few brief lines of code.
On the Silicon Chip website, you’ll
find two short programs which show
just how easily it can be done. The
file “RCWL0516_motion_sensor.ino”
is suitable for an Arduino.
When you download it, verify and
compile it using the Arduino IDE and
then upload it to your Arduino, you
should find that when you open the
IDE’s Serial Monitor, you see a sequence of one-line messages from the
module like this:
Fig.3: wiring diagram for the
motion sensor module to a
Micromite. The MMBasic program
for this module also displays data
on the LCD screen.
No movement detected: Output = LOW
No movement detected: Output = LOW
Movement detected:
Output = HIGH
The messages will be coming at the
rate of two per second, and you’ll soon
46
Silicon Chip
Celebrating 30 Years
siliconchip.com.au
Fig.4: circuit diagram
for the Elecrow
CT0007MS moisture
sensor. Q1 is connected
as an emitter-follower
such that the voltage
across the 100W
resistor at the emitter
is proportional to the
soil moisture level.
with the plug on the module itself.
Fig.4 shows the circuit of the CT0007MS module. Which is just an
emitter-follower using NPN transistor Q1.
When the two probe electrodes are
pushed into the soil, they form a resistance whose value is inversely proportional to the moisture present in
the soil.
As this resistance is effectively between the DC supply rail (VCC) and
the base of Q1, this means that its
base current will vary according to the
soil moisture. Ergo, wetter soil equals
a lower resistance in the base circuit
and a higher base current.
Because Q1 is connected as an emitter-follower, this means that the voltage across its 100W emitter resistor
will also be proportional to the soil
moisture level.
The wetter the soil, the higher the
voltage across the resistor due to the
higher base current. Since the voltage across the resistor forms the sig-
nal (SIG) output from the module, this
voltage will also vary according to the
soil moisture.
So the CT0007MS module is essentially just an analog transducer converting soil moisture into a DC voltage. In order to use it with a micro, all
that’s needed is to feed its SIG output
to one of the micro’s (analog to digital converter) inputs and to connect
its VCC and GND inputs to the corresponding supply lines.
Fig.5 shows this connected with an
Arduino, while Fig.6 shows it with a
Micromite. The module’s VCC lead can
be connected to either the +5V line
or the +3.3V line. To emphasise this,
we’ve connected it to the Arduino’s
+5V line, but to the +3.3V line in the
case of the Micromite.
Programming this one
Programming an Arduino to use the
CT0007MS moisture sensor module
is straightforward. All you need to do
Fig.5 (above): wiring diagram for the moisture sensor module
to an Arduino or similar. Note that its VCC line can be
powered from either the 5V or 3.3V rail.
Fig.6 (right): wiring diagram for the moisture sensor with the
Micromite and an optional touchscreen attached. If a screen
is present there will be a bar display of the soil moisture
level, as shown on the next page. As with the Arduino, the
module can be powered from either the Micromite’s 5V or
3.3V line.
siliconchip.com.au
Celebrating 30 Years
February 2018 47
is read the module’s SIG output voltage. The higher the reading, the more
moisture in the soil.
To get you going with this, we have
produced a simple little program
called “CT0007MS_moisture_sensor.
ino” which is available for download
from the Silicon Chip website.
Use the Arduino IDE to upload it to
your Arduino and you should find that
it will start printing out (via the IDE’s
Serial Monitor) moisture readings
from the sensor every two seconds, as
shown in the screen grab.
During our test, the sensor probes
were inserted into soil a number of
times. On the last occasion the soil
was quite wet, resulting in readings
of around 866 (out of 1023). On the
other hand, the readings were zero
(0) when the probes were not inserted
into any soil.
We’ve also written a small program
to show how easy it is to use the sensor with a Micromite. It’s called “CT0007MS moisture sensor.bas” and as
before, it’s available from the Silicon
Chip website.
This program produces the same
sort of printout of moisture readings
(a feature of MM Edit) as the Arduino program. But if your Micromite is
connected to an LCD panel, it will also
display a bar graph on the screen, indicating the current moisture level.
You can see this in the two small
screen grabs below, one showing the
display when the soil is fairly dry and
the other showing the display when
it’s very wet.
Hopefully, these two simple programs will give you a good introduction to what’s possible using the
Elecrow CT0007MS module.
SC
Above: example output data from running the sample Arduino program with the CT0007MS.
48
Silicon Chip
Celebrating 30 Years
siliconchip.com.au
|