Hi, we are Ilaria, Daniele and Roberto. We teamed up as the UniCAS team with the aim of developing our final project for the CPSA’s course (Cyber Physical Systems Architectures). It consists in the use of Agrumino Lemon, a device based on an ESP8266, to send data into a Thingspeak channel. In this way we are able to compute and visualize the corresponding moisture level of the soil through a preprocessing of the voltage signal measured by the sensor.
In order to employ the Agrumino Lemon firmware, we used the Arduino IDE software. There, we can find the Lifely Agrumino library, which contains many pre-baked functions and examples, particularly useful for taking advantage of all the specifities of Agrumino Lemon. The aforementioned functions made us able to acquire a voltage, that is the result of the measure carried out by the humidity sensor, and send its value to the first field of our ThingSpeak channel. Such field which will, therefore, correspond to the voltage measured by the sensor.
In addition, in order to avoid unnecessary battery drain, Agrumino normally stays normally in sleep mode, however, every 5 minutes, it wakes up from the sleep state to send the data it has collected.
Step 2 - Matlab codeAt this point the Matlab code running in the Thingspeak server will take from field1 the voltage measures in mV and the percentages of the different terrain types, saved in fields 3-4-5.
The latter, knowing the Write API key of our channel, can be inserted through an HTTP POST on the browser.
Considering that field3, field4 and field5 represent respectively the percentages of sand, clay and loam in the monitored terrain, we can construct the URL as follows:
https://thingspeak.com/update?key=xxxxxxxxxxxxxxxx&field3=xx&field4=xx&field5=xx
The humidity level values are obtained from the curves associated with the three types of soil as a function of the voltage measured by the sensor. These curves are given as a collection of points, so a linear interpolation is computed on these data to accommodate intermediate voltage values.
The computed humidity values for the three soil type are then averaged based on the inserted percentages, sending the computed humidity value to the field2 of the channel.
In the figure below it is shown one of the three characteristic curve.
After the data gathering we can visualize all the discussed measures in the associated ThingSpeak channel, reachable from the following link:
https://thingspeak.com/channels/1429676
To test our system we positioned Agrumino in a dry soil and started it, together with the server running the Matlab code.
As we can see from the plots the humidity is initially very low, but after watering the soil the humidity immediately increases up to 50%.
After some hours, we tested how the system would react consequently to a change in the percentages of the different terrain types. During the testing, we noticed that a drop in the humidity curve had appeared, however it showed to be not dependent on the measured voltage but actually on the repentine change in the relative weight of the three curves. In this case we increased the weight of the dryier terrain type.
With this example we have shown how it is possible to realize a smart system to monitor the humidity level of the soil.
Possible improvements can be the exploitation of other useful metrics, such as the temperature or the light intensity, and of a more important feature that reflects perfectly a cyber physical system: the decision taken from the cloud and their actuation in the physical world.
In our case, the proposed system may be used to automatically activate a water pump whenever the soil moisture level has decreased below a certain threshold.
Comments