Plant Monitoring and Watering System Using Hexabitz

Set up your Pi to automatically take care of your plant by reading a moisture & weight data from Hexabitz modules, and watering when needed.

Load Cell Sensor (H26R0x): H26R0x is a load cell (strain gauge) sensor interface module based on Avia Semiconductor HX711 Wheatstone bridge ADC and STM32F0 MCU. This module is a precision 24-bit analog-to-digital converter (ADC) designed for weigh scales and industrial control applications. It interfaces to load cells (strain gauges) in a Wheatstone bridge configuration. The module accepts a full bridge (5-pin connection) as well as a secondary sensor connection (2 pins).

To use a load cell module, first you need to calibrate it. To do this add the following APIs to your Hexabitz load cell module code.

Calibration(20, 1.9242, 0.0094);

Load Cell: A load cell is a transducer which converts force into a measurable electrical output. Although there are many varieties of force sensors, strain gauge load cells are the most commonly used type.

A load cell consists of a metal core and a set of electrical resistances that transform when a force is applied to it. But after the force is removed, it returns to its original state. The reversibility of this material determines the quality and accuracy of the load cell. The equivalent electrical circuit of a load cell is as follows:

Our load cell has 4 wires:

🔴 Red for Excitation+

⚫ Black for Excitation

🟡 Yellow for Output+

🟢 Green for Output-

STLINK-V3MODS Programmer (H40Rx): H40Rx is a programmer module which contains STLINK-V3MODS stand-alone debugging and programming mini probe for STM32 microcontrollers (Hexabitz modules and other MCUs).

It supports the SWD (Serial Wire Debugging) interface for the communication with any STM32 microcontroller located on an application board.

It also provides bridge interfaces to several communication protocols, allowing for instance the programming of the target through bootloader.

SPDT Mechanical DC Relay (H0FR1x): H0FR1x is a compact mechanical DC relay module capable of driving DC loads up to 30V / 8A.

It is based on Omron G5LE-14-DC3 SPDT relay and STM32F0 MCU.

SPDT Mechanical DC Relay (H0FR1x)

Moisture Sensor: Analog Soil Moisture Sensor can read the amount of moisture present in the soil surrounding it. It’s a low tech sensor, but ideal for monitoring an urban garden or your pet plant’s water level. This is a must have tool for a connected garden!

This moisture sensor uses the two probes to pass current through the soil, and then it reads that resistance to get the relative moisture level. More water makes the soil conduct electricity more easily (less resistance), while dry soil conducts electricity poorly (more resistance).

It can be helpful to remind you to water your indoor plants or to monitor the soil moisture in your garden.

How does it work? The voltage that the sensor outputs changes accordingly to the water content in the soil.

When the soil is:

Wet: the output voltage decreases

Dry: the output voltage increases

The ADC on the Hexabitz is a 12-bit ADC meaning it has the ability to detect 4096 (2^12) discrete analog levels.

The way an ADC works is fairly complex. There are a few different ways to achieve this feat (see Wikipedia for a list).

To start, we need to select ADC channel.

void ADCSelectChannel (uint8_t ADC_port,char *side)

And then do the analog to digital version by using the ReadADCChannel API:

void ReadADCChannel (uint8_t Port,char *side,float *ADC_Value)

The value that is returned and stored in x will be a value from 0 to 4095. Hexabitz has a 12-bit ADC (4096 (2^12)).

And to reading the analog signal, & convert it to digital value as a percentage (0-100) you can use this API:

float GetReadPrecentage (uint8_t port,float *precentageValue)

Note: Calling Get Read Percentage API will replace using ADCSelectChannel API, if it was called then the reading will be exclusively from the “bottom” layer.

Steps 📝

1) Planning the array and assembling the hardware:

We prepare the project components and plan our array design by aligning modules side-by-side. Then we solder the modules together using Hexabitz Fixture.

2) Writing codes with STM32CubeIDE software:

Check out this article for writing code with STM32CubeIDE.

After creating the topology for the two modules and setting their configurations, we add the topology for each module. See this link for help in creating a topology file.

Based on the calibration values, the programs below define the ranges to determine the status of the soil 🪴

These values were first monitored using the STM32CubeIDE debugging function to monitor live expressions.

These limit values change depending on the kind of plant 🌲🌳🌾🌿🌱🌴🌵🥀🌷

Note: You can use Receive Weight function in BOS_Porting.cpp in HF1R0x-Firmware/src/hexabitz folder to display weight values on your Pi.

3) Test the System 🪴🚿😊⚖️


Picture of Aula Jazmati

Aula Jazmati

Electronic Systems Engineer Hexabitz Ambassador RaspberryPi Volunteer translator

Leave a Replay

Leave a Reply

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

Follow Me

My Latest Posts

Sign up for our Newsletter

Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit