IoT Sports Scoreboard
There are many times when we just need to keep update with the game score of our favorite sports team or we are busy with some work and just need the score update rather than watching the live game on TV. I personally like to study for my exams and keep glancing at my mobile phone for the cricket scores, but at times it becomes distracting due to notifications from different apps in my mobile phone. So, i decided to make a device which would display the game score on a 16x2 LCD display and keep updating in real-time.
Supplies
Things you will need to make this project are:
- ESP32 Dev Kit (You can also use ESP8266)
- 16x2 I2C LCD Display
- Arduino IDE installed in your computer
- Few jumper Wires
- Breadbord (For Prototyping)
Circuit Connections
The connections are fairly simple which can be seen in the above image. Also, if you are using esp32 for the first time, you need to install some drivers into your Arduino IDE. I would suggest you to go through this instructable by Fernando Koyanagi.
Setting Up Thingspeak Account
You need to create a free account on thingspeak.com and then under App dropdown select thingHTTP app. Then click on new thingHTTP and give it a name of your choice. I will name it live cricket score. We will fetch live sports score from a sports website called cricbuzz. For this demo i am showing for cricket, but you can get scores of any sports (football, basketball, etc.) of your choice by just changing the website. Then you need to provide the URL of that website in thingHTTP app.
Copying Xpath
Then go to the sports website and select the game for which you want the live scores, right click and select inspect. A highlighted blue line will have the data of scores. Right click on that line and select copy and the copy its XPath. Paste that into Parse String as shown in the image, and then save the thingHTTP.
Testing the API
After saving the thingHTTP, we will receive an API which will contain all the required information of live score which will get updated in real time. Copy that API and paste into the browser, if everything goes well we will obtain a string which will be as shown in the image. We will use this API in our ESP32 code in the Arduino IDE to fetch the data.
Uploading the Code
There are few changes we need to make in the code. Change your wifi SSID and PASSWORD to your ssid and password. Also, paste that API obtained from the thingspeak into url1 as shown in the image. We will get the whole data from the API in a variable Data_Raw in string format. We need to parse this string to get only the required data (team name, score, overs, etc.) and display on the LCD display. For this we make use of inbuilt functions of arduino called indexOf() and remove(). If there is a tournament going on, you just need to upload the code once and it will fetch the team name, score and other information for every game itself. Upload the code and enjoy the game on your 16x2 LCD display!
Downloads
What's Next?
An enclosure can be designed and 3-D printed to provide it a neat look and it can be powered with a single 18650 rechargeable Li-ion battery to make it portable. Also, buzzer can be added and code can be modified slightly so that it can alert us when any important event takes place in the game. For example, if a player hits a six or homerun or a goal, the buzzer will buzz for 3 seconds. This is just an example but the possibilities are endless.