EScoreBuzz - Live Cricket Updates

by indoorgeek in Circuits > Arduino

3699 Views, 49 Favorites, 0 Comments

EScoreBuzz - Live Cricket Updates

eScoreBuzz - Live Cricket Score Updates | ESP32 + e-Paper Display
IN_Thumbnail.jpg

Hey, DIY enthusiasts! I hope you're all having a fantastic day so far.

You know, mornings like these often bring out our most creative thoughts. And speaking of creativity, I'm sure many of you have been caught up in the cricket fever lately, thanks to the exciting Cricket World Cup matches happening right now.

As the ICC Cricket World Cup fever sweeps across the globe, there's no better way to stay in the loop than with this mini score ticker. This compact marvel is your ultimate source for live cricket score updates, ensuring you never miss a moment of the action.

Supplies

IMG_2450.JPG
IMG_2448.JPG
IMG_2439.JPG
IMG_2451.JPG
IMG_2446.JPG
IMG_2444.JPG
IMG_2514.JPG

The Plan

IMG_2512.JPG

A few years ago, I created a Cricket Scoreboard using NodeMCU. At that time, Cricbuzz used to offer an XML file containing live match data. Unfortunately, my project's excitement was short-lived as Cricbuzz quickly discontinued the data feed, rendering the project useless. However, my enthusiasm has been reignited because I recently stumbled upon cricketdata.org, a cricket data API that offers comprehensive data. All we have to do is send the right request. With cricket fever sweeping the nation, I thought this would be the perfect moment to revive this old project, and this time, I intend to make it even better!

This time the plan is to use ESP-32 WiFi module to receive the raw JSON data provided by the API and then deserialize it to get the required data. The score would then be displayed on an e-paper display. The entire setup will be enclosed in a stylish casing resembling a vintage TV for added aesthetic appeal.

Not a cricket fan? No problem! You can find APIs on the internet which provide live data for the sport you like and use a similar approach and get the data.

Let's get started!

Setting Up API

tempsnip.png

Visit Cricdata.org and create your free account.

Once your account is created, a unique API key will be generated which is visible on the dashboard.

A free subscription has a limit of 100 hits per day which allows us to request data after an interval of 15 minutes without exceeding the limit. If you wish to decrease the interval, you will have to get a paid monthly subscription which increases the limit to 2000, 10000, etc. The code would still remain the same - just change the below line to the interval of your choice (in milliseconds)

const long interval = 900000; //Interval of 15 minutes

Receiving Data

Capture.JPG
tempsnip1.png

Cricketdata has assigned IDs to every match and series. There are quite a few APIs that we can use to get the data depending on our requirement. For this project, I will be using 2 APIs to fetch the score of a live match:

  • Series Info - Based on the Series ID provided, this API will give you information about the series.
  • Match Info - Based on the Match ID provided, this API provides complete details of a particular match.

"Series List" API lists out all the available series. Copy the series ID for the series of your choice.

Series ID for ICC Cricket World Cup 2023: bd830e89-3420-4df5-854d-82cfab3e1e04

Using the "Series Info" API and series ID found above, we can get the list of all the matches in a series. This is how you can send the request:

https://api.cricapi.com/v1/series_info?apikey="YOUR API KEY"&id=bd830e89-3420-4df5-854d-82cfab3e1e04

Note: Edit the URL with your API key which can be seen on the dashboard without the double quotes.

Once you send this request, you would be bombarded with a lot of information which at first wouldn't make sense. Use a JSON viewer to visualize the data. It should make sense now.

What is JSON?

JSON stands for JavaScript Object Notation. JSON is a lightweight format for storing and transporting data. It is usually used to read data from a web server. This is exactly what is done here as well.

JSON data is written in name/value pairs. They both are separated by colon (:)

"name" : "ICC Cricket World Cup 2023"

JSON Arrays are written inside square brackets [ ]

"teams" : ["South Africa","Bangladesh"]

JSON Objects are written inside curly brackets { }

{"name" : "ICC Cricket World Cup 2023"} 

Getting the data is very easy if you follow the structure. For example, if you want to get the series name, this is how you can pass it to a string.

String series_name = obj["data"]["info"]["name"];

I will be using the same logic to get the required bits and pieces from the entire raw data provided by API.

The code looks for a live match from the list by checking the value of "matchStarted" & "matchEnded". If matchStarted = true & matchEnded = false, the code then stores the match ID of that particular match which is then used to fetch the score using the "Match Info" API

PCB Design

IMG_2413.JPG
IMG_2486.jpg
IMG_2484.jpg

I got my PCBs fabricated from PCBWay.

The PCB design is going to be very straightforward. PCB will contain the ESP-32S module along with some other supporting components.

This mini scoreboard would be powered by 5V from a USB. AMS1117 is used to step down this 5V to 3.3V to power the ESP-32S WiFi module.

The PCB has TX, RX & GND pads to program the ESP-32S using a USB to UART TTL module and another set of pads to connect to the e-paper display.

There is another set of pads that would be used to connect LEDs and a small piezo buzzer.

Click here to download the gerber files.

Assembly

IMG_2498.JPG
IMG_2505.jpg
IMG_2513.JPG
IMG_2515.JPG
IMG_2523.JPG

I used Fusion360 to create an enclosure resembling a miniature retro TV, adding a distinct aesthetic charm to the design. All the parts were printed on Creality Ender 3 using PLA filament.

The enclosure is mainly divided into two parts:

  • Main Body
  • Back Cover

As illustrated in the provided 3D model, begin by carefully embedding the threaded inserts in their designated locations with the assistance of a soldering iron. Subsequently, secure the e-ink display firmly by attaching it with (4) M3 x 5mm spacers. Following this step, proceed to affix the PCB to the spacers using (4) M3 screws to complete the assembly.

I soldered one red SMD LED to the end of two lead trimmings as seen in the picture. This will act as an antenna and will be used to give a visual notification when the score updates. Solder them to the pads L (+) and G (-) on the PCB.

I desoldered the connector which came with the e-paper display and soldered wires directly between the PCB and display as seen in the picture.

The back cover is designed to securely snap onto the main body.

I used an old USB cable to power the scoreboard.

Code

1.jpg

Download the attached code and open it up in Arduino IDE.

UART Module <=> PCB pads connections

  • RX <=> TX
  • TX <=> RX
  • GND <=> GND

Select the "ESP32-WROOM-DA Module" from the board list and select the COM port.

Before you up:

  • Enter your WiFi credentials
  • Enter series ID
  • Enter API key from the Cricdata dashboard

Hold down the PROG push button while powering ON the module to put ESP32S in programming mode and hit the upload button. Once the code has been uploaded, restart the module and now the code should be running.

Downloads

Enjoy!

Sequence 01.00_02_36_20.Still001.bmp

Finally, the moment of truth. Just plug it in any 5V USB supply and enjoy the game!

Thanks for sticking around till the end! We hope you've enjoyed it. Stay safe, and we'll catch you in the next one!