Arduino Monitor

Arduino Soil Moisture Monitor

A soil moisture monitoring system for gardens and farms.

Overview

Hardware Block Diagram

Software Block Diagram

Preparation

Get the Parts

Prepare Garden Host Computer

The arduino version of the monitor requires a host computer to be connected via USB to network enabled.

The host computer can be used to communicate with the device, upload sketches, and automatically update the device when a new version of the sketch is available.

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 Monitor Device

Use this script when you want to upload the sketch and also create all related services.

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.

Arduino Nano

Use the following commands for an arduino nano compatible microcontroller.

Syntax:

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

Notes:

  • The port needs to match the USB/serial port that the microcontroller is connected to.
  • Don't include the /dev/ in the [Port] argument. Use ttyUSB0 instead of /dev/ttyUSB0.

Example:

  • sh create-garden-monitor-nano.sh "Monitor1" monitor1 ttyUSB0

Arduino Uno

Use the following command for an arduino uno compatible microcontroller.

Syntax:

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

Notes:

  • The port needs to match the USB/serial port that the microcontroller is connected to.
  • Don't include the /dev/ in the [Port] argument. Use ttyUSB0 instead of /dev/ttyUSB0.

Example:

  • sh create-garden-monitor-uno.sh "Monitor1" monitor1 ttyUSB0

The output should look something like this:

The device has now been created and the code has been uploaded to the microcontroller.

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

Upload Monitor Sketch

Use this script if you want to upload the sketch to the microcontroller without creating the related services on the host computer.

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.

Arduino Nano

Use the following command for an arduino nano compatible microcontroller.

Syntax:

  • sh upload-monitor-nano-sketch.sh [Port]

Notes:

  • The port needs to match the USB/serial port that the microcontroller is connected to.
  • Don't include the /dev/ in the [Port] argument. Use ttyUSB0 instead of /dev/ttyUSB0.

Example:

  • sh upload-monitor-nano-sketch.sh ttyUSB0

Arduino Uno

Use the following command for an arduino uno compatible microcontroller.

Syntax:

  • sh upload-monitor-uno-sketch.sh [Port]

Notes:

  • The port needs to match the USB/serial port that the microcontroller is connected to.
  • Don't include the /dev/ in the [Port] argument. Use ttyUSB0 instead of /dev/ttyUSB0.

Example:

  • sh upload-monitor-uno-sketch.sh ttyUSB0

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-1023
  • 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 from the device before continuing on 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 soil moisture sensor adapter to the arduino expansion board:

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

Connect USB Cable

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

Check the Soil Moisture Sensor Power

The soil moisture sensor adapter LED should be flashing on and off every few seconds, as it takes a reading.

Check the Device Readings

  • pio device monitor

The output should look similar to this:

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

Testing the soil moisture sensor power is an optional step but is useful for troubleshooting and to avoid wiring problems. You can choose to skip this step and come back to it later if there is an issue.

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: