Connect your Raspberry Pi to a Wi-Fi network directly from PiStorms!
Rainfall Alert
The mindsensors Grove Sensor Adapter makes it easy to use a variety of unique Grove sensors with the EV3. Our custom block makes it easy to read the sensor from your program. Here is an example of using it with the water sensor.
Design
This project uses the Grove Water Sensor and the mindsensors.com Grove Sensor Adapter. It's very simple to connect the sensor, adapter, and start displaying numbers on screen. Here we have one EV3 with the sensor connected. It records the detected water number and displays it on screen. A second EV3 acts as the remote monitor. It receives the water data over Bluetooth and displays an image based on that reading.
1023 is the maximum value the sensor will return, denoting absolutely no water detected. The number will decrease as more water reaches the sensor.
The idea is to leave the first EV3 outside, putting the water sensor in a small container. When it rains the container will start to fill with water, and the water sensor will detect that. Then the second EV3 (inside, on your desk) would get the message and show you the current water level. It wasn't raining today so we just used a mug of water to demonstrate.
Without water...
With water!
Now lets take a look at the program, one for each EV3.
Program
Sensor
First, we read the raw value from the sensor. This is the default Mindsensors GroveSensorAdapter block, no options need to be changed. Then we have a switch to display "Read error" if the sensor is not connected. Otherwise, we display the number on screen. If the value is less than 1000 we'll send True (water found), or False if it's above 1000 (no water). This value is sent to the EV3 named "Alarm" with the message name "Rain detected". Finally we wait a moment because the rain level shouldn't be changing that quickly. The hope is this will help save battery, by taking a longer break between readings. You may want to leave this delay low for flash floods!
Alarm
The Alarm program is also very simple. In an infinite loop, it reads the "Rain detected" message from the Sensor EV3. If it receives a True value then it Displays the full water graphic, otherwise it Displays the empty water image. Again, we use a Wait block because we don't need to be constantly checking.
Bluetooth
While you can set up Bluetooth from your EV3 program, we found it more reliable to do so through the EV3 menu. First, go over to the settings menu (4th tab) and scroll down to Bluetooth.
Press Enter. Make sure both EV3s have Bluetooth on and Visibility set.
Select Connections and press Enter on Search.
Wait a moment while the EV3 searches for other Bluetooth devices.
Select the second EV3 from the list.
Select Connect.
Press Enter on both EV3s to confirm the connection.
Leave the default password on each, just press Enter.
Done! Your EV3s are now paired.
Go back to the programs tab and start the Sensor and Alarm programs on the EV3s.
Extensions
Why not try adding a buzzer or some other from of alert when it starts to rain? You can find a related blog post here.
Leave a comment