Close

More Show and Tell

A project log for Soil moisture monitoring in a flower garden

When do your flowers have enough water, and how do you know?

joseph-eoffJoseph Eoff 03/20/2021 at 17:525 Comments

I managed to get a functional version of the  ESP32 control node software working this week.  I spent several rather intense evenings, flipping back and forth between ESP32 documentation, Arduino documentation, MQTT PubSubClient library documentation, C documentation, and StackOverflow.


The control node works as planned - sort of.  I ended up changing plans a bit.

The idea has always been for the node to register with the MQTT server and report in.  The bridge then sends it a list of all the Bluetooth sensor IDs it should scan.  The node then reads them and reports the sensor values back to the bridge.  The bridge stores the data in the Mud-Py database. Once the node has done all the sensors, it tells the bridge "done" and the bridge tells it to take a nap for X seconds then check in again.

The outline stayed, but the details changed.

My original concept had the node dropping the WiFi connection while scanning the sensors.  I've noticed interference between Bluetooth and WiFi before, and wanted to avoid that.

That would have required the node to store the list of Bluetooth IDs to scan, and also to store the results.  That turned out to be more complicated than I thought - memory management is no fun in the Arduino environment.

I ended up leaving WiFi active the whole time, and just doing things "live" - send the sensor IDs one by one as MQTT messages and let the node read and respond to each command as it comes in.

That made a lot of things much simpler, and is the reason I have a functional control node software ready to run.

You can't see bits and bytes, though, so I'm going to show the progress on the hardware side.

I finally got around to buying some hot melt glue to finish up the control node adapter boards and the modifications to the power banks.

Insulated control node adapters:

I put hot melt glue over the back of the adapter boards.  Most of the bare spots back there are connected directly to the battery - I wanted them insulated to avoid accidentally testing the PTC fuses I put in the power banks.


I put some more hot glue in the hole in the power banks where the wires come out.  That's more to provide a little strain relief and keep bugs from crawling in and making homes in the power banks.

Here's the first completed power bank and a control node doing the first ever battery powered update:

I also did some preparation for putting the nodes out in the yard.

My original plan was to go full out redneck and just stick the nodes on a post and plop a big, empty soda bottle over the whole shebang to keep off the water.

My wife was not amused by the idea of a soda bottle on a stick in our front yard, so I changed plans.

Lots of people around here put glass decorations (colored globes and what have you) in their yards.

I bought some (cheap) decorative glass jars that will fit over the post and the electronics.  The jars look like a (somewhat plain) version of the glass thingies that
folks use for decorations.

Here's the approved "jar on a post" design:

The solar cell is charging in there - the green "charge" LED is visible.  There's also a blue "progress" LED lit, but it is hard to see.

I think I have all of the pieces together now.

The software is functional.  It doesn't have all the features yet, but I can add those in while collecting data.

The hardware is ready.  I've got a pile of sensors, and all the stuff it takes to put the nodes outside.

I've got a big pile of sensors stacked up here in my work room.

All that's left is updating the Raspberry Pi with the finished software, and putting all the hardware out in the cold.

I'll do that piece at a time over the next few days.

I have to mark the sensors so that I know which is where, and that'll take a while.

Discussions

Chris Gervang wrote 03/23/2021 at 18:33 point

Awesome progress! The ESP32 code is super informative and helpful. As I was reading and considering how I might set up my garden, I realized my raspi has Bluetooth and WiFi, and I don’t have a large garden (just two boxes).

I also have a weatherproof box, power, and WiFi next to my garden. I could collect data using the built-in Bluetooth and host the python server on the Pi. Then later if I extend my garden I could add ESP32 nodes.

I was wondering if you think there are any downsides to using the raspi without any esp32 in my situation?

  Are you sure? yes | no

Joseph Eoff wrote 03/23/2021 at 21:07 point

I don't see a down side to using just the Pi at all.

I'd get hold of the miflora Python library, though, and make things easier. 

https://pypi.org/project/miflora/

That and a bit of your own code and you are good to go.  You can cut out the MQTT part entirely if you run all the software on the Pi.

  Are you sure? yes | no

Chris Gervang wrote 03/23/2021 at 23:44 point

Awesome, that’s the library I was looking at last week too.

  Are you sure? yes | no

Joseph Eoff wrote 03/23/2021 at 22:38 point

I just noticed: "The ESP32 code is super informative and helpful."

I mashed it together any old way to get it running.  Is it comprehensible at all?  When I look at it I think "Man, what a mess."

  Are you sure? yes | no

Chris Gervang wrote 03/23/2021 at 23:44 point

Yeah, it’s clear enough to me. Informative function names.

  Are you sure? yes | no