The Strava Monitor is a LED small display that shows off some of your exercise statistics from Strava. It's small enough to put on a bookshelf and only requires a single power cable. All the data is regularly pulled from Strava over a wifi connection and displayed on its screen.
The Strava Monitor cycles between two screens every few seconds:
It can easily be customised to display more screens or a variety of other statistics from Strava.
The unit can be built for around £20 or $25 worth of components.
Parts for the final product:
Tools needed to build it and get it up and running:
Skills required:
To connect the LED matrix to the Pi, you need to solder a female connector to the pHAT and a male connector to the Raspberry Pi, then connect the two parts. You can find the soldering instructions here. I used the included L-shaped male connector (as opposed to the straight one) on the Pi so that the display can be upright while the Pi is laying flat behind it.
The Raspberry Pi Zero is tiny, but this makes the setup tricky because it only has one USB port and you will have to connect the Wifi dongle and a mouse and keyboard to set it up the first time.
To do this, connect a powered USB hub to the Micro USB connector and plug it into the second USB plug on the Pi. You will remove these once it's set up. Note the first USB plug is for power only, not for connecting accessories.
Next, plug in the Wifi dongle, keyboard and mouse into the USB hub.
Connect the HDMI cable to a monitor or TV and the other end into the Pi via the Micro HDMI adaptor.
Plug the Micro SD card into a computer (via an adaptor if required)
Download Raspbian operating system for the Pi link
Carefully follow the instructions to install it onto the SD card (Mac and Windows link)
Insert the SD card into the Raspberry Pi Zero
Insert the Micro USB cable into the Raspberry Pi Zero's first USB slot and the other end into a USB wall plug or other USB power source. This will give the Pi power.
If everything is working correctly, the small green LED next to the power USB connector will start flashing while the device is booting up. Shortly you will see the Raspbian symbol appearing on the monitor or TV.
After it has booted to the desktop, click the Network symbol at the top right of the screen. It will then scan for wifi networks. If this doesn't work, it may mean that your Wifi dongle is not recognised by the Pi. Make sure you have the USB hub powered on. Most recent dongles work natively with the Raspbian operating system.
Select a wifi network and enter the wifi password.
Once you've done that, the Pi will connect to wifi and you should have internet access. Test this by opening the browser and going to a website.
Next, you will set up the Pi's configuration so that you can access it remotely via SSH from another computer via Wifi, which will allow you do remove the monitor, mouse and keyboard from the Pi.
The first step is to discover your Pi's IP address so that you can connect to it over the network. To do this, click on the black terminal icon on the top bar of the Raspbian desktop to open the Terminal.
Type "ifconfig" and then find the wireless IP address ("inet addr") under "wlan0" that will look something like 10.0.1.12 or 128.168.0.1 and make a note of it. Note it is not 127.0.0.1, there should be a different address under "wlan0".
To set up SSH and other aspects of the Pi:
Macs have SSH built into the Terminal app, so if you're using a Mac, open up Terminal.app from your Applications/Utilities folder and type "ssh pi@[ip address]" where [ip address] is the one you made a note of earlier.
If you're on Windows, download a free SSH app such as PuTTY (link) and connect to the IP address with the user name of "pi".
Enter the password you selected above. You will now connect to the Pi and you will see the same terminal screen you would see as if you were working directly on the Pi.
You can now remove power, the USB hub, monitor, keyboard and mouse. Plug the Wifi dongle directly into the Pi (see photo).
When you plug the power back in, the Pi will boot up and automatically connect to wifi.
After about 20 seconds of boot time, log back into the Pi remotely via SSH from your PC.
The next step is to enable the FTP server which will let you copy files to the Pi from your PC:
You can now access the Pi's file system remotely using an FTP application such as the free Filezilla by using the IP address, pi as the username and the password you selected earlier.
Various libraries are needed on the Pi for your code to control the pHAT LED matrix and access Strava over the internet.
In the Pi's terminal (over SSH), do the following:
Prepare the folders for your source code:
You can now test the LED display using some sample code from the pHAT library:
This step sets up your Strava account so that you can read data from it using the Pi. To do that, you need Strava to generate an Access Token which is unique to your account and you only need to do this once.
This token will be used in the next step within your Python source code to access the Strava data.
The generate the Token, follow these thorough instructions including a video:
http://yizeng.me/2017/01/11/get-a-strava-api-acces...
Note that Read access will be sufficient and you won't need Write access.
The Access Token will look something like this: a6f1aa3c70aef9f4982cf8df31796389316baa34. Make a note of that for the next step.
Download the source code within this step and edit it on your PC.
Change the Access Token near the top to match your new Strava Access Token from the previous step.
Save the file and upload it to your "strava" folder on your Pi.
You can now test the code by running "python stravascroller.py" on the Pi from that folder. It should first show a loading bar, then cycle through the two screens every few seconds.
You can set up the Pi to run your script every time it boots up, saving you having to SSH in and kick the code off every time it has been plugged out. You can also set it up so that the Pi reboots automatically at midnight every night, helping it to run smoothly.
To do this, use the CRONTAB scheduler on the Pi as follows.
The Pi should now automatically start up the routine every time you apply power.