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:
- Total Distance of all activities so far this year
- Bar chart showing the relative distance of your last 5 activities
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.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Required Parts
Parts for the final product:
- Raspberry Pi Zero link
- Scroll pHAT - LED display (buy this separately or as a bundle with the Raspberry Pi Zero) link
- Micro USB charger and cable (link) included in some Raspberry Pi kits
- USB Wifi dongle link
- Micro USB adaptor link
- Micro SD card for storage link
Tools needed to build it and get it up and running:
- Soldering iron and solder
- HDMI monitor or TV with an HDMI cable
- Mini HDMI adaptor to connect the Pi to a monitor or TV while setting it up. Included in some Pi kits.
- SD card reader to load Raspbian onto the SD card
- USB hub (powered) to connect mouse and keyboard to the Pi for configuring it the first time
- A free Strava account
- Very basic soldering
- Some python programming if you want to customise or change the code
- Some experience with Linux and Raspberry Pi helps, but not required
Step 2: Assemble the Parts to Set Up the Raspberry Pi Zero
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
Step 3: Powering Up and Setting Up the Wifi
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.
Step 4: Configuring the Pi With Remote Access (SSH)
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 18.104.22.168 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:
- Enter "sudo raspi-config" to enter the config tool
- Choose the "Expand file system" menu item so that the Pi can use all of the SD card space
- Choose Change Password and select a new password (the default is raspberry)
- Under the Advanced menu, enable both SSH and I2C
- Under Boot Options, choose to boot to the Command Line (not desktop). This will make the Pi slightly faster while running.
- Save and Reboot 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.
Step 5: Setting Up FTP for File Transfers to the Pi
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:
- In the terminal, type "sudo apt-get install vsftpd". This will install the FTP server from the internet.
- Next, edit the FTP's config file
- Type "sudo nano /etc/vsftpd.conf"
- Change write_enable=YES (or remove the # comment symbol if needed)
- Change local_enable=YES (or remove the # comment symbol if needed)
- Change anonymous_enable=YES to NO (if it's not set already or remove the # comment symbol if needed)
- Press Control-X, then Y to save the file
- Type "sudo service vsftpd restart" to restart the FTP server with the new settings.
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.
Step 6: Install the Various Code Libraries on the Pi
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:
- To install the pHAT library, type "curl -sS https://get.pimoroni.com/scrollphat | bash"
- To install the Strava library, type "sudo pip install stravalib"
Prepare the folders for your source code:
- Create a folder for your code by typing "mkdir ~/strava". This will create a folder called strava within your home folder.
- Type "mkdir ~/strava/log" where your log files will go so you can troubleshoot if needed
You can now test the LED display using some sample code from the pHAT library:
- On your PC, download the sample code here.
- Open up your FTP client and connect to the Pi
- Upload the test code to your Pi's strava folder
- Connect using SSH, go to your strava folder with "cd ~/strava" and type "python sine.py"
- The LED should now display a wavy pattern
Step 7: Prepare Your Strava Account and Get an Access Token
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:
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.
Step 8: Load the Source Code Onto the Pi
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.
Step 9: (optional) Let the Code Run Automatically Every Time the Pi Boots
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.
- Using SSH, access the Pi's Terminal and type "sudo crontab -e" to edit the scheduler config file
- Add the following to the bottom of the file:
- @midnight sudo /sbin/shutdown -r now
- @reboot /usr/bin/python /home/pi/strava/stravascroller.py > /home/pi/strava/log/stravalog 2>&
- Press Control X, then Y to save the file
The Pi should now automatically start up the routine every time you apply power.
Participated in the
Microcontroller Contest 2017