@tutorial: WiFi YouTube subscribers counter with Arduino

This is a very nice project and so easy to build. All we need is a WiFi module and a screen to print the values. Using the ESP8266 WiFi module we connect to the internet. Once connected, using the YouTube channel ID and the API key we obtain the YouTube subscribers count and then we print that value to a 7 segments screen module. The code refresh itself and it will beep each time the value changes. To make it look nice, I've 3D printed the case,

External Link: https://electronoobs.com/eng_arduino_tut16.php

by: ELECTRONOOBS on 2026-05-30

~Material

This project is simple. The total price is under 10 dollars. If you don't have a 3D printer you should create any kind of small case and fit everything in place. So lets see what we need.

7 segment module: LINK eBay

Wemos D1 R2 mini: LINK eBay

Buzzer: LINK eBay

3D printed case

~Schematic

The schematic is very simple. Just connect the data, load and clock pins from the 7 segment module to pins D4, D3 and D2 of the WeMos D1 R2 mini board. Also connect the buzzer to the board. To supply the circuit we will use directly the USB connector with a voltage of 5 volts.

Youtube subscriber counter Arduino tutorial
Youtube subscriber counter Arduino tutorial
~Case

The case is 3D printed. You could find the STL files in a link below. Print the file using 2 perimeters, 20% infill. I've used a 0.4mm nozzle and the Creality Ender 3 Printer. Fit everything iside the case and pass the USB cable through the hole. Close the case and that's it. You could add some nice front labels to make it look cooler.

Download: Case
~Code

Before we look at the code we have to prepare the Arduino IDE with the libraries and also the core for the WeMos development board. To install the WeMos with the ESP8266 module core you have to:


-Add the next line in to the Additional Boards Manager URLs in order to find the desired download URL.

Copy and paste this line in the Additional Boards Manager URLs:

http://arduino.esp8266.com/stable/package_esp8266com_index.json

Open Arduino IDE, go to preferences and add the line there. If you already have URL added just type a comma (,) and add the new URL. Ok, now that we've done that we can go in to boards manager and search for the needed board. For that go to tools, board, boards manager. Now that we have the URL added into the Arduino preferences the ESP8266 installing file will also appear here. Select it and press install. Once installed you should probably restart Arduino IDE.

Now if we go to boards you can see that I have a lot of extra boards added. We will use the WeMos D1 R2 board. If this doesn’t work then you should use the downloaded ZIP below. Extract the zip and copy the content into the Arduino directory, into hardware, ESP8266COM and a new folder called ESP8266. Now you should restart the IDE and try if it works.

~The 7 segments display

The thing is that we could send serial data to this module using just 3 pins. Those pins are clock, chip select and data. I’ll show you an example of that right now. I’ll connect the module to the Arduino UNO for the test. Data is pin 2, chip select is 3 and clock will be 4. All we need now to do is to shift some registers containing our data. Open the code above in the Arduino IDE and upload it to the Arduino uno and mount the next schematic.


The shift function will first activate the chip select pin which is activated by a low value. Next it will create the data on the data input pin by shifting the value that we want. In this case it will first be the address of the corresponding register on the 7 segments module. This action is followed by the same thing but with the sent data. Finally set the chip select to high and the transmission is done. Ok, so in the setup void, we define those pins as output and send the configuration data. As you can see in the code I send the address of the register and the value using the shift function. If we check the datasheet of this chip on page 7 we can see the address for the intensity, mode and shutdown. We send the corresponding value to make the display show the numbers from right to left. Next, in the infinite loop, we just send the data for each 7 segment display. Easy right.

Ok, so now we know how to print numbers on this module. Let’s see how to obtain the YouTube subscribers value.


Youtube API

Ok, now let’s see how to get our YouTube data. We have to go to GitHub once again or use the download link below. We should thank witness me now for this code. Just download the zip file as before. Now open the Arduino IDE, and go to sketch, include library, add zip library and select the downloaded zip file. And we are done. Now we should have the examples for the YouTube subscriber count. This example is compatible with the ESP8266, it will connect to WIFI and get the subscriber count.


Now open the Arduino IDE, and go to sketch, include library, add zip library and select the downloaded zip file. And we are done. Now we should have the examples for the YouTube subscriber count. This example is compatible with the ESP8266, it will connect to WIFI and get the subscriber count.

Now go to examples, YouTube APi, ESP8266 and select channel statistics. You should add your exact and full WIFI name as below. Then the exact password. Then here you should add you YouTube channel ID. For that go to YouTube. Select creator editor and select the channel icon in the corner and go to YouTube settings. There click advance and now you should copy just copy the channel ID and paste it here in the code. Now for the API key, if you don’t have one you should create it now.


API KEY

Go to google and type Get Youtube API key or use this link for that. There you select the API console and sing in with your Youtube account data. There on the library select all of the Youtube API and enable them. Accept the terms. Now go to credentials and create new credential. Once created copy the API key and paste it in the code.

Now compile and upload the code. Open the serial monitor. Ok, first we connect to the WIFI. Now you will probably wait a few minutes till the first Youtube subscriber data will show. There you go, this is my subscriber value below. The code works.


Now all we have to do is to marge this 3 examples into just one. Use the ESP8266 chip, get subscribers value and print it on the 7 segment display. Let's see how to do that in the next part.

Final code

Now all we have to do is to marge this 3 examples into just one. Use the ESP8266 chip, get subscribers value and print it on the 7 segment display. For that I’ve created this code that you should download from a link below. As before I add my Youtube and WIFI data. Next, I define the pins for the clock, chip select and data of the 7 segment module. In this case are digital outputs of the WEMos 2, 0 and 4.


Ok, down in the code I get the subscribers value and save it in a string format. Since the 7 segment display module has just one chip I can’t sent the entire 8 characters number by shifting data from one chip to another. I have to take each character of the string value and print it one by one. That’s exactly what I’ve done in this function. That’s it. I upload the code and test if it works. Success, this is my subscribers value. By the way, thank you all guys for subscribing and like my videos.


~Mount the case

Ok, so I’ve printed the case with my Anet E10 printer using PLA material, 0.4 mm nozzle, 2 perimeters and 20% infill. I take the 3D printed case, solder everything following the schematic below and glue the parts inside. I first glue the 7 segment display. Then the buzzer and screw the toggle witch in place. This switch will activate or des-activate the beep for each new subscriber value. I place the WeMos board in place and glue close the case. Now I add the extra details to make this case look better. I connect the USB cable and we are done. After the initial message I get the subscriber count. This will automatically refresh for each new value.

That’s it guys. You have all the data in this tutorial. You also have the purchase link for all the parts of this project or a new 3D printer. If you consider helping my projects, check my new Peatron page and help my workshop grow and have a lot of more other cool tutorials.

Leave a comment

Please login in order to comment.

Comments

ADVERTISERS
ADVERTISERS
PCBWAY