Silicon ChipEl Cheapo Modules 13: sensing motion and moisture - February 2018 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Yet another threat to surfing the net
  4. Feature: Turning your garbage into useful electricity by Ross Tester
  5. Project: A Water Tank Level Meter with WiFi and More! by Nicholas Vinen
  6. Review: Navman’s DriveDuo – Satnav and Dashcam by Leo Simpson
  7. Project: 6-Element VHF TV Yagi to kill UHF 4G interference by Leo Simpson
  8. Feature: El Cheapo Modules 13: sensing motion and moisture by Jim Rowe
  9. Serviceman's Log: Smart TVs can be pretty dumb sometimes by Dave Thompson
  10. Product Showcase
  11. Project: Highly versatile & accurate dot/bar 10-LED Bargraph by John Clarke
  12. Project: The Arduino Mega Box Music Player revisited by Bao Smith
  13. Vintage Radio: A more detailed look at the 1919/20 Grebe Synchrophase by Ian Batty
  14. PartShop
  15. Subscriptions
  16. Market Centre
  17. Advertising Index
  18. Notes & Errata: UV Light Box & Timer / Micromite BackPack Touchscreen DDS Signal Generator / Deluxe Touchscreen eFuse / Kelvin the Cricket
  19. Outer Back Cover: Hare & Forbes Machineryhouse

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!":
  • WiFi Water Tank Level Meter shield PCB with stackable headers [21110171] (AUD $7.50)
  • Small 2A boost step-up regulator module (MT3608) (Component, AUD $3.00)
  • IPP80P03P4L-07 high-current P-channel Mosfet (Component, AUD $2.50)
  • GY-68 Barometric Pressure/Altitude/Temperature I²C Sensor breakout board (Component, AUD $2.50)
  • DHT22/AM2302 Compatible Temperature and Humidity sensor module (Component, AUD $9.00)
  • 5dBi 2.4GHz WiFi antenna with U.FL/IPX adaptor cable (Component, AUD $12.50)
  • 2dBi omnidirectional 2.4GHz WiFi antenna with U.FL/IPX adaptor cable (Component, AUD $10.00)
  • Elecrow 1A/500mA Li-ion/LiPo charger board with USB power pass-through (Component, AUD $25.00)
  • Arduino sketch (.ino) file and libraries for the WiFi Water Tank Level Meter (Software, Free)
  • WiFi Water Tank Level Meter shield PCB pattern (PDF download) [21110171] (Free)
Items relevant to "El Cheapo Modules 13: sensing motion and moisture":
  • Arduino and BASIC source code for El Cheapo Modules 13 (Software, Free)
Articles in this series:
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • A Gesture Recognition Module (March 2022)
  • A Gesture Recognition Module (March 2022)
  • Air Quality Sensors (May 2022)
  • Air Quality Sensors (May 2022)
  • MOS Air Quality Sensors (June 2022)
  • MOS Air Quality Sensors (June 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Heart Rate Sensor Module (February 2023)
  • Heart Rate Sensor Module (February 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • VL6180X Rangefinding Module (July 2023)
  • VL6180X Rangefinding Module (July 2023)
  • pH Meter Module (September 2023)
  • pH Meter Module (September 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 1-24V USB Power Supply (October 2024)
  • 1-24V USB Power Supply (October 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)
Items relevant to "Highly versatile & accurate dot/bar 10-LED Bargraph":
  • 10-LED Bargraph PCB [04101181] (AUD $7.50)
  • 10-LED Bargraph Signal Processing PCB [04101182] (AUD $5.00)
  • 10-LED Bargraph PCB patterns (PDF download) [04101181/2] (Free)
Items relevant to "The Arduino Mega Box Music Player revisited":
  • Firmware (Arduino sketch) for the LC Meter (Mega Box) (Software, Free)
  • Firmware (Arduino sketch) for the VS1053 Music Player (Mega Box) (Software, Free)
  • Geeetech VS1053B MP3/audio shield for Arduino (Component, AUD $10.00)
  • Firmware (Arduino sketch) for the VS1053 Music Player (Mega Box) (Software, Free)
Articles in this series:
  • The Arduino MegaBox from Altronics (December 2017)
  • The Arduino MegaBox from Altronics (December 2017)
  • Arduino LC Meter Shield Kit (January 2018)
  • Arduino LC Meter Shield Kit (January 2018)
  • The Arduino Mega Box Music Player revisited (February 2018)
  • The Arduino Mega Box Music Player revisited (February 2018)
  • Altronics New MegaBox V2 Arduino prototyping system (December 2019)
  • Altronics New MegaBox V2 Arduino prototyping system (December 2019)

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