Mornings are harried. Who has time to check the weather report?
This cool Raspberry Pi build was put together for ZDNetters by John Cole of Dexter Industries. It turns your dumb umbrella stand into a smart rain detector. As you pass in front of it on your way out, it will alert you to expected rain with a red light.
Note: I have not affiliation with Dexter Industries, but plenty of admiration for their DIY ethos. If the maker bug catches you, check out their great assortment of build tools and ingredients.
What you'll need for this project:
- a Raspberry Pi (any model)
- a WiFi dongle
- a power supply for the Pi
- an ethernet cable if your WiFi is not already set up on your Pi
- a Grove Pi board
- a GrovePi-ready SD card
- one or two Grove LED (we suggest red and blue , but the choice of color is up to you).
- A grovePi case (highly recommended for this project but not strictly necessary)
Or you can get all of the above (and more for future projects) in our kits: GrovePi+ Starter Kit (all the above items)or GrovePi+ Base Kit if you already own the first four items on the above list and don't want the GrovePi case.
- the supplied code (it's free)
- a Weather Underground API key (we'll help you get a basic one - it's free)
- 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:
- some lace doily (or other cover if you're not into lace)
Step 1: Connect the hardware
With the Raspberry Pi *not* under power:
- Install the GrovePi+ onto the Raspberry Pi. If this is your first time, follow Getting Started with GrovePi+ Step 1
- Put the two boards into the GrovePi+ case
- Plug the Wifi dongle into the Raspberry Pi USB port (any of them)
- Plug the rain/red LED into Port D7
- If you choose to have a clear sky/blue LED, plug it into Port D8
- Put the SD card in the Pi, if not done already
- Power up the Pi
The electronics part of the project is over!
Step 2: Connecting the WiFi
Your project will need to be connected to your WiFi network. If your Pi is already connected to your WiFi network from a previous project, you can skip this step, and go straight to step 3.
If this is your first time connecting a Dexter product to WiFi, you can follow the steps found under the GoPiGo section. They are equally valid for GrovePi+. Follow the explanations for Step 1 / Option 2, and Step 2.
You will need the Ethernet cable to connect to your laptop or desktop. Once WiFi is set up, the Ethernet cable will no longer be needed for the remainder of this project.
Step 3: Getting the rain notifier software
With your Pi/GrovePi+ connected to the Internet, use your computer to remote login into the Pi (either via VNC, or a terminal)
- If you have VNC:
Run DI Software Update to update the SD card.
- If you're using a terminal:
Type in the following commands:
sudo git clone https://github.com/DexterInd/GrovePi
This will pull down all enhancements for the GrovePi+, including the software needed for the Rain Notifier project.
If you want just the code for this project, you will need to use the Terminal window and do the following:
- Navigate to where the projects reside:
- Test to see if the code is already on the card
Navigate to this specific folder:
If this line gives you an error, then the software is not yet on your card and you will need to manually download it. First let's create the folder where it will reside and move into the new foldersudo mkdidr rain_notifier cd rain_notifier
- Download the python code itself
Enter the following all in one line:
At this point, you're ready to test your present setup!
sudo python rain_notifier.py test
This should turn the blue LED on, and blink the red LED for 10 seconds, then turn the LEDs off.
Step 4: Getting your Weather Underground weather key
Weather Underground is a service that provides weather information from all over the world. You can read more about them on their about page.
To get your API key, go tohttp://www.wunderground.com/weather/api/ and click on "Sign Up for FREE!"
Then fill in the signup form, the one on the left (you can safely ignore the form on the right for now):
Your handle will be your username. Use a password that will be unique to this site and make a note of it on a piece of paper (unless you really trust your memory). Also don't forget to read their Terms of Service, and agree to them by clicking that little box.
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 the provided 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.
Clicking on the link doesn't mean you're done yet though. The API key itself hasn't been created yet.
You now have your Weather Underground account, but not your API key. Now is the time to fill in the form on the right, the one we ignored previously! (Hopefully you noted your password down on paper)
Once you click on Login, it will create your account, display some info really quickly in your browser, then move on to another page. Don't worry, you can still get your key. Now click on "EXPLORE MY OPTIONS," make sure you have the Stratus plan, with a total of $0 USD (we like free!) and click on "Purchase Key."
Almost there!One more hoop to jump through and we're done with this API Key. Fill in that final survey:
Your contact name is yours, the project contact email is also yours. The fields that are filled in are just our suggestions. Feel free to adjust. Every field in this form must be answered. And then click on "Purchase Key" (your cost is still $0)
Your key will be listed here:
but it's not copy/paste-able (and yes, that's now a word). You can either take a note of it on paper or click on to get a form where the key can be selected and copied into your computer clipboard for safekeeping.
Voilà! You're done with step 4, getting your Wunderground key! Congratulations!
Step 5: Customizing the code
For this project to work properly, you will have to make a minimum of two changes in the code, although we provide a few more options that you may wish to play with.
The two mandatory changes are:
- entering your zip code (or your postal code)
- entering you Weather Underground Key
To do this, you will need to edit the program by typing:sudo nano rain_notifier.pyand scroll down a few lines until you find the one that states
zipcode = 'YOUR_ZIP_CODE'
Change YOUR_ZIP_CODE for your own zip code (or postal code), keeping the opening and ending quote. Your Zip Code is not sent to Dexter Industries, but it is sent to Weather Underground as a way of customizing the weather information for where you live.
Change YOUR_WUNDERGROUND_API_KEY for the key that you got on the Weather Underground website in the previous step. Here too, keep the opening and closing quote around the key.
Then press Control-X to exit
Your changes are done!
To launch the program, run the following in the command line:
sudo python rain_notifier.py
Will it rain today for you?
Step 6: Launching the rain notifier automatically
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.
Step 7: Finishing touches
Now there are a few more features that you can activate or deactivate within the code.
If you go back in and scroll down a bit, you will find the following:
sudo nano rain_notifier.py
If you have chosen to use a second LED to indicate the absence of rain, this is where you would set its port. The default is port 8. If you do NOT want a second LED, change the 8 to -1If you don't want your rain LED to blink at all, you can change it here. Just set it to False (yes, the uppercase F is important, in case you were wondering)
Put the two LEDs at the bottom of a small frosted glass. We got one from Ikea, called Knubbig. Fix the lampshade near your umbrella stand, or near your front door.
Cover the GrovePi+ case with a doily, or anything that fits your decor. Watch the video to see how a doily is actually advantageous.
How to get code for this project
The easiest way to get the code is to update your Dexter Industries software through the "DI Software Update". When you do this, all of the code files for new projects like this will show up!
Once you've run the DI Software Update, this project will be found in this location:
The project is named rain_notifier.py