Pi BADGEr ePaper Weather Station


This hack was featured on on 01/08/2014
This hack was featured on on 01/10/2014

ePaper Weather Station

The OHS2013 BADGEr has been transformed into an ePaper real-time weather station

At the 2013 Open Hardware Summit that I attended a few months ago, all attendees were given a “BADGEr,” a unique ePaper badge that displayed our credentials, showed the conference schedule, etc. Of course, since this was the OPEN Hardware Summit, the BADGEr (designed by the awesome folks at Wyolum) was completely open source. Not only is the BADGEr hackable, it was designed to be hacked. So, of course, I immediately started hacking on it as soon as I returned home from the summit at MIT. It didn’t take me long to write new firmware for the device, connect it to a web-connected Rapsberry Pi computer, and hang it on my wall with some custom 3D-printed brackets. I’ve been using it for the last several months as a handy weather station that I can glance at before I leave my apartment each morning. A supplementary LED beacon warns me of extreme conditions (hot, cold, or rainy). On the weekends, it shows the weather report for San Francisco (where I live), and on the weekdays, it shows the weather report for Mountain View (where I work). The display checks for new weather data and updates once every 10 minutes.

What to see it in action? Want to learn how to make it yourself? Read on!

Weather Station in Action:

Here’s a quick Instagram video (Don’t you follow me on Instagram!?) that shows the data updating, the warning light coming on, and the ePaper display refreshing. In this example, I’ve chosen to display data for New York City. Since there is a 90% chance of rain, the warning light glows a pleasant blue. Ordinarily, you wouldn’t actually see the terminal program spitting out debug data, since it runs automatically on the headless Raspberry Pi (I’m SSH‘ed into the Pi to show you what the updating process looks like).

Are animated GIF’s more your speed? Here’s a looping GIF showing the display switching back and forth between New York and San Francisco weather reports (my previous and current places of residence):

Updating ePaper Display

This looping animated GIF shows the ePaper display updating about once every 15 seconds. For demonstration purposes, it is switching between New York and San Francisco.

Here’s how the Weather Station works:

  1. Once every 10 minutes, a cronjob triggers on the Raspberry Pi. This cronjob launches a python script that uses and APIs to fetch the following data:
    1. Yahoo weather code: This corresponds to an image ID that will load on the ePaper display. Different codes represent different conditions like, “sunny”, “cloudy”, etc.
    2. City name: You provide the script with your zip code, and it will automatically get the name of the city.
    3. Current Date
    4. Sunrise Time
    5. Sunset Time
    6. Forecast (Sunny, cloudy, etc)
    7. Chance of Precipitation
    8. Temperature (high)
    9. Temperature (low)
  2. Once the script has grabbed all this info, it parses out the relevant data, and formats it to be sent over USB-serial to the attached BADGEr device. An identifying character is appended to the start of each serial string, which allows the BADGEr to determine which piece of data it is receiving.
  3. Once the Pi has finished sending data (it sends a termination character to tell the BADGEr it is done), the BADGEr parses through the data.
  4. The BADGEr identifies and loads the appropriate weather condition image from the loaded SD card (it contains a specially converted and formatted image for each possible weather condition).
  5. The BADGEr loads the remainder of the data into a buffer and sends it all to the ePaper display.
  6. Steps 1-5 repeat once every 10 minutes.

