Introduction: Rain Notifier
In the rush to get out in the morning, do you have five minutes to check the weather alert for the day? Wouldn’t you prefer to spend that five minutes with a warm cup of coffee, reading news that matter to you? Or get those extra five minutes getting some much needed sleep? Let your umbrella stand do more than just stand there. Equip it to check the weather for you, then you can know as you walk out the door whether you need that umbrella or not. A blue light means blue sky (well no rain at least, it may be cloudy), and a blinking red means Rain Alert! Take that umbrella with you.
This is a simple project, perfect for a beginner, or for someone with just a bit of free time. In a couple of minutes, it can be up and running.
Step 1: What You Will Need
- a Raspberry Pi (any model but the PiZero will do)
- a wifi dongle
- a GrovePi
- a Raspbian for Robots SD card
- one or two Grove LED (we suggest red - and blue - , but the choice of color is up to you).
- a power supply for the Pi
- the supplied code (it’s free)
- a Wunderground API key (it’s free)
- GrovePi Case (not displayed)
- an umbrella stand (although not really needed. You could just have the alert system next to the outside door)
- some frosted glass lampshade. We used the small Knubbig from Ikea
Step 2: GrovePi Ready SD Card
You have three options for the SD card itself. Instructions can be found on the Dexter Industries website. (The GrovePi uses the same one as the BrickPi)
Your three options are:
- Buying a pre-loaded SD Card from Dexter Industries
- Downloading and use our modified Raspbian image on your own SD Card
- Modifying your own image
Step 3: Get Your API Key From Weather Undeground
Weather Underground is a service that provides weather information from all over the world. You can read more about them on their about page.
You can Sign Up for Free in order to get your personal API key.
Then fill in the signup form, the one on the left (you can safely ignore the form on the right for now). Don’t forget to read the Terms of Service before agreeing to them.
Once you click on Sign Up>>, an email will be sent to you with an activation link. Wait for that email to be delivered, and click that link! The subject line of that email will be “Weather Underground Email Service” and it will be delivered from email@example.com. In certain cases, this automated email might be caught in your spam filter, but it made it through ours easily.
You're not quite done yet though. Now your account is created, you can get your API key. Now is the time to fill in the form on your right, the one we previously ignored!
Click on Login>>, then Explore My Options>> Make sure you select the Stratus plan, which is free, and click on Purchase.
One more hoop to jump through and we’re done. Fill in that final survey, and click that new Purchase Key.
To be able to grab a copy of your API key, click on "Key Settings". You will be shown a form from which you can copy the key. Save it in a text file somewhere on your computer.
Voilà! You've done the hardest part: getting your Wunderground key! Congratulate yourself!
Step 4: Connect the Hardware
As a reminder, you will need:
- one Raspberry Pi (any model but the Pi Zero)
- one GrovePi board
- An SD card properly configured for the GrovePi (refer to http://www.dexterindustries.com/GrovePi/get-started-with-the-grovepi/ if need be)
- Wifi dongle (this project assumes the umbrella stand will be in an area where wifi is served)
- one GROVE LED to indicate rain weather (we suggest a red LED)
- optional: a second GROVE LED to indicate clear sky weather (we suggest a blue LED)
- One (or two if you choose the two LED setup) GROVE connection cable(s)
- optional: some frosted glass container or lampshade.
- Cellphone charger (or some sort of power like an appropriate battery pack)
With the Raspberry Pi *not* under power:
- Install the GrovePi onto the Raspberry Pi. If this is your first time, follow http://www.dexterindustries.com/GrovePi/get-started-with-the-grovepi/
- Plug the Wifi dongle into the Raspberry Pi
- Plug the rain LED into Port D7 (you can change that in the code, but this is the default one)
- If you choose to use a clear-sky LED, plug it into Port D8 (again, you can change that in the code).
- Put the SD card in the Pi, if not done already
- Power up the Pi
Step 5: Get and Test the Software
With Raspbian for Robots, you can click on the DI Software Update to ensure all examples and projects are transferred to your SD card. Since you will need to edit the file, and you don't want future updates to overwrite your changes, copy the file into your home directory:
cp Desktop/GrovePi/Projects/rain_notifier/rain_notifier.py ~/.
You can get the software from GitHub
- Select the whole thing, and paste it into a new file on your Raspberry Pi. Call this new file rain_notifier.py.
- On the Pi, type in:
- sudo wget https://raw.githubusercontent.com/DexterInd/GrovePi/master/Projects/rain_notifier/rain_notifier.py
First, let’s verify our setup. The rain notifier comes with a small test mode. This will turn the clear-sky LED on and blink the red LED for a few seconds. This lets you verify your setup up to this point.
sudo python rain_notifier test
and press the Enter key. The blue LED on digital port 8 should light up, and the red LED on digital port 7 should blink five times.
If the LEDs behave properly, your hardware is all nicely configured!
Step 6: Configure the Software
Now all you need to do it customize the module to your own geolocation.
Edit the file by opening it with nano
Any line that starts with a # is simply a comment and is not part of the actual program. They’re explanations from us to you.
You only need to edit three lines
zipcode = 'YOUR_ZIP_CODE'
api_key = 'YOUR_WUNDERGROUND_API_KEY'
clearled = 8
Change YOUR_ZIP_CODE to your actual zip (or postal code), make sure to keep the quotation marks.
Change YOUR_WUNDEGROUND_API_KEY with what Wundeground assigned you and keep the quotation marks there too.
If your clear-sky indicator is on port 8, then leave that third line alone. If you choose to have only one LED, then set this one to -1.
Then hit Ctrl-X to exit.
Click the Y key to confirm that you want to save the changes.
And then press Enter to confirm the filename.
Your changes are done, you now have a working system!
Step 7: Other Configurations
The software offers more configuration options:
BLINK = True
DELAY = 5*60 # in seconds
METRIC = 1
RAIN_THRESHOLD = 1
rainled = 7
The application works fine without changing these parameters, but they are available to you should you wish to customize it.
BLINK will determine whether your rain alert will blink to get your attention. Set to False if it annoys you.
DELAY is how often Wundergroud will be polled. It's set to every five minutes, but there isn't a need to poll that often. You can poll every half hour and still be safe. Don't poll more often than the default, as Wundeground sets a limit on the rate of polling.
METRIC: do you live in a metric area, or an imperial system one? 1 means you are in a metric system area, and 0 means you are not.
RAIN_THRESHOLD is the amount of rain that can be predicted to fall before triggering an alarm. If a little bit of rain doesn't bother you, then leave it at 1. The unit here is determined by the above variable. If METRIC is set to 1, then it will be in millimeters, if METRIC is set to 0, it will be in inches.
rainled is the digital port for the rain LED, should you wish to change it.
Step 8: Finishing Touches
Put the two LEDs at the bottom of a small frosted lampshade. We got one from Ikea, called Knubbig. We used clear tape to keep the LEDs in place at the bottom. That way, the lamp is still functional as a regular lamp too. Put the lampshade near your umbrella stand, or near your front door. Run a final test, then hide the Raspberry Pi behind the umbrella stand.
- Lamp - second option
You can also watch the video for another finishing touch
It's best if you set up the pi to run the rain notifier without human intervention. That means that you only need to power up the Pi, and the program will run.
Type the following:
sudo nano /etc/rc.local
Scroll down near the end of the file. Before the line exit 0, type in
Adjust the path according to your needs.
Boot up the pi and let it do its magic.
Participated in the
Raspberry Pi Contest 2016