RaspberryPi ASCII Weather Station

The next guide reach that RaspberryPi launch a Go program that show the current weather and 3 days of weather forecast. I’m using a fork that I did from wego developed by Schachmat. The main program is the only program that run in the Pi, for that I forced it to start with xinit on full screen, also I included some improvments for:

Materials

  • RaspberryPi (any version should be works)
  • Any TFT display compatible (I’m using a 4inch HDMI LCD)


Note: you don’t need keyboard or mouse, this guide is a headless installation, we only need SSH.

Prerequisites

Open Weather Map API key

You can create an account and get a free API key by signing up

RaspiOS config on PC

Please first install in your SD RaspiOs lite or any Raspberry OS compatible with it on your RaspberryPi. Before run it, please add the next changes:

In the boot partition or boot folder, modify and add the next configs:

Enable SSH:

Add a simple empty file for enable SSH access in boot folder:

touch ssh

WiFi Credentials

Add your WiFi secrets on a new file wpa_supplicant.conf in the boot folder, you can generate it like this:

wpa_passphrase yourwifiname yourpassword > wpa_supplicant.conf

edit it and put the next line at the start of file:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

More info about WiFi headless configure here.

Connect your RaspberryPi

Dependencies

Via SSH, please update and install the next packages for build and run the wego application:

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install --no-install-recommends xserver-xorg xserver-xorg-legacy xinit xterm golang build-essential git

Config that Pi user can launch the xserver without root:

sudo dpkg-reconfigure xserver-xorg-legacy

in the console menu please select Anybody

Build and install Wego

go get -u github.com/hpsaturn/wego

Then configure wego like is described here. Remember only fill the settings for openweathermap.

NOTE: Unfortunately forecast.io, now Darksky, was acquired by the fuck company Apple, and they closed it, for this reason please only use these API, the steps 2 and following.

Launcher

Please edit /etc/rc.local and put the next line before the last line:

sudo su -l pi -c "xinit -geometry =800x400+0+0 -fn 8x13 -j -fg white -bg black /home/pi/go/bin/wego -- -nocursor" &

reboot the Pi and it is all, the Pi will start the Wego app like unique X application.

Improvements

Speed: Boot mods

In config.txt add the next lines to end of file:

[all]
arm_freq_min=250
core_freq_min=100
sdram_freq_min=150
over_voltage_min=0
disable_splash=1
dtoverlay=pi3-disable-bt
dtparam=act_led_trigger=none
dtparam=act_led_activelow=on
boot_delay=0

With that, we have: reduced CPU usage, no boot splash, disabled bluetooth, disabled LEDs and reduced the boot delay.

In cmdline.txt:

Edit and add to the end of the line the next changes, quiet for remove boot verbose, fastboot, noswap and ro, for improve SD life and improve boot speed:

console=serial0,115200 console=tty1 root=PARTUUID=132a822c-02 rootfstype=ext4
elevator=deadline fsck.repair=yes quiet rootwait fastboot noswap ro

Speed: Disable some services

Optional, you could disabled some unused services, for example:

sudo systemctl disable dphys-swapfile.service
sudo systemctl disable keyboard-setup.service
sudo systemctl disable apt-daily.service
sudo systemctl disable raspi-config.service
sudo systemctl disable triggerhappy.service
sudo systemctl disable avahi-daemon.service

More info about this improvement here.

Speed and life time of SD

You also could disabled some write process for improve speed and SD life:

Remove and disable the next services:

sudo apt-get remove --purge wolfram-engine triggerhappy anacron logrotate dphys-swapfile
sudo systemctl disable bootlogs
sudo systemctl disable console-setup

Replace your log manager, removing the standard syslog output of log files to /var/log and instead replace it with the busybox in-memory logger:

sudo apt-get install busybox-syslogd
sudo dpkg --purge rsyslog

Power consumption

I found a excellent guide about that, the more important thing is turn off the USB ports, but there they described other improvements.

For example for turn off USB ports, put the next line before xinit line on /etc/rc.local:

echo '1-1' |sudo tee /sys/bus/usb/drivers/usb/unbind &

Troubleshooting

Any feedback, bug or issue, please report it in the issue section.