ESP WiFi Monitor

ESP WiFi Soil Moisture Monitor

A WiFi based wireless soil moisture monitoring system for gardens and farms.

Preparation

Get the Parts

Prepare Garden Host Computer

The ESP WiFi version of the monitor requires a host computer to be connected to the same network running the MQTT broker. The MQTT broker allows devices to communicate.

The host computer can be used to upload sketches then the USB cable can be removed and the device deployed.

Once completed you should have a terminal window open that looks like this:

Use this terminal in the GreenSense/Index directory for commands provided throughout this guide.

Install Sketch

Connect via USB cable

Connect the device to the garden computer via the USB cable.

Choose an Installation Approach

Choose between creating a device (including network functionality) or simply uploading the sketch on its own. You don't need to run both because the "create" script takes care of uploading.

Create ESP WiFi Monitor Device

The script does the following:

  • uploads the sketch to device
  • adds the device to the Linear MQTT Dashboard user interface
  • adds the device info to the /devices/ directory

Note: If you only want to upload the sketch then use the upload script below.

Syntax:

  • sh create-garden-monitor-esp.sh [DeviceLabel] [DeviceName] [Port]

Note: Don't include the /dev/ in the [Port] argument. Use ttyUSB0 instead of /dev/ttyUSB0.

Example:

  • sh create-garden-monitor-esp.sh "WiFiMonitor1" wifiMonitor1 ttyUSB0

The output should look something like this:

Upload ESP WiFi Monitor Sketch

Notes:

  • If you've already run the "create" script above then you don't need to run this as it has already been run.
  • This script can be used if you want to update or re-upload the sketch directly.

Syntax:

  • sh upload-monitor-esp-sketch.sh [DeviceName] [Port]

Example:

  • sh upload-monitor-esp-sketch.sh wifiMonitor1 ttyUSB0

Note: The port needs to match the serial port the monitor is connected to.

The output should look similar to this:

Once you see data being written to the screen the device is running, and should now respond to commands.

Note: Press CTRL+C to exit back to the terminal.

The D; prefix indicates the line contains data.

The following keys and values are displayed:

  • T (Time) - The number of seconds since the system started.
  • R (Raw) - The raw sensor value 0-1024
  • C (Calibrated) - The calibrated sensor value 0-100.
  • D (Dry reading) - The value expected when the soil moisture sensor is dry (used for calibration).
  • W (Wet reading) - The value expected when the soil moisture sensor is wet (used for calibration).
  • Z (Version) - The version of the current version of the sketch.

Disconnect USB Cable

Disconnect the USB cable so the power is off before continuing with assembly.

Assembly

Install Soil Moisture Sensor

Connect two wires to the soil moisture sensor:

  • Note: These wires can be connected either way because the sensor has no polarity.

Connect the same two wires to the soil moisture sensor adapter:

  • Note: These wires can be connected either way because the sensor has no polarity.

They should now be connected like this:

Connect 3 wires to the soil moisture sensor adapter:

  • Blue - AO - The analog signal coming from the soil moisture sensor.
  • Yellow - VCC - The 5v power supply to the soil moisture sensor.
  • Green - GND - The ground wire of the soil moisture sensor.

Connect the 3 wires to the arduino development board:

ESP12E Development Board

  • Blue - AD0 (Analog 0)
  • Green - G (Ground)
  • Yellow - D6

Wemos D1 with Sensor Shield

  • Blue - A0 (Analog 0)
  • Green - G (Ground)
  • Yellow - D12

Test the Device

Connect the USB Cable

Connect the device to the host computer using a USB cable.

Monitor Device Output

View the device output:

  • pio device monitor --baud 115200

The output looks similar to this:

Test the Soil Moisture Sensor Readings

Submerge the soil moisture sensor in water (or similar):

The values should change to something like this:

The calibrated (C) value doesn't go all the way to 100 because the system hasn't yet been calibrated. It is currently operating with the default calibration values.

Troubleshooting

Test the Soil Moisture Sensor Readings

The soil moisture sensor readings can be tested to ensure that it's working correctly.

Test the Soil Moisture Sensor Power

The soil moisture sensor power can be tested to ensure that it's working correctly.

Calibrate via Mobile Device

The simplest way to calibrate the monitor is to set up networking and then use a mobile device.

Upgrade to Irrigator

The monitor system can be upgraded to the irrigator system by adding a pump: