Learn how to build In-Plants, a mesh-connected soil monitoring system

Tired of killing your houseplants? Here's how you can build a connected houseplant monitoring system using an Argon, a few Xenons, and Particle Mesh.

Nick Engmann article author avatarNick EngmannMay 06, 2019
Learn how to build In-Plants, a mesh-connected soil monitoring system

Particle has discontinued development of Particle Mesh, our OpenThread-based mesh networking solution, and will no longer be manufacturing the associated Xenon development board. Particle will continue investing in its other “Gen 3” products, the flagship cellular (Boron) and Wi-Fi (Argon) product lines. Read more about the deprecation here.


I have plenty of thriving plant babies around the house that I like taking care of. But much like regular children; I am more fond of my 3D printers and gaming hobbies and often forget to water them. So I sought to create a simple project to monitor the health of my houseplants with the following qualifications:

  • Low cost: I don’t want to spend a large amount of money to monitor a cheap plant.
  • Low power consumption: And if I can’t remember to water a plant I probably won’t remember to charge a battery.
  • Easy to develop, deploy, and monitor remotely.
  • Avoid cords/cables if possible.

Keeping all that in mind I decided to use my Particle Mesh hardware that I preordered from Particle to build In-Plants.

Editor’s note: This post originally appeared on Hackster and is republished here with the author’s permission.

What is Particle Mesh Hardware?

For those who are unfamiliar with Mesh networking, the idea is simple. Instead of having multiple devices that all speak to your home router directly you have one “gateway” device that speaks to the router and the other devices, or nodes, in the network speak through each other to send data to that gateway device. This way each node of a mesh network talks with each other and amplifies the signal, which ends up creating strong wireless coverage.

In the Particle Mesh topography the Argon acts as a gateway between my router and the rest of the network which lets each mesh device have its own IP address. The remaining Xenons connect to the internet through the Argon; allowing them to publish things directly to the internet without being directly connected to my router.

Sounds Cool Nick, But Why Is This Important?

Particle Gen 3 hardware: two Xenons and an Argon.

It’s important to explain this because using mesh networked devices allows me to fulfill a large portion of my requirements. While the Particle Argon device has to maintain a solid connection to my router for internet traffic to pass through, the Xenons do not. This will allow me to place any or all of my Xenon’s into a sleep state and have them only periodically wake up a few times a day to connect to my Argon and transmit the appropriate data.

By entering a low power sleep state I can conserve a lot of battery power for a majority of my In-plant monitors. Plus it helps that Particle devices are cheap and relatively easy to use because of the large community support system.

A small fleet of In-Plant units deployed outside.

3D Print the Enclosure

First things first, let’s take some time to print all the enclosures. We are going to want to start these prints first because it will take approximately 2 hours to get the rest of the project setup. You are going to need one full set for every plant you want to monitor, and it took my printer setup approximately 45 minutes – 1 hour to print all the necessary parts for one setup. You can find the hosted Enclosure files on Thingiverse.

3D printed In-Plant enclosures — STL files available here.

Setup the Argon

After beginning the prints we are going to go ahead and start to register our Argon device. To reiterate, the Argon acts as the gateway device for the rest of the Mesh network. Meaning that the Argon connects directly to your wireless connection and the Xenon’s will connect to it. It’s important to set up the Argon first and correctly so you will have an easy time setting up the remaining Xenon devices.

For this portion of the setup I’m going to direct you to Brandon Roberts’ guide on how to setup an Argon Mesh device. He did a wonderful job putting the sets together and his guide helped me get my network up and running. You can also feel free to use the quickstart guide that comes with the Particle Argon. If you are having any issues check out Team Particle’s video on how to add an Argon to your network.

Setting up my Argon — make sure your Argon is flashing blue.

The last step in setting up the Argon allows you to name your network, I named mine particle-plants, but feel free to name both your network and your devices anything you want.

Use a network name that’s easy to remember. I picked particle-plants.

Setup the Xenon

If you are just wanting to monitor a single plant then you won’t need to setup any Xenon devices. However, if you want to create the mesh network pick up a Xenon and let’s get started.

For this portion of the setup I’m again going to be redirecting you to Brandon Robert’s guide on how to set up Xenon Mesh devices. It is very similar to the Argon article, just follow the dialog prompts on the Particle app and you should be able to set up your Xenon devices. Each device takes approximately 5-10 minutes to completely setup. If you are having any issues check out Team Particle’s video on how to add a Xenon to an existing Mesh network.

Follow the remaining on-screen prompts to complete the Xenon setup.

Firmware Updates

Now that your Mesh network is connected to the internet they can now proceed to initiate Over the Air (OTA) updates. OTA updates happen automatically and take around 5 – 10 minutes for each device. This step is important because you will need the latest firmware version, 0.9.0 (Gen 3), for the software to run correctly. You will know that the device is currently doing a firmware update by the LED indicator on the top of the device. If your Xenon is blinking magenta (red and blue at the same time), it is currently loading an app or updating its firmware, this happened for me after connecting to the Mesh network for the first time and again after I programmed my Mesh network devices.

The Xenon flashes magenta during a firmware update.


During this process, you won’t be able to program any device in the Mesh network, so just sit back for a bit while we wait to program the devices with our In-Plant software.

Program the Mesh Network

Once everything is connected and updated we can head on over to the Web IDE and let’s flash our devices! Feel free to start with either the inplants-argon or inplants-xenon code that can be found in the In-Plants repo on Github.

Simply copy the code from the *.ino file and paste it into the Web IDE code editor.

Copied code for the In-Plants Argon.

Then go to the Devices sub-menu (indicated by the Crosshair icon) and select which device you would like to flash by clicking on the star next to the device.

Flashing my Argon from the Web IDE.

Next, go ahead and click the lightning bolt symbol in the top left corner of the Web IDE to flash that device. Repeat that process for all the Mesh network devices and you’re ready to move on to installing the hardware into the In-Plant device enclosures.

Selecting the lightning bolt symbol to flash the starred device.

Install Devices into Enclosures

First let’s start by gathering all the materials that we are going to need including our particle mesh hardware, lipo batteries, connector cables, 3D printed enclosure, and screws.

Gathering all my materials for the build.

Our goal is to solder everything inside our enclosure, so we are going to have to cut and solder a few things in order for it to look like the following circuit diagram.

In-Plant circuit diagram.

First, we are going to cut the Capacitive Soil Moisture Sensors’ connector cables so that we can solder them directly to the Particle hardware. I simply cut mine in half, leaving about 4″ on either side.

Cutting the capacitive soil moisture sensor cable.

Next, we are going to want to cut the header pins off of our particle devices. This is in order to make sure the particle device fits snugly into the In-Plants enclosure.

I removed the headers from the Gen 3 Particle hardware.

Now we are ready to begin soldering! Heat up your soldering iron and connect the capacitive moisture sensor cable red/black/yellow wires to 3.3V/GND/A1 on the particle board.

Soldering the plant sensor directly to the header-less Xenon.

Then you will want to go ahead and solder the switch and battery cables together. This step is going to be a little difficult because the soldering may need to be done inside the enclosure depending on cable length.

Soldered connection between the switch and the battery.

Finally, you are ready to place the particle inside the enclosure, using the bolts to secure everything in place and plug in the power source and turn it on by sliding the slide switch.

An assembled In-Plant showing the Xenon and the capacitive moisture sensor.

Marvel at a Job Well Done

Great job soldering and setting up the hardware! You should now have fully functioning In-Plant devices so let’s go ahead and turn them on and see what happens.

In-Plants in planters with plants

First things first, make sure your In-Plant device with the Argon (the one with the wifi antenna) is turned on. Then go ahead and turn on the remaining In-Plant devices. You will know the In-Plant is properly connected when you see a slow beating Cyan light on the front cover. If you see a slow beating Green light multiple minutes after turning the device on you may have internet connectivity issues which could resolve in you having to go back through and setup the Particle Mesh device again.

Breathing cyan, visible through the In-Plants enclosure

Next, we want to make sure that we can see the data coming in from the In-Plant devices. So go ahead and place your In-Plant device in a plant pot and go to the Particle Web Console. From here we should see a live update of the plant sensor data and voltage levels of the various devices in your In-Plant network. The devices are currently setup to report their values every 6 hours.

