Give Your Smart Home A Green Thumb With MQTT

We have all been stuck inside for too long, and maybe that’s why we have recently seen a number of projects attempting to help humans take better care of their housemates from Kingdom Plantae. To survive, plants need nutrients, light, and water. That last one seems tricky to get right; not too dry and not drowning them either, so [rbaron’s] green solder-masked w-parasite wireless soil monitor turns this responsibility over to your existing home automation system.

w-parasite MQTT diagram

Like this low-power soil sensor project and the custom controller for six soil sensors, [rbaron’s] w-parasite uses a “parasitic capacitive” moisture sensor to determine if it’s time to water plants. This means that unlike resistive soil moisture sensors, here the copper traces are protected from corrosion by the solder mask. For those wondering how they work, [rbaron]’s Twitter thread has a great explanation.

The “w” in the name is for WiFi as the built-in ESP-32 module then takes the moisture reading and sends an update wirelessly via MQTT. Depending on the IQ of your smart-home setup, you could log the data, route an alert to a cellphone, light up a smart-bulb, or even switch on an irrigation system.

w-parasite circuit board in a potted plant[rbaron] has shared a string of wireless hacks, controlling the A/C over Slack and a BLE Fitness Tracker that inspired more soldering than jogging. We like how streamlined this solution is, with the sensor, ESP-32 module, and battery all in a compact single board design. Are you asking yourself, “but how is a power-hungry ESP-32 going to last longer than it takes for my geraniums to dry out?” [rbaron] is using deep sleep that only consumes 15uA between very quick 500ms check-ins. The rechargeable LIR2450 Li-Ion coin cell shown here can transmit a reading every half hour for 90 days. If you need something that lasts longer than that, use [rbaron]’s handy spreadsheet to choose larger batteries that last a whole year. Though, let’s hope we don’t have to spend another whole year inside with our plant friends.

We may never know why the weeds in the cracks of city streets do better than our houseplants, but hopefully, we can keep our green roommates alive (slightly longer) with a little digital nudge.

 

