Moisture Sensor Using Particle Photon

79

1

1

Introduction

In this tutorial we are going to build a Moisture sensor using a Particle Photon and its in bedded or/and external WiFi antenna. WiFi strength is dependent on the amount of moisture in the air and also in the ground. We use this principle for the measurement of soil moisture.

Step 1: Part List

  1. WiFi router
    • The router should be close to the Photon for the best results
  2. Particle Photon
    • We use this to send the data to the cloud
  3. Breadboard or something to protect the Photons pins
  4. Waterproof case
    • The case protects the Photon and power bank from the dirt and moisture.
    • It should be big enough for both the photon and power bank
  5. Power bank or power source
    • You can use whatever power bank fits in your case, higher capacity means that you can use the sensor for longer.
  6. External antenna (optional
    • You can use this to gain an increase in WiFi strength

Step 2: Basics

Make sure you have set up the photon by following the instructions of the Photon website: https://docs.particle.io/quickstart/photon/

Optional:

Attatch the external antenna as shown in the Photon's manual

Step 3: Step 1: Filling the Case

We are now going to fill the case with the power bank, photon and optionally the external antenna

Step 4: The Code

//the amount of time, in milliseconds, between measurements.
//since you can not publish too many events, this has too be at least 1000
int delayTime = 15000;
String eventName1 = "WifitestIN";
String eventName2 = "WifitestEX";
void setup(){
 //nothing to do here
}
void loop(){
 //do a measurement: read the value from the internal antenna
 WiFi.selectAntenna(ANT_INTERNAL);
 
 int measurement1 = WiFi.RSSI();
 //publish this to the Particle Cloud
 Particle.publish("Internal", (String) measurement1); 
//wait for the delayTime amount of milliseconds
 delay(delayTime);
 
  //do a measurement: read the value from the external antenna
 WiFi.selectAntenna(ANT_EXTERNAL);
 int measurement2 = WiFi.RSSI();
 
 //publish this to the Particle Cloud
 Particle.publish("External", (String) measurement2);
 //wait for the delayTime amount of milliseconds
 delay(delayTime);

Step 5: Burying the Sensor

At this point the Particle should be posting data at the interval set in code.

You can now go outside and look for a good spot to bury the device.

It should be within the range of your wifi and near the ground that you want to measure.

You should regularly check the connection when placing the device.

When buried you should now be able to see a change in signal strength when it rains.

Step 6: Data Analisis

You now have data coming into particle dashboard that is uncalibrated.

To calibrate this data you can chose to go with two methods.

  1. Low accuracy
    • For this method you log the data and look at the difference of data after and before rain.
      This gives a low accuracy guess of how high the moisture content is.
  2. Higher accuracy
    • For this method you borrow or hire a high accuracy moisture sensor to calibrate your diy sensor.
      This gives higher accuracy data compared to the first method.

Share

    Recommendations

    • PCB Contest

      PCB Contest
    • Toys Contest

      Toys Contest
    • Big and Small Contest

      Big and Small Contest

    Discussions

    0
    None
    seamster

    13 days ago

    Nice first instructable. Welcome to the site! : )