7 in 1 Soil Monitor

by Itrium in Circuits > Sensors

1863 Views, 8 Favorites, 0 Comments

7 in 1 Soil Monitor

FRONT.jpg

In gardening, knowing the condition of the soil is an important factor in growing successful crops. Over the last few years, sensors have become widely available that can measure many soil properties by using electrical measurements. Besides water content, these sensors can measure soil conditions like pH, temperature and fertiliser concentration letting the gardener know when to water and feed the plants.

This Instructable shows how to connect one of these sensors to the internet and plot the results on Thingspeak. These charts provide a detailed report on the state of the soil and provide guidance about any remedial action. The readings from this sensor could also be used to automate a watering or fertigation system to control moisture, pH and NPK levels.

Supplies

Soil sensor ComWinTop 7 in 1 soil sensor

ESP32 development board

MAX485 module

Arduino IDE

ThingSpeak account

Soil Sensor

RS485-4-20mA-Soil-Temperature-Humidity-Moisture-Conductivity-EC-PH-Sensor copy.jpg

The soil sensor used in this project was the WinComTop NPKPHCTH-S which can measure 7 soil properties with a single sensor. This unit will operate with a supply voltage of 4.5 to 30V using an RS485 data interface. A series of 8 hex numbers are sent to the sensor to request a reading and then the sensor will reply with a further 8 hex numbers which contain the reading. It is important to send the correct error checking code otherwise the sensor will reject the request.

There are similar brands available but the hex codes may need changing and the operating voltage must be less than 5V.

MAX485 Interface

e6b5224ee425fc4db6d63cbc2e6199f0.jpg

The soil sensor uses an RS485 interface which allows the use of long twisted pair cables up to about 1km. However, microcontrollers use TTL levels for communication. An RS485 to TTL convertor is therefore required to connect the sensor to a processor that can generate and read the numbers used by the sensor. Fortunately, these interfaces are readily available and very cheap at about $1each.

In this project, a MAX485 module was used with a 3.3V supply voltage. Although the module is specified for a 5V supply, it worked well at 3.3V. There is a lower voltage version, the MAX3485 specifically designed for lower voltages but this was not found necessary.

There are two pins labelled DE and RE on the MAX485 that enable transmit and receive data. The two pins can be conveniently connected together as transmit and receive are never required at the same time. Thus 3 GPIO are needed on the microcontroller, one each to transmit and receive data and the third pin to define the MAX485 mode.

ESP32 Microcontroller

MFG_ESP32-DEVKITC-32UE.jpg

There are many microprocessors capable of communicating the required codes to the sensor. An ESP32 development board was eventually chosen for several reasons:

It has an extra hardware serial port to interface with the MAX485

The development board takes a 5V supply from a USB socket

There is on board WiFi to connect with the internet

It is cheap and readily available

Some development boards have their own WiFi antenna but using an external antenna gives better range.

By running the MAX485 module at 3.3V, the module can be directly coupled to the ESP32 without worrying about voltage levels.

Wiring

cct.png

The MAX485 module and ESP32 are directly wired together with soldered joints to avoid problems with loose connections. After connecting the two boards together, the 4 wires from the soil sensor are soldered to the MAX485. A small plastic box may be used for further protection. The next step is to load in the software.

Software

IMG_0417.JPG
IMG_0415.JPG

The software for the ESP32 is loaded into the board using the Arduino IDE with a PC. There is plenty of information about doing this on the internet, the code for this project is listed in the file.

The best way to view the soil readings is graphically and so the results from the sensor are sent from the module via WiFi to a ThingSpeak visual display. To do this, you will need a ThingSpeak account and the corresponding API key. Again, details for all this can be found on the internet.

Your WiFi router SSID, password and API key need inserting into the ESP32 code and uploaded into the board. Results from the sensor can be viewed from the serial port or plotted graphically through ThingSpeak. Many of the results will be zero until the sensor is placed in damp soil.

Conclusion

The soil monitor can measure moisture content (humidity), temperature, conductivity and pH quite effectively. NPK readings need treating with caution. The NPK values seem to be estimated from the conductivity measurement and there is an option to scale the values to match the real world. This will give a rough idea of NPK but nothing like what is achieved by a dedicated test.