ESP8266-SOIL Monitor

Soil is one of the rich resources in agriculture, it’s important to monitor the soil quality for health plantation,soil data will be more helpful in identifying the quality of soil and type of crops can be grown in field, using soil sensor we can monitor the soil temperature and humidity, and push data to server via esp8266. 

Block Diagram

Flow Chart

Component Required

  1. Node MCU.
  2. Soil Sensor
  3. Jumper wire
  4. BreadBoard

Software Required

  1. MIT App inventor – Android
  2. Firebase
  3. Arduino 

Circuit diagram


Login To firebase

  • create new project
  • Create database for weather monitoring device
  • Set firebase security rules to test mode to allow esp8266 to set and read database
  • Set Rules of firebase to read and write in real-time database
  • Select Real-time Database 
  • Copy the URL- Required in code as firebase host-id to communicate with firebase
  • Click to add child to Create a field to hold data in firebase   
  • Create soil_Humidity field to hold humidity data in firebase.
  • Create soil_humidity field in realtime database hold weather station data.
  • Get authentication id from firebase.

Android Application

  • Select layout to place the userinterface component
  • Create a header from the Android application: 

                 drag and drop label in the screen for app header

  • Add firebase component to app
  • Use the firebase database url, you can ignore the FirebaseToken 

Logic for soil monitoring in android app

after creating the logic download the apk file

  • Code
#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
#define FIREBASE_HOST " "
const char* ssid = "IMAKE";        // Your ssid
const char* password = "12345678"; // Your Password
void setup()
Serial.print("Connecting to ");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
Serial.println("WiFi is connected");
void loop()

int sensor_analog;
sensor_analog = analogRead(sensor_pin);
moisture_percentage = ( 100 - ( (sensor_analog/1023.00) * 100 ) );
Serial.print("Moisture Percentage = ");
Serial.print("%\n\n");Firebase.setInt("soil_humidity",moisture_percentage );