Measuring soil moisture

The sensor probe used in this project is a resistive sensor, which measures the current that is passed through the probes of the sensor. It has two probes that are physically separated; one probe is attached to a positive end and the other to the GND end. When both probes are connected by a common surface, it will measure the current that is passed through that surface and give us a reading.

In our case, when the probes touch the soil, it will measure the current that passes through. When soil gets wet, it becomes more conductive, meaning that more current will pass through the probes.

The Intel Edison ADC (analog-to-digital) converter that is in the Arduino breakout board has a 12-bit resolution, but this is limited through software to a 10-bit resolution. If we use this as the basis for our measurement, we will get the following understanding of the readings:

210 = 1024

This means that our readings will be a value from 0 to 1,023, where 0 means no water at all and 1,023 means 100% of the water. This will vary because of other impurities that are present in the soil, such as minerals. However, in this case, we will assume that the soil is perfectly measured. When it's completely dry, it will give us a measurement of 0% and if it's a glass of water without any soil, it will give us a reading of 100%.

The following code will read the soil moisture sensor every two seconds:

var mraa = require('mraa');
var pin0 = new mraa.Aio(0);
var getSoilMoisture = function() {
var sensorReading = pin0.read();
return sensorReading;
};
setInterval(function() {
console.log("Current Moisture " + getSoilMoisture());
},2000);

To run the code, type npm start in Edison's SSH console.

For testing purposes, let's take a look at the measurement readings of the sensors that are printed to the console and gain some understanding of the values:

We already know that 0 means 0% water and 1,023 is 100, which means that the sample measurement readings in the program are as follows:

Applying the reading values to the preceding formula will transform them into percentage values as follows:

Reading values
Moisture percentage
256
25.02%
307
30.00%
302
29.52%
303
29.61%
299
29.22%
298
29.13%
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.218.184