Weather forecast on a RaspberryPi printer – now with added Pi

Here’s how I get the weather printed on my RaspberryPi-powered GoFreeRange internet printer every morning at 6AM.

My daily weather forecast


  • I made a GoFreeRange printer using a RaspberryPi instead of an Arduino.
  • I signed up for IFTTT and got it to send a local weather forecast as a text file to a folder in my DropBox account each day at 6am.
  • I wrote a shell script on the RaspberryPi which looks to see if there’s weather forecast in my DropBox account. If there is, it downloads it to the RaspberryPi. It then moves the remote DropBox copy of the forecast to another remote DropBox folder so it doesn’t get printed again. The script then calls a Python script to send the forecast to the GoFreeRange printer backend server so it prints out on my printer.
  • I scheduled this shell script to run every 5 minutes on the RaspberryPi using crontab.



I know there’s a Printer Weather app for the GoFreeRange printer, but I can’t get it to work and, knowing nothing about Ruby, I don’t have a clue how to install it myself – but I still want a weather forecast to come out of my little printer first thing in the morning.

The first time I got this working, I had to have a Mac turned on, as this was running JD Harper’s Python script to poll DropBox for new files to print. Having to keep a Mac running was a bit of a drag, especially when my little printer is being run by a RaspberryPi that just loves to run Python scripts.

The problem is that although there’s a Linux version of DropBox, it doesn’t work on the Pi’s ARM processor, and you need to have a DropBox folder mounted or sync’d locally on the Pi for the script to work.

Then I discovered Andrea Farbrizi’s Dropbox-Uploader shell script. This doesn’t mount or sync a DropBox folder by itself, but it does allow you to upload and download files to and from DropBox on a RaspberryPi. Incredibly useful! So I installed it on my Pi and got it working.

I also installed JD Harper’s Python script on the RaspberryPi – amazingly this pretty much worked first time, much easier than it had been to get running on my old iMac.

Daily weather forecast on my little printer

I put everything in a folder called /home/pi/dropbox/gfr/ on the Pi including a directory called txt for the downloaded weather text files, with 2 sub-directories, one called ToPrint and another called Printed.

I had hours of fun making sure all the files were accessed by absolute paths and filenames so when the scripts were run by cron, cron would know where to find everything. (Cron’s not very good at looking for things, you really have to point things out to it. It must be a man.)

My IFTTT recipe looks rather like this, except I’ve changed it so the resulting file is always called ‘weather.txt’ – this just makes the coding a bit easier on the Pi:
Using IFTTT to print daily weather forecast on my little printer

Here’s what my shell script looks like:

#!/usr/bin/env bash

# bash script by Giles Booth
# (c) 2013 Giles Booth
# for printing daily weather report on my Go Free Range printer
# using Andrea Fabrizi's Dropbox-Uploader shell script
# and JD Harper's python script to poll local
# folders and send text files to the GoFreeRange backend print server

# put a directory listing of Dropbox ToPrint folder in a text file
/home/pi/dropbox/gfr/ list txt/ToPrint > /home/pi/dropbox/gfr/ToPrint.txt

# if there's a remote file called weather.txt download it and move
# remote copy to 'Printed' folder in my DropBox

if grep -R "weather.txt" /home/pi/dropbox/gfr/ToPrint.txt
/home/pi/dropbox/gfr/ download txt/ToPrint/weather.txt /home/pi/dropbox/gfr/txt/ToPrint/weather.txt
/home/pi/dropbox/gfr/ upload /home/pi/dropbox/gfr/txt/ToPrint/weather.txt txt/Printed/weather.txt
/home/pi/dropbox/gfr/ delete txt/ToPrint/weather.txt
echo "no weather found"

# clean up list of files to print
rm /home/pi/dropbox/gfr/ToPrint.txt

# now run the python script to print local text files
python /home/pi/dropbox/gfr/

And here’s what my crontab.txt looks like:

*/5 * * * * /home/pi/dropbox/gfr/ > /home/pi/dropbox/gfr/tempfile.txt 2>&1

This runs every 5 minutes and writes a log file called tempfile.txt so I can see what’s been going wrong, if anything. I loaded the crontab with the
crontab crontab.txt
command. I still need to get this cron task to load up when the Pi is first switched on, though.

The other thing on my ‘To do’ list is to get the Pi to print any file in my DropBox ‘ToPrint’ folder, not just one named weather.txt

Daily weather forecast on my printer - rain, of course

This entry was posted in computers, internet, Linux, Raspberry Pi, Raspbian and tagged , , , , . Bookmark the permalink.

10 Responses to Weather forecast on a RaspberryPi printer – now with added Pi

  1. J. D. Harper says:

    Awesome! And thanks for the tip about the drop box script for the Raspberry Pi. That’s going to make it *much* more useful!

    • blogmywiki says:

      Thank you, and thank you so much for your Python script which is what got me going on this in the first place. It works a treat on the Pi. Next I’d like to see if I can get the DropBox script to download ANY files in the remote txt/ToPrint folder, rather than just one called weather.txt – and maybe add some pictures somehow?

  2. Pingback: Printing Daily Weather Forecasts with Raspberry Pi #piday #raspberrypi @Raspberry_Pi « adafruit industries blog

  3. This is great – going to blog about it. You should put this forward to the Foundation for going on their homepage. It’s just the kind of reproduceable project they like :-)

  4. Pingback: Weather forecast on a #RaspberryPi printer | Raspberry PiPod

  5. Pingback: พิมพ์คำพยากรณ์อากาศ | Unofficial of Raspberry Pi Fan in Thailand

  6. Pingback: Weather forecast | mrbankscomputing

  7. Matthew says:

    I know this will make me look dumb, but can this type of thing be used for a regular old epson or HP printer that one might have laying around or gotten free from craigslist?

    • blogmywiki says:

      Hi Matthew – not dumb at all, it’s a very good question.

      It must be possible, but the thermal printers are line printers, printing text one line of text (or pixels) at a time.

      You’d need to find out if it’s possible to send the same text / images to a printer over USB – but those are usually page printers, printing a whole page at a time. The joy of the till roll printer is that it’s rip-and-read.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>