Moisture Sensor Using Particle Photon
by Ranja_Max in Circuits > Arduino
694 Views, 1 Favorites, 0 Comments
Moisture Sensor Using Particle Photon
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.
Part List
- WiFi router
- The router should be close to the Photon for the best results
- Particle Photon
- We use this to send the data to the cloud
- Breadboard or something to protect the Photons pins
- 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
- 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.
- External antenna (optional
- You can use this to gain an increase in WiFi strength
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 1: Filling the Case
We are now going to fill the case with the power bank, photon and optionally the external antenna
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);
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.
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.
- 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.
- For this method you log the data and look at the difference of data after and before rain.
- 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.
- For this method you borrow or hire a high accuracy moisture sensor to calibrate your diy sensor.