Weather Printer
Overview
The weather printer collects local weather data, and prints it on thermal receipt printer. It will print the weather at 8 in the morning, so you know what the weather will be for the next 24 hours (unless you loose the printout, and/or have a bad memory)
How it works
An electric imp polls an ec2 instance to get the latest weather, this is returned as a bitmapped image which is then sent to the serial input on the thermal printer.
The ec2 instance internally loads an x server, fires up firefox, loads a weather page that I created and turns that into an image. I then use imagemagick to convert that to a 2 bit black and white image, and return it in bmp format.
The weather page connects to the open weather map api, and returns a 5 day forecast for cambridge, MA. I look through the first 8 results (3 hours per result) resulting in 24hours of forecasting.
I used bootstrap for the formatting, and a weather icon font for the weather symbols.
Status
The printer outputs when power is applied, but does not yet work on a regular schedule. I have attached a button to one of the electric imp pins, so will probably use that to trigger prints.
Specifications
Code
For the weather images I used the Climacons weather font - Climacons To grab the page as an image I used wkhtmltopdf - wkhtmltopdf
Start
I used aws to spin up an ec2 instance, using Ubuntu 12.04
To Install wkhtmltopdf
cd /tmp
wget http://wkhtmltopdf.googlecode.com/files/wkhtmltoimage-0.10.0_rc2-static-amd64.tar.bz2
tar xvjf ./wkhtmltoimage-0.10.0_rc2-static-amd64.tar.bz2
chown www-data:www-data ./wkhtmltoimage-amd64
chmod +x ./wkhtmltoimage-amd64
mv wkhtmltoimage-amd64 /usr/bin/wkhtmltoimage-amd64
cd ~
Install lamp, imagemagick, x11, fonts
sudo apt-get update
sudo apt-get install apache2 php5 php5-mysql php5-gd imagemagick xvfb a2ps libx11-dev
Generate Image
Code to this can be found on the weather-printer github page - Weather printer
Sending to the printer
The electric imp grabs the generated image, and sends it to the printer. This was modified from electric imp example code.
To do
- I need to build an enclosure for the printer, housing it all in one unit
- I'll also need to setup timing, so it prints at 8am every day, or set it to trigger from the button
- The fonts seem to be rendering as the default firefox fonts, I need to see if I can update these
Last edited by Richard at 11:18pm on 10th of June 2014