Arduino Plant Hygro meter for Domoticz

This is one of my first Arduino projects to complete and it costed me about €4. Which is cheaper than the blinking sensors you can pick up from AliExpress and is a lot more flexible. To goal was to create a soil hygro sensor to alert me when my plant needs water, as I forget and then the die. Which is a pity.

I used the following hardware:

IMPORTANT: You need to add some drivers and follow the installation details here to get the board working. Don’t ask me if you can’t get this step to work, I just followed the instructions and got it working. If you want to see output, make sure your serial monitor is set to the right baud. Interestingly, contrary to what the board says (9600), I’m using 11520 for the baud rate. While I know nothing about baud rates, this might not surprise others.

Once you’ve done so, you can make a small setup like this:

Then, find a plant that you can set up next to your computer and plug it in. You can also test with a simple cup of water, which will make testing slightly less messy.

Next is to go to your domoticz and create a Virtual device. I’ve opted for Leaf Wetness, mostly because it shows a plant and stores a number. After you created this, find the ID of the device in the devices overview. You need it later.

The code to connect to WiFi is taken directly from Henry’s Bench with a small adjustment to disconnect between readouts and a timeout for failing connections. We’re only connecting every 10 minutes or so, so there’s no use in keeping the WiFi signal alive. This should also save battery if you decide to run it on a battery. But you can probably make more improvements there.

The whole connecting and sending is in a different function so you could also change it if you only want to send when it’s below a certain threshold or, if you use the digital setting, only when the value changes from 0 to 1 or vice versa. My goal is to send the value to Domoticz. So I can add individual plant logic later, some plants want more moisture, some want less, and I want to use Python & Pushover to notify me when a certain plant is in need of water, or the Arduino hasn’t updated in three hours which would require a reset or something else.

Anyway, the code:

Update: The Long term

Cathode, anodes and electrolysis… :-(
A cheap alternative.

So, turns out I forgot a bit about chemistry. And in the long term, this doesn’t work. Why? Well, Cathodes, Anodes, you know. In short, the contacts from the hygrometer dissolve. The stick-in-things are cheap, you can get them from China for 60 cents or so, but as a long term solution, they don’t work. I found some unused rivets in the shed and decided to use those. It appears they work. Maybe not as accurate, but I just need a readout, from there I’ll decide what the levels of acceptance are and thus when to water the plant.
Another method might be to cut power to the cathode and anode in between read outs. This will increase the lifetime of them and save power, which is interesting when run on batteries.

Leave a Reply

Your email address will not be published. Required fields are marked *