- Pin | Description
- VCC - > +5 Volts Power Source
- GND -> Ground or negative power source
- DO -> Digital Output. (low when moisture exceeds threshold)</td>
- A0 > Analog Output - 0 -4.2 volts. The lower the voltage, the greater the moisture.
Connect the two pins on the probe to the plus and minus pins on the mh-senor.
Now we need to connect mh sensor to our Wemos in the following way
- MH - > Wemos
- VCC -> VCC
- GND - > GND
- A0 -> 35
Connect the Wemos board to the computer via USB and check lights on the sensor and the Wemos.
The code below is all you need to get the measurement of the voltage across the probe which can be translated into the percentage moisture of the soil.
Replace the following values of the following variables names (Place the correct value between the quotation marks right of the variable names in the code):
ssid
- with your WiFi network name.
password
- with your WiFi network password.
device_secret_key
with your device secret key from the Wia Dashboard (the one that begins withd_sk
).
In the Arduino IDE:
- Select the
Wemos lollin32
board
- Select the appropriate port
- Click
Sketch > Upload
in the menu
Go to the Wia dashboard and view the events as the come in the Wia debugger.
Now we are going to set up a flow in the Wia flow studio that gives you a push notification when the moisture percent passes a certain threshold. The Wia app is required to send a push notification to your phone, it can be installed herefor Android and here for ios.
Go to your Wia Dashboard and in the space you setup before, go to flow section in the left side bar and create a flow. You can name whatever you prefer.
In flow studio, drag an event node
from the triggers section and:
- Enter moisture as the the event name
- Add the device that matches the one added to the code earlier
Drag a function node
from the logic section and copy and paste the following code:
if
The Output from the soil moisture sensor is a number between 0 and 4200 with zero being completely wet and 4200 being completely dry.
All the code above does is sets to not process the output when there is no input or if the input is less than 3000 (i.e The doesn't plant need watering)
Finally, and a notification node
and enter The plant is needs watering
in the text field so that Wia can send a notification to you when your plant needs watering.
Thats it! If you are having any problems, drop us a line below and we'll help you out.
Comments