Advertisement

Hands-on review: making an open-source soil moisture alarm go full IoT

With the right additions, a cheap soil moisture sensor can become a wireless IoT moisture probe to help automate indoor plant watering

By T.K. Hareendran, contributing writer

Recently, I got a Chirp! plant-watering alarm for evaluation from wemakethings. Chirp, designed to be run on a 3-V CR2032 lithium coin cell, is an electronic plant-watering alarm. You put it into the soil near a plant and it emits a tiny chirp when the soil is dry, reminding you to water the plant. Furthermore, Chirp will be silent when it’s dark and will restrain itself from making too much noise at night. A huge métier of Chirp is that it uses capacitive humidity sensing; hence, it does not make an electric contact with the soil. This helps avoid electrode corrosion and soil electrolysis.

I discovered that it is also possible to adapt the alarm so that it would do more than make a noise; it could send data. Here, the soil moisture sensor would periodically monitor the moisture level in the soil near the roots of the plant and transmit this data over a wireless network to a distant master device. The master device could then use the received data to remotely operate a sprinkler or similar device to water the indoor plants. For a simpler solution, I could just configure the master device to send an alert by an SMS/tweet in case the plant gets too dry.

both-sides_jpg_855x570_q85_pad_rcrop

Fortunately, Chirp is open-source hardware available under CERN Hardware License v.1.1 and fully documented, making it easy to modify. The design is based on the ATtiny44A microcontroller and, surprisingly, offers a header onboard for programming and/or serial communication. Because Chirp acts as an I2 C slave (with 7-bit address 0 x 20 hex), this header can also be used to read moisture (and light) levels from its sensors by linking another microcontroller to it as an I2 C master.

The header also means that the battery is not actually necessary. Chirp’s header isn’t just an I2 C connector; it’s actually a “full” 6-pin AVR-ISP header for programming its onboard ATtiny44A. This means that there are also reset and power supply connections available, allowing you to power the device externally by 3.3-/5.0-V source.

In principle, Chirp can work in two modes. The first is the standalone/default mode in which it periodically monitors soil moisture and give out chirps when the plant needs to be watered. The second is the I2 C slave mode in which it measures moisture/light only when demanded by the external I2 C master device. You switch Chirp from default mode to slave mode by initiating a reset. After reset, Chirp reads moisture and light levels, but if any I2 C communication is received during that time, Chirp will switch into slave mode. It will not chirp, just respond to I2 C requests.

An extra brain
You can find some example code to use the Chirp as the front-end sensor in a big system as well. The code is pretty simple: whenever you want to get a reading from the moisture sensor, just call read I2 C Register 16-bit (0 x 20) and you will get an integer representing the soil moisture content. Reading the moisture level is only half of the game, however. There needs to be an extra “brain” to send a wireless alert once the moisture level drops below an acceptable level.

Fortunately, a “Wemos D1” (mini pro/mini) that I had turned out to be quite suitable for this purpose because it has onboard Wi-Fi packed in as standard. The Wemos mini pro is a nifty Wi-Fi board with 16-MB flash, an external antenna connector, and a built-in ceramic antenna based on ESP-8266EX. Also, there are third-party software nodes out there that can send out alert messages. This idea is not bound to Wemos D1, however, so feel free to start your experiments with other standardized IoT hardware modules — the NodeMCU module, for instance.

2-WemosD1

When choosing hardware to control the Chirp, however, there is one thing about which you need to be careful. According to Albertas “Miceuz” Mickenas (Chirp’s mastermind): “The Chirp plant-watering alarm can be used as an I2 C sensor with almost all platforms, provided that they support the I2 C properly — in particular, clock stretching. I2 C is more of an add-on in the Chirp platform than a proper feature, but all in all, it is always possible to use if the I2 C clock is slowed down.”

Mickenas has addressed this limitation, however, by creating another version of Chirp. “My customers had some problems using it as a standalone sensor with Raspberry Pi, so I have moved to a different MCU that has a proper I2 C implemented in hardware and higher clock speeds for my standalone I2 C sensor platform.”

The “sensor-mode-only” version of Chirp (v2.7.1) uses a 16-MHz crystal and can reliably be read via I2 C protocol. It also provides some additional features like thermistor-based temperature sensing, slave address changing, and chip resetting.

3-Chirp-v2.7.1

Integration of this “sensor-mode-only” version with famed IoT hardware like the Particle Photon or the Espruino Pico can also be used to create more complex, advanced, and practicable wireless sensor projects, such as the one described here.

4-Particle-Photon

There are hidden beauties:

There is a continuation of the Chirp project that is a capacitive soil moisture sensor interfaced via Modbus over RS485, as well. This particular version (v2.8.0) is suited to more professional installations in which long cable runs are a requirement. It adds a local voltage regulator to mitigate the voltage drop due to cable length and includes an RS485 transceiver to accommodate long wires. The transceiver also includes reverse polarity and additional ESD protection.

There’s also a featured project: “Getting Soil Moisture Sensor Information with Android Things and Raspberry Pi 3.” The project will transfer soil moisture sensor data over wireless through NodeMCU. This transfer will be done by using an Android Things installed gateway. You can access the project files on GitHub.

As you can see, then, Chirp is a pretty simple, open-source, hackable design that can readily be converted from a simple alarm to a full IoT device. As with most trusted hardware, there are always many ways of doing things, but this is especially true of Chirp.

Want more? Here are some of TK’s other hands-on reviews:
Hands-on review: preparing for development with the versatile MinnowBoard Turbot
Hands-on review: Open-source MinnowBoard Turbot SBC is fast, powerful, and versatile
Hands-on review: Analyze signals with free, open-source sigrok PulseView
Hands-on review: Plug-and-play your way to the IoT with Wio Link

Advertisement



Learn more about Electronic Products Magazine

Leave a Reply