Want to Make This? Here are the Steps:

  1. Visit the GitHub Repository that I link to at the bottom of this post. Either clone it to your computer with git command line tools, or download the entire ZIP by clicking “Download ZIP” on the right side of the GitHub repo page.
  2. Remove the MicroSD card from your BADGEr and insert it into a card reader on your computer. You may need a microSD to SD adapter. Format the card.
  3. Copy the contents of the “BADGEr SD Card” folder in my GitHub repo to the SD card. Once you’ve done this, the root of the SD card should contain three files and an IMAGES folder. The Wyolum ePaper library utilizes a special image format (.WIF). I’ve taken the liberty of already converting the weather glyphs to this format, and have included the original .gif files as well. If you’d like to experiment with making your own .WIF files, you can do so by using the Wyolum python-based .WIF image conversion tool.
  4. Next, you’ll need to flash the BADGEr with my custom firmware. The BADGEr uses a standard FTDI 5-pin connector for this purpose, but NOT all FTDI cables will work. I was only able to flash the device by using the sparkfun FTDI breakout. Connect BADGEr to your computer using one of these cables.
  5. Follow the instructions from Wyolum to download and install the EReader Arduino Library. Make sure you do this with the Arduino IDE closed.
  6. Open up the “BADGEr_Display.ino” Arduino sketch contained in the GitHub repo linked from the end of this post. One you have it open in the Arduino IDE, select your USB-Serial port in Tools>Serial Port, and select “Arduino Pro Mini 3v3 8MHz” in Tools>Board.
  7. Press the upload button to upload my firmware to your BADGEr.
  8. You can now unplug the BADGEr from your computer, and plug it into the one of the USB ports on your Raspberry Pi. The BADGEr is now ready to accept serial commands that can control its screen. This tutorial assumes you already have Raspberry Pi up and running with internet connectivity. If you don’t, follow the introductory Raspberry Pi tutorials from Adafruit first. I am also assuming that you are connected to your Raspberry Pi over SSH, and that are you comfortable transferring files to it via FTP. The remainder of the steps should be performed on your Raspberry Pi (either directly, or via SSH) unless otherwise noted.
  9. By default, Arduinos (including the BADGEr) will restart whenever a serial connection is initiated with them. We don’t want the BADGEr to do that while it is plugged into the Pi. Figure out what device your BADGEr is listed as on the Raspberry Pi:
    [email protected] ~ $ cd /dev

    That will print out an exhaustive list of all hardware devices connected to your Pi. Your USB-Serial converter (the BADGEr) will likely be called something like ttyUSB* where * is some number. Scroll through the list and find those entries. If there is just one, that is your BADGEr. If there are multiple, unplug the BADGEr, re-run ls-l, and see which one disappears – that is your BADGEr. Note down the device name. With the directory appended, it will look something like “/dev/ttyUSB1”. Use your favorite editor to modify your Pi boot file so that it disables Serial resets for that device on boot:

    [email protected] ~ $ sudo nano /etc/rc.local

    Append “stty -F /dev/ttyUSB* -hupcl” (without the quotes) to the end of that file. Be sure to replace the “*” with the number for your device! Save the file.

  10. Now, you’ll need to install the Weather and Serial python libraries. Navigate to your home directory:
    [email protected] ~ $ cd /home/pi

    Download, unzip, and install the Python Weather API Library:

    [email protected] ~ $ wget
    [email protected] ~ $ tar -zxvf pywapi-0.3.8.tar.gz
    [email protected] ~ $ rm pywapi-0.3.8.tar.gz
    [email protected] ~ $ cd pywapi-0.3.8
    [email protected] ~ $ python build
    [email protected] ~ $ sudo python install

    Now, install PySerial using PIP:

    [email protected] ~ $ sudo apt-get install python-dev python-pip
    [email protected] ~ $ sudo pip install pyserial
  11. Now, on your main computer, edit my script to match your needs (you can use any text editor). When you open the file, you’ll see that there is a configuration section at the top. Right off the bat, you’ll probably want to set the “use_SUNN” variable to “False”. SUNN is a custom piece of LED lighting hardware that I’m using to act as the warning light (it’s not open source yet, but may be in the future). Make sure you set “BADGEr_dev” to match the device name that you determined earlier! Save the python script when you are done.
  12. Next up, you need to copy my script to your Pi home directory. Since you already have my entire GitHub repo for this project downloaded on your main computer, I recommend sending the file over to your Pi via FTP. The python file is located in the “Weather Checker” directory of the GitHub repo, and should placed in your Pi’s home directory (/home/pi/ Once you’ve copied it over, make sure you make it executable:
    [email protected] ~ $ cd /home/pi
    [email protected] ~ $ chmod 755
  13. At this point, you should now be able to manually run this file, and see the BADGEr display update accordingly. Assuming you are still in the home directory, manually run the script like this:
    [email protected] ~ $ ./ 10001

    The program accepts a zipcode as its one argument. 10001 is a zip code for New York City. When you run it, replace it with the zipcode for wherever you want to see the weather report. When you run the script, you should see an output on the terminal that looks like this animated GIF: Output

    This looping animated GIF shows the output of the script when you run it manually

    When you run it, you will see different text because you will presumably have the SUNN functionality disabled, and you will be using a different zipcode.

  14. As the final step, you’ll setup a cronjob to handle automatically running this script once every 10 minutes. Open up the crontab editor:
    [email protected] ~ $ crontab -e

    At the end of this file, add two lines:

    */10 * * * 1-5 /home/pi/ 94043
    */10 * * * 0,6 /home/pi/ 94117

    The first line triggers the script once every 10 minutes on weekdays. Replace “94043” with the zipcode of where you work. The second line triggers the script one every 10 minutes on weekends. Replace “94117” with the zipcode of where you live. Save and close the crontab.

  15. You’re done! You can now log out of your SSH session to the Pi. It will continue to run, and will update the display every 10 minutes with the latest weather report. Hooray!

Supporting Documentation and Code

This project is licensed under an Apache v2 Open Source License. Please Attribute and Share-Alike. You can download the source files directly from the GitHub Repository linked below:
Get it on GitHub