This instructable shows you how to connect your soil moisture sensor and ESP8266 to the IoT cloud.
For this project we will be using a node MCU ESP8266 WiFi module and a soil moisture sensor that measures the volumetric content of water inside the soil and gives us the moisture level as output. Measurements will be monitored over the cloud using a user friendly IoT platform called AskSensors.
So let’s start!
The soil moisture sensor consists of two probes that allow the current to pass through the soil and get the resistance value to measure the moisture value.
The FC-28 sensor is equipped with both analog and digital output, so it can be used in both analog and digital mode. In this article, we are going to interface the sensor in analog mode.
Here are the main specifications of the soil moisture sensor FC-28:
Below are the three connections diagram for connecting the soil moisture sensor FC-28 to the ESP8266 in analog mode.
On the other side, connect the two pins from the probe to the two pins on the Amplifier circuit via jumper wires.
Module 2: for moisture state. It shows an alert when the moisture level exceeds a predefined threshold.
Get this demo code from the AskSensors github page.
Set the following parameters:
const char* wifi_ssid = "......................"; // SSID const char* wifi_password = "......................"; // WIFI const char* apiKeyIn = "......................"; // API KEY IN
The analog output of the moisture sensor is used to connect the sensor in the analog mode (values from 0 to 1023). The moisture measurement will be converted to percentage values from 0% to 100%.
The Soil moisture sensor contains a potentiometer which will set the threshold value, which will be compared by the LM393 comparator and according to this threshold value the output LED will light up and down .
However, in this demo, we will not use this potentiometer. Instead we will be using an AskSensors graph to show if the moisture value has exceeded a software predefined threshold:
#define MOISTURE_THRESHOLD 55 // moisture alert threshold in %
The enclosed images show my setup. For simplicity, I'm using a cup of water to test the moisture changes.
Now we should be ready to see our data in the cloud !
The images shows the data read on the AskSensors graph. We can notice two cases:
Now open a serial terminal on your Arduino IDE. You can cross-check the AskSensors graph readings with the values being printed on your Arduino Terminal.