Thermal Receipt Weather Printer
Prints a daily weather forecast on an ESC/POS thermal printer, such as the "Bisofice Mini BT thermal receipt printer".
Dependencies | Setup | Usage | Cron
Dependencies
Python 3
Pillow : The Python imaging library.
: The Python imaging library. ImageMagick: For converting SVG icons to a printable format.
Setup
Install dependencies: On Debian/Ubuntu: sudo apt-get update && sudo apt-get install imagemagick python3-pil On other systems, install ImageMagick via your package manager and Pillow via pip: pip install Pillow Get the weather icons: Run the script with the --download-icons flag to download only the necessary icon files: ./printweather.py --download-icons Or git clone https://github.com/erikflowers/weather-icons
Or download the zip.
Usage
Run the script, redirecting the output to your printer device (e.g., /dev/usb/lp0 or /dev/ttyUSB0 ).
The script can be run from any directory by providing its full path:
/path/to/print-weather/printweather.py > /dev/usb/lp0
Supplying Coordinates
You can provide GPS coordinates and timezone via command-line arguments or environment variables. If none are provided, the script defaults to London, UK.
The order of command-line arguments is: LATITUDE LONGITUDE TIMEZONE
As command-line arguments:
# Example for London ./printweather.py 51.5072 -0.1276 " Europe/London " > /dev/usb/lp0
As environment variables:
LATITUDE=51.5072 LONGITUDE=-0.1276 TIMEZONE= " Europe/London " ./printweather.py > /dev/usb/lp0
Scheduling with Cron
To run the script automatically at 5am every day in the system's timezone, edit the crontab with crontab -e and add the following line.
Use environment variables to configure the location and timezone.
0 5 * * * LATITUDE=51.5072 LONGITUDE=-0.1276 TIMEZONE="Europe/London" /path/to/print-weather/printweather.py > /dev/usb/lp0