36 thoughts on “Give Your Smart Home A Green Thumb With MQTT

    1. No matter what update interval they chose you could say it should be longer. Where does that line of reasoning end? At some point you have to choose a minimum measurement rate you’re happy with, and then you have to find other ways to achieve a battery life target.

      Now there actually are ways to do that without affecting the measurement collected; for instance decoupling the measurement and upload periods by saving several measurements and uploading them all at once, so you can amortise the large wifi cost of an upload across them. If you want to get really fancy you can make the upload period dynamic so that it slows down as the battery gets lower, to eke out as much from a charge as possible.

      1. I really like this idea. Would you use the ADC (assuming it has one or more onboard) with a voltage divider, then define thresholds in the code to achieve this dynamic upload period you described?

        1. Yes, but you need to consider the current through the potential divider and its affect on overall sleep current. One would typically use a FET to isolate the divider from power or ground whilst sleeping to negate the parasitic current.

          1. That current can be arbitrarily low, such that it doesn’t really impact the battery life significantly. You hit the problem that the source impedance needs to be lower than the input impedance of the ADC pin to get anything like a decent reading, but all you need to do is add a cap across the bottom leg of the divider.

            The other trick if you really want to switch it is to connect the bottom leg of the divider to another gpio pin instead of ground, configured as open-drain. There’s no need for an external fet.

      2. Any sampling period smaller in scale than hours is pointless and wasteful. Saying “where does it end” disregards the most basic knowledge of what plants need, dynamic systems, hysteresis, etc. People feel more satisfied with more data, regardless if it’s meaningful. Plants have no such defect.

        1. Those are precisely the considerations that go into “minimum measurement rate you’re happy with”. It can be quite low for this specific application, but the techniques are equally applicable for things that have completely different timescales, and are therefore worth discussing in the general case.

        2. Was that a paraphrase of the bit in “Soul of a New Machine” when engineer says he’s going to Vermont and will deal with no unit of time smaller than a season?

        3. I am thinking make the dynamic reporting period tied to how close the moisture level is to a no go value. Reasoning being if you have just watered the plant sufficiently there is less need to monitor it at all frequently but as it approaches dry level there needs to be more reports to ensure unhealthy levels are not hit. Ie at good moisture levels it is safe to report maybe every few days but as it gets to almost too dry send an update every hour seems appropriate. Also take into account night time … no one’s watching so if not automated might as well schedule next sample and report at 6am and sleep till then.

      3. While you all are at it, dynamically change the time depending on the humidity readings. I assume this won’t be used outside where it might rain, this means when the plants recently got water they might get water again when dry. Since it won’t get dry in a matter of seconds you don’t need to read for a couple hours anyways.

    2. ESP32 has plenty of RAM. It does not really have to TX reading each time a new one is acquired. I bet starting WiFi and connecting to server eats most the TX power, even if you transmits a few KiB…

  1. “We may never know why the weeds in the cracks of city streets do better than our houseplants…”
    That’s no secret. Take a walk, look closely and you’ll know why.

    1. Small(ish) solar panel charging up a few large(ish) capacitors would be ideal here…

      No need to replace a battery, even a rechargeable, it’ll be near sunlight by nature of being near plants that need sunlight, and if it should run out of power and disconnect the lack of updates is indicative of not enough sunlight for the plant.

      Even if the caps can’t make it overnight, do you really need to track your plants through the night?

    2. For low duty cycle applications, you can achieve almost any battery life target you want. I’ve previously worked on a smart device that had to last 15 years on a single battery (and *not* a car battery either, a D-sized primary lithium cell) while uploading over 4G and that was a challenging but entirely achievable target.

      (the device and the company failed due to chronic mismanagement, but the engineering was rock solid.)

  2. “This means that unlike resistive soil moisture sensors, here the copper traces are protected from corrosion by the solder mask.”

    That seems optimistic. Check the PCBA at the end of the growing season.

    If you want it isolated, dip it in silicone.

  3. >the weeds in the cracks of city streets do better than our houseplants
    The sky is not going to check if the soil is getting too dry or too wet before it rains. Plants in the wild adapt and deal that.

    If there is too much water, you know that’s what the drainage hole in the pot and the dish are for. If there is too little water, the plant looks wilted. Just don’t let either happen too often.

    All that technology isn’t needed. You should be able to figure out how much and how often to water just like generations before you. Afterall, you do have a neural network fully capable of learning.

    1. It’s not really complicated, or difficult. Some people just lack responsibility and motivation to do it regularly, and consistently. Plants are forgiving, to a point, but indoors, in a pot, they are completely dependent. What good are house plants, if you aren’t interested enough to look at them? For an indoor ‘herb’ garden maybe, but you would probably want fuller automation of you hydroponics and grow lights, to maximize production.

    2. I grow cannabis hydroponically and use these to measure my grow medium to ensure I have reached the correct dry back before watering again. This dry back time is dependent on the stage of growth, size of plant, location under grow light, among other environmental factors. With some basic experience and knowledge of horticulture, you would understand that managing this is not as simple as remembering to water a plant daily. It is especially helpful when the scale of your grow increases.

  4. Curious if Bluetooth low energy was considered. If it was then why wifi instead? You don’t have to wait for something to connect, you just send out a advertisment into the ether and a gateway can catch it.

  5. That is a lot of tech per node just to generate and send less than 2048 bits of data each day, if you think about what your really need to be sending. Better to have a lot of dumb nodes and one smart gateway so it really can scale to a full building or larger. Dumb nodes are far more likely to have power requirements that a small solar panel can handle.

  6. Looking at the circuit, the output on the soil sensor is just a voltage. If you can figure out the voltage that corresponds to the plant needs watering, you can have that be the trigger to exit deep sleep. Then it will only check-in when the plant needs it. No need for the continuous data.

    Alternately, have an led that flashes or a piezo that buzzes every few minutes once watering is needed.

    1. Why not just trigger a valve or small pump, to add a little water… Then, there would still need to be the need to remind, the the reservoir needs refilling…. Why the need for batteries, in a house? Low voltage DC wiring can be thin, easily hid. Or just go with artificial plants to begin with. Large selection available these days, and the price has come down considerably. Most, you have to touch, to know they are fake plants.

  7. WiFi.. Bluetooth.. No no no. Too energy hungry. Use LoRaWAN and see around 10 years at 30 minute reporting intervals. Gateway on the Things Stack and you’re laughing. This is what we use for remote Asset management.

  8. I have been designing and building soil moisture sensors for over 7 years. The greatest challenge is to keep them alive in soil. Soil is a very harsh environment, I can see that sensing pad is too close to components, this will not survive a month in a pot. My sensor designs are open source, check them out for inspiration: https://www.tindie.com/stores/miceuz/

    1. The cheap trick I’ve been using is applying a layer of transparent nail polish on the sides of the pcb and over components closer to the soil. I have a few of those in the ground for a little over six months and they seem to be holding up okay.

    2. Hello Miceuz, I did a re-routing of your design (https://github.com/SKZ81/temp_AutoWatS_moisture_WIP), mainly to use PCBA stock available parts and to improve my KiCAD (eeschema) skillz, thanks to you !

      That’s funny how the module (that capacitive sensor v1.2 that blooms everywhere) looks like a down-trimmed version of your idea… But OP then got the ideo to attach an MCU to the PCB probe… Eternal cycle or what ? :D

  9. Surprised there isn’t more love for mqtt-udp. Decentralised and lightweight seems like a no brainer for this kind of connectionless sensor (what with it being asleep most of the time).

Leave a Reply to JonCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.