Connected things
How many times did you forget to water your flower pot? With a soil moisture sensor you will give the flower pot the instrument to alert you when it will be thirsty (see Photo 1). This example of analog input uses a soil moisture sensor to detect and report via the Internet two events: dry soil (Dry) and wet soil (Wet).
Materials required
- Smick (http://smick.tk)
- Soil moisture sensor
- Flower pot
Circuit
Connect the Soil moisture sensor as shown in Figure 1:
- Vcc PIN to 3.3V,
- A0 PIN to A0.
Note: probe PINs can also be inverted.
Tip: you can make the probe with two rigid copper wires.
Sketch
Write a sketch K to define:
- the input connection: Soil :: A0
- threshold variables: d (dry) and w (wet)
- the events to send: Dry, Wet (see Figure 2)
- the rules to turn on the status LED when the soil is dry and turn it off when it is wet.
Soil :: A0
d = 100
w = 700
Dry = Soil<d
Wet = Soil>w
Dry -> led=1
Wet -> led=0</d
or simply load the sketch in the workspace with the command
] load e16_soil_moisture
Try and learn
1. Take a glass of water and insert the sensor into the glass:
< Wet
the Wet event happens and is sent over the Internet; the status LED turns off.
Pull the sensor out of the glass:
< Dry
the Dry event happens and is sent over the Internet; the status LED turns on.
2. Insert the sensor into a dry plant and read the Soil value with the command:
] Soil #1
determine the threshold value and set the variable d.
After watering the plant and changing the threshold w, insert:
] stop
to stop reading Soil
] save
to store the new sketch.
References
Smick site: http://smick.tk
Youtube: https://www.youtube.com/watch?v=qhfoJNewfkc
Responses