Our team consists of Silvia, Paolo, Marco and Nils, which has come together in a university project. The task of this project is to measure the soil moisture in order to monitor the health of a plant. In practical terms, this is done by a system consisting of an additional soil moisture sensor connected with an Agrumino Lemon via an I2C ADC module. The obtained data will be sent to a ThingSpeak channel and thus made visible and processable.
General DescriptionThe electronic components which are necessary for carrying out the project, have been adequately connected through the support of a breadboard and jumpers. The components used, as well as the used platform und protocols are listed and described below.
Capacitive soil moisture sensor v1.2
This soil moisture sensor measures soil moisture levels by capacitive sensing. For this purpose, it is made of corrosion-resistant material which gives it excellent service life. Once inserted into the soil around the plant, it allows to monitor the real-time soil moisture data. This module includes an onboard voltage regulator which gives it an operating voltage range of 3.3 ~ 5.5 V while, the output voltage, is 0 ~ 3.0 V. For the device to function correctly, a calibration must be performed: the value obtained after immersing it in water corresponds to 100% humidity while, the value obtained in air, is that relating to 0% humidity. These are indicative values to establish a scale of evaluation of the results.
Analog-to-digital converter
The output from the sensor described above is of the analog type. Since the Agrumino Lemon board communicates only through the I2C interface, it was necessary to use a compatible analog-to-digital converter. Specifically, it was used the Adafruit ADS1115. The ADS1115 provides 16-bit precision at 860 samples/second over I2C. The chip can be configured as 4 single-ended input channels, or two differential channels; it even includes a programmable gain amplifier, and it can run from 2 V to 5 V power/logic.
Agrumino Lemon
The Agrumino Lemon DEV Board allows the operation of the entire system. In fact, Agrumino is an open-source programmable device for all your needs as it is equipped with an ESP8266 chip with connectivity to the 2.4 GHz Wi-Fi network for Internet communication. Also, it can be battery powered with a 3.7 V type 2450 battery and it has built-in sensors for:
ThingSpeak
The Agrumino device necessarily needs to have an output from which the user who is using it can read the data he needs. To do this, it was decided to use the ThingSpeak platform.
ThingSpeak is an IoT analytics platform service that allows you to aggregate, visualize and analyze live data streams in the cloud. It provides instant visualizations of data posted by your devices to ThingSpeak.
I2C Protocol
With I2C, you can connect multiple slaves to a single master (like SPI) and you can have multiple masters controlling single, or multiple slaves. This is useful when you want to have more than one microcontroller logging data to a single memory card or displaying text to a single LCD.
I2C only uses two wires to transmit data between devices:
To use the Agrumino Lemon firmware, we have used the software Arduino IDE. Agrumino offers a well-stocked library, with excellent example sketches that can be used for various applications. In our case we used as a starting point the sketch that allowed communication with the ThingSpeak platform. Starting from this example sketch you can, by modifying a few fields, customize the sketch to obtain the requested task.
The fields that will have to modify will be those concerning the Wi-Fi to which Agrumino you will have to connect and the address and the writing key of the channel ThingSpeak to which you will want to send the data.
Once done, you will be ready to read on your channel the values of the data that Agrumino allows you to read.
The Agrumino, as mentioned above, is able to read the percentage of Soil Moisture, but in our case, we want this value to be read by the Capacitance Soil Moisture Sensor.
This must be done through the I2C communication protocol of which Agrumino is equipped. To do this you will need an analog-to-digital converter. For the use of this communication protocol and the converter a specific library has been used. The library in question is Adafruit_ADS1X15.h, provided by Adafruit.
By default, the library provides an ADS reading address equal to 0x48, which however interferes with the temperature sensor of the citrus, so to avoid this problem you must change the ADS address with the following function:
ads.begin(0X49);
The converter provides values of voltages read by the sensor which must then be reported in percentage value for a comfortable reading on the channel.
Before this conversion, the sensor must be calibrated, that is, the maximum and minimum voltage values of the sensor must be defined. To do this, the maximum value is taken as the value read by the sensor when completely immersed in water and the minimum is taken as the value read by the sensor when it is completely dry. This calibration, with the use of a specific function, leads to the definition of the percentage of Soil Moisture that we want to send to the channel. The function used to calculate the fee is shown below:
int percentageHumidity = map(adc1, wet, dry, 100, 0);
Once we get this value, we can send it all to the ThingSpeak channel following the example sketch provided by the library that was used as a base.
Test and SimulationsFor the testing phase, it was planned to monitor the soil moisture of a plant. A Basil plant was used in this test. As first thing the code explained above was loaded via usb cable as shown in figure.
As you can see, both the Agrumino (not needed) and the sensor were inserted inside the soil. The latter are interfaced via an ADC converter to allow an I2C connection.
Once the program is loaded, the battery mode can be started to monitor the change in soil moisture over the course of the day. It is important to remember that data was taken every 20 minutes and started from a situation where the soil was very dry.
Soil moisture (from sensor) and temperature (from Agrumino) data and results were sent to ThingSpeak. The results are shown below:
As can be seen, the tests were started in the morning at 7:30 am. The initial soil moisture data were very low because, as mentioned above, we started from a dry soil situation. After half an hour water was added to wet the soil and in fact the value reached 94%. Then, during the day (the tests ended at 1 am), the value decreased to 62%.
As far as temperature is concerned, an interesting fact is the value recorded at the beginning of the test when it was over 30 degrees. This is due to the fact that at the beginning the Agrumino was connected via usb port (the phase in which the code was loaded) and therefore in this phase the microcontroller overheats slightly and a value higher than the real environment is recorded. Shortly after, the value stabilized at the real temperature.
Comparison between Sensor and AgruminoIt is also interesting to make a comparison between the analog sensor used by us and the humidity sensor integrated in Agrumino. The following comparison graphs are:
As you can see, the trends are very similar. However, from various simulations we found that on average the sensor records a higher percentage of humidity than the Agrumino sensor. This could be due to the fact that the analog sensor we used is able to get deeper into the ground than Agrumino, and in depth the humidity is held more and longer.
ConclusionWith this report we wanted to provide a description of how is possible to manage the monitoring of the soil through an external sensor. it was also of interest to implement the I2C communication protocol and visualization of the results on a web platform.
It is possible to implement in the future a system with more external sensors such as light sensor, temperature and so on. Another possible implementation could be the possibility to add push notifications via Telegram channel to alert the user of the ground conditions (add water or not).
Comments
Please log in or sign up to comment.