The Water Sensor module used in this article produces analogue readings depending on the water level the sensor is submerged in. You can use the Breadboard block to read this information and trigger actions of other blocks.
- First, connect your Breadboard to your WiFi and Power Station Blocks:
- Add the block to the canvas and open its Properties Panel:
-
Click on the ‘Visual Map’ button and configure pins 1, 2 and 3 as follows:
IO1: AnalogIn
IO2: VCC
IO3: GND
- To connect the sensor to your Breadboard, you can use a male to female connector:
- Connect the cable to your Breadboard block making sure the line from the ‘S’ side of the board is connected to pin 1:
If you configured your Breadboard block properly, a red LED light in the Water Sensor module should light up.
We are now ready to create our program, a good example could be to create a logic to monitor the water level and trigger an alarm if the water goes below a certain point, for this, we will use a Virtual block. -
Add a Sound Player virtual block and connect it as a child of the Breadboard:
-
Finally, go inside the Breadboard’s Logic maker, add and connect the following gates:
INPUT -> LESS THAN -> SUSPEND -> ACTION
How does it work?
The INPUT Gate receives the analogue readings the Water Sensor produces and pass them to a LESS THAN Gate, this gate will compare the values with the number you typed in, if a value is ‘less’ it allows the event to pass through. The SUSPEND Gate receives the event the first time and lets it pass through, then it goes to sleep for 5 seconds. This gate is used to prevent the alarm from triggering multiple times. Finally, the ACTION Gate instructs the ‘Sound Player’ block to reproduce the ‘Siren’ sound.
Keep in mind that the value inside the LESS THAN Gate will depend on the level of water you want to measure. To help you calibrate the right values, you can add a DISPLAY Gate and attach it to the INPUT Gate to visualize in real time the readings from the sensor, then just introduce the Water Sensor slowly in a glass of water (do not allow the electronic components to get wet) and check the readings it produces.