The Xenon devices are placed in a sleep state in between reads to drastically improve battery life. The Argon is kept awake the entire time and reports once every 60 seconds. This is because the Argon needs to maintain a connection to the router to transmit traffic to the Particle Cloud. Because the Argon needs to stay awake, its important that you connect the In-Plant device with an Argon to a power source. A worthy sacrifice in order to keep the rest of the mesh network battery efficient.

A view of the data coming in from the Particle events.

Remember that you still need a Frontend

So we’ve ensured that our sensor data is actually being sent to our Particle Cloud, but reading data values this way isn’t easy and quick to digest, so I quickly pieced together a frontend to visualize the data coming in.

I found a bunch of different services online to visualize this data, including thingsboard.io and freeboard.io but in the end, I settled for something both free and easy to setup for this prototype. I ended up going to Thingspeak and utilizing their free visualization tools. They aren’t anything super fancy, but they get the job done, so here is a quick tutorial about how to use them. If you want to utilize a different frontend architecture or design your own (like I intend to do in the future), feel free to skip this section, but you’re also free to imitate my setup as seen in the images below:

Humidity readings displayed on my dashboard.

Creating a ThingSpeak Channel

First, you are going to want to head over to the ThingSpeak website and create an account. After successfully logging in, you are going to want to create your first channel. Give it a name, description, and set a field for each of your In-Plant sensors. For my first channel, I am going to only monitor the soil humidity levels of all my In-Plant sensors.

Above you can see my In-Plant channel settings.

Afterward, click on the API Keys and note your Write API Key

Creating a Particle Webhook

Next, you are going to want to create webhooks using the Particle Console to request your In-Plant sensor data from. To do this navigate to the Integrations Menu by clicking on the Icon in the Particle Console.

The integrations icon is found on the left menubar of the Console.

Click on “New Integration and then Click Webhooks. You can then click on Custom Template.

For this project I used the Webhooks, available in the integrations section of the Console.

Replace the code block in the Custom Template page with the following codeblock. Make sure to replace the field with your ThingSpeak Write API Key from the previous step.

{
"event": "plantStatus_percentage",
"deviceID": "",
"url": "https://api.thingspeak.com/update",
"requestType": "POST",
"noDefaults": true,
"rejectUnauthorized": true,
"form": {
"api_key": "",
"field6": "{{{PARTICLE_EVENT_VALUE}}}"
}
}

Finally, go back to the Webhook builder screen and select a specific device you would like this webhook to target.

Select the specific device you would like this webhook to target.

Repeat the “Creating a Particle Webhook” step for every device in your In-Plant network whose humidity you would like to track. If so you will have a webhook for every device in your In-Plant network.

Webhooks for days!

After doing so we can go back to our ThingSpeak channel to view the humidity levels of our entire network.

If you also want to monitor the voltage levels of all the devices in your In-Plant network repeat the “Create a ThingSpeak Channel” and “Creating a Particle Webhook” step but this time using the following code block in your Custom Template for your voltage readings.

{
"event":"plantStatus_voltage",
"deviceID":"",
"url": "https://api.thingspeak.com/update",
"requestType":"POST",
"noDefaults": true,
"rejectUnauthorized":true,
"form": {
"api_key":"",
"field6":"{{{PARTICLE_EVENT_VALUE}}}"
}
}

Conclusion

Currently, that’s all I have to show for In-Plants. It’s my first step into mesh networking and there are tons of improvements that I would like to see with this project including but not limited to:

My own frontend that is hosted locally. ThingSpeak is alright for now but it is definitely a little limiting. Would like something that allows the user to input what type of plant they have (fern, succulent, etc.) and have the appropriate humidity level scale appear.

Figure out a way to incorporate a sunlight sensor on the device, to tell how much sunlight my plants and receiving.
Solar power? If I could recharge using solar that would save me some time from going around and recharging my In-Plant devices manually.
Some sort of pump to automatically water the dirt if the plant humidity level falls below a certain threshold.

??? Please hit me up if you have any questions or would like to collaborate on any portion of this project, I’d love to talk! ???