Tag: sports clock

I’ve started working on the software aspects of the sports clock. The code for the sports clock are in three parts:

iOS App

Spark Core code

Node.js Backend

To store the data for each clock, I’m using Parse (soon to be shutdown so I need to migrate the database when I have more time).

Backend

The Node.js backend code listens for events emitted by the Spark Core. It then fetches from the database the MLB team that the user wants to get scores for. Then, I use the MLB API to get the scores for any live games where the team is playing.

The MLB scores api is at http://gdx.mlb.com/. For every day, there is a file named masterscoreboard.json that contains all the games for the day.

For example, on March 26, 2016, the masterscoreboard.json would be located at

You can then search through the JSON file to find any relevant games. Each game contains a property called game_data_directory that has a path to files for the game. For example it could be something like: /components/game/mlb/year_2016/month_03/day_26/gid_2016_03_26_detmlb_phimlb_1. To get the data for that game, you can tack on gd2.mlb.com to the path so the url is like:

In this directory, you’ll find all kind of helpful files containing info about the game. Linescore.json (example shown below) was the best choice for me.

I deployed the backend through Heroku.

For easy retrieving of MLB scores, I made my own npm package: mlb-scores. To install it, simply type:

npm install mlb-scores

Spark Core

To control the LED matrixes, I used the ledmatrix-max7219-max7221 for the spark core. I have a method called setScore() that is called by the server whenever the spark core asks for a score.

Since Heroku will auto sleep your code after a while, the spark core pings the server every few minutes to keep it awake. This is done through a Particle.publish() which is connected to a webhook.

I used the ParticleDev app on OSX to upload and flash code to the Spark Core and used command line to view the serial messages from the Core. The default serial monitor in ParticleDev took 100% cpu power so I used the CLI instead.