Building two UIs to
display Mars weather

...a simple yet complex project. Requires a quite diverse skillset

One of the most fun projects I have worked on. What I thought would be a simple project involving only some API requests and data analysis became an extensive idea that required me to get a RPi touchscreen, learn Flask app development, HTML/CSS, and using Google's app engine. I even hired an artist friend to desing my website's background


Skillset

  • API requests
  • Flask
  • Raspberry Pi
  • Python
  • Data analysis
  • HTML5
  • CSS
  • Responsive website design
  • Google App Engine
  • Some artistic side :)

Process

The project is divided into three parts. Starting with the data gathering, I used different data sources to collect information from Mars rovers. One of the main issues is that live data is basically impossible due to the bandwidth of sending back the information. Therefore, there will always be a delay in relay information - which can be from days to months. The second and third parts of the projects are the display of the information. I originally thought of only creating a Python-based GUI using an RPi's touchscreen display. However, the idea evolved into also creating a website display the most up-to-date information.

Accessing the Data

I will be using the two apps above as my data sources. The altimeter app produces a CSV file that can be parsed using Python's pandas package. For the Fitbit app, I will be creating an account and accessing their API.

Accurate Altimeter

This is a pretty good app that allows to measure your current altitude at any moment. It has the capability to record continuously and set them up at different time steps. You can also set the triangulization method to derive your altitude from the internet or use your phone's GPS instead. This is really helpful for those remote hikes where internet is spotty. However, my favorite feature is the ability to export your history to a CSV and its compatibilty with Google Drive. This is my main method to download the data without requiring to access the app's API.

Fitbit

Obtaining data from Fitbit is trickier. There is an option to download a CSV file from Fitbit's online account, but the file contains only a mere summary. Instead, their intraday time series boasts a lot more options, allowing to extract data at different time steps for a wider category of activities. To do so, we'll need to access Fitbit's API.

I've split this walkthrough in 3 main steps:

  1. Creating and registering an application
  2. First, Fitbit requires to create and register an application on their developer's site. This can be done by simply filling out the application on this link. Make sure you select "Personal" under the "OAuth2.0 Application Type" field. This allows to request any intraday time series without any additional access approvals. However, by selecting this field, your application will be limited to pulling personal data only.

  3. Authentication and authorization token
  4. Fitbit has upgraded their authentication requirements to OAuth2.0 only. Their website has amazing documentation explaining both types of authentication flows you can obtain. I decided to use the "Authorization Code Flow" and my initial code was based on this thorough post by Paul's Geek Dad Blog.
    However, I found his authorization code request a bit restrictive, thus I refactored using Python's Requests package instead.

  5. Requesting data
  6. To call the intraday time series I downloaded this Fitbit API client implementation package created by orcasgit. To install the package, clone the github repo:

    git clone git@github.com:orcasgit/python-fitbit.git


Graphs

Check my graphs and data in my Plotly dashboard.
All my graphs are interactive! You can hide each hike by clicking on it or double-click on one to select it.