YouTube Subscriber Counter

by InterlinkKnight in Circuits > Arduino

6071 Views, 51 Favorites, 0 Comments

YouTube Subscriber Counter

DIY YouTube Subscriber Counter (E-Paper Display + ESP32)
Tutorial For YouTube Subscriber Counter
warning indicators.jpeg
Diagram.jpg
Schematic.png
PCB Done_000000.jpeg
P1010244.JPG

I always wanted a YouTube Subscriber Counter that look good and clean. With the availability of e-paper displays for hobbyists like us, this idea became a reality and I've seen many people doing it, but I want to take my own approach and make the process as easy as possible for anyone that wants to build their own.

PCB sponsored by PCBWay - Full feature custom PCB prototype service: https://www.pcbway.com/

It runs on AA x4 batteries and thanks to the high efficiency of the components used, it can run for many months and even years without having to replace the batteries.

I include the sketch (code) file, the links to buy the parts, the STL files for 3D printing and I even include the gerber files so you can order the custom PCB to facilitate soldering the components.

Code Features:

  • It shows the amount of subscribers and views of your YouTube channel.
  • You can select to show the complete numbers or an abbreviation (1,234 → 1.23K). On 2019 YouTube started to abbreviate the subscriber count so even if you select to see the full amount, it's going to show a bunch of zeros to the right depending on the value (1,234,567 → 1,230,000).
  • It shows the date and time from the last update, using NTP servers.
  • Optimized to use as little power as possible, in case you use batteries. This includes turning OFF Wi-Fi when not in use, reducing CPU speed and going to deep sleep mode when waiting for the next refresh. Also, we can control the power of the display with a NPN transistor to be able to turn ON the display only when updating.
  • You can set to wake up and refresh the data every X amount of seconds or set the time of day (example: 3AM) where you want to update the screen. It uses the data taken from the time server to calculate for how long to stay sleep, depending on the set interval.
  • Warning Indicator - Connection:
  • No Wi-Fi: The icon is 4 bars with an X over it.
  • No Internet: The icon is a globe with an X over it.
  • Warning Indicator - Battery (optional):
  • Low Battery: The icon is a battery with a small line, as almost empty.
  • Battery Empty: The icon is a battery with nothing inside and an X over it.
  • The ESP32 will permanently sleep if the battery voltage is too low. This is to prevent draining the battery beyond the safe limit, and to avoid having an unstable situation where the ESP32 would crash for lack of power.
  • It tries multiple times to connect with the time server and YouTube API if necessary and it adds timeouts to make sure it doesn't wait forever.
  • You can select the date format as "MM/DD" or "DD/MM".
  • Screensaver: To prevent screen burn-in (ghosting) we can set to clear the screen multiple times before printing the stats screen.
  • It automatically adjusts the spacing and position of the values and icons on the display depending on the value of the view count.
  • Optionally show a grid to use as a guide to center the components.
  • Print to the serial monitor detailed data about what's doing.

Physical Features:

  • Compact design.
  • It can be hang in a wall or stand in a flat surface using the retractable leg.
  • Since we use a e-paper display, it doesn't produce light so it's not intrusive in the room is at.
  • Power consumption:
  • Average current when updating: 45mA
  • Current when deep sleep: 0.014mA
  • In my real life test, it lasted 3 years on alkaline AA batteries (x4).

Limitations:

  • Maximum amount of subscribers and views allowed is 999,999,999,999,999.
  • The wake up time can be off by several minutes or even hours.
  • The time shown when it refreshes after a long deep sleep can be off by several minutes. I'm not sure why this happens and I could not find a solution, but it shouldn't matter that much if you choose to wake up every day. When resets, we get an accurate time, but when it wakes up after deep sleep, the longer it stays sleep, the larger the time shown is off.
  • All the warning indicators can refresh only when we do a complete refresh cycle so don't expect them to update in real time.

Supplies

Parts:

Recommended tools for this project:

Note: As an Amazon Associate I earn from qualifying purchases.

Files:

Test the Display

E-Paper Display Tutorial_000000.jpeg
ESP32.jpg
ESP32 Board installation 1.jpg
ESP32 Board installation 2.jpg

If you have an ESP32 Development Board (I recommend you do), or an arduino uno/nano, test the display with an example code or maybe the main sketch of this project.

Here's a video tutorial to help you with this: https://youtu.be/g7nUAa2SQqI


Connection from the E-Paper Display to the ESP32:

  • BUSY = 4
  • RST = 16
  • DC = 17
  • CS = SS (5)
  • CLK = SCK (18)
  • DIN = MOSI (23)
  • GND = GND
  • 3.3V = 3.3V

If you never used an ESP32 on your Arduino IDE, you need to install the board going to "File > Preferences" and add this link in "Additional Boards Manager URLs": https://dl.espressif.com/dl/package_esp32_index.json

Then go to "Tools > Board > Boards Manager...", search for "ESP32" and install it.

Remember that you also need to install a few libraries:


Get YouTube API Key and Channel ID

API Key_000000.jpeg
channel id_000000.jpeg
test_000000.jpeg

In the sketch you need to add, beside the network name and network password, the YouTube Channel ID and YouTube API Key for your channel.

To get your YouTube Channel API Key, go to the Google API webpage: https://console.developers.google.com and make sure you are logged in to your gmail account.

In the "Dashboard", click "Create Project". Choose a name for the project and click "Create".

You should see "Enable APIS and Services". Click that and then write in the search box for "YouTube Data API v3". Enable it and "Create Credentials". In the page to create credentials you'll see in small letters the link to create a "API key". Then click "API restrictions" and select "YouTube Data API v3". Click create and then you'll see your key, which you need to add on the sketch.

You also need your Channel ID. You can find it in your advanced account settings. In the top right, click your profile picture and then Settings. From the left Menu, select Advanced settings. You'll see your Channel ID.

Test the API is working by going to this address in your browser: https://www.googleapis.com/youtube/v3/channels?part=statistics&id=PutYourYoutubeID&key=PutYourYoutubeAPIKey

Replace "PutYourYoutubeID" with your YouTube ID and "PutYourYoutubeAPIKey" with your API key.

Solder Components to the PCB

PCB Layout.bmp
PCB componentsr_000000.jpeg
P1010280.JPG
P1010278.JPG

You could use an ESP32 development board, but they consume too much power when they are in deep sleep mode, and since I wanted to use batteries, I decided to use a bare ESP32 module and solder the minimum components to it. Sounds annoying, but it's not as complicated as you might think. I even solder everything with a traditional soldering iron, instead of a heat gun. To make it easier, I designed a PCB especially for this project, and you can order it from PCBWay (sponsor) using my gerber files.

It cost just $5 USD for 10 PCBs and the process is very simple.

I listed all the components that goes on the PCB, but there's one that requires some testing before soldering. I choose this voltage regulator (HT7333-A) because is very efficient consuming very little power while not having a load, but I discovered that not all units have the same performance. I bought a bunch of them and I measured the current without a load to see which one is the best to use in my PCB. This is because I want the batteries to last a long time and it's critical to get very low power consumption when the ESP32 is in deep sleep mode. So you should test them without a load and choose the one with least power consumption.

Assembly - Display Frame

P1010250.JPG
P1010266.JPG
P1010267.JPG

Remove the protective film from the display and attach the display to the [Display Frame] 3D printed part. I like to keep everything in a way that allows taking everything apart, just in case, so I recommend using something like masking/painter's tape to attach the E-Paper Display to the [Display Frame].

Assembly - Display Ribbon Flex Cable Adapter

P1010269.JPG
P1010272.JPG

Screw the small Ribbon Flex Cable Adapter to the [Display Board Support] 3D printed part using the M3x4mm HEX screws. It should go directly into the plastic so there's no need for nuts.

Assembly - Display Board Support

P1010273.JPG

Glue (I recommend Loctite Super Glue) the [Display Board Support] to the [Display Frame] in a way that the Ribbon Flex Cable, when connected to the display, has a natural curvature and aligned correctly. This cable is usually not perfectly centered in the display so that's why we need to glue this part accordingly to each display.

Assembly - Spacers

P1010274.JPG

Glue one [Spacer] on each corner of the [Display Frame]. Make sure they don't come out from the frame because then it would not let the frame fit the Shadow Box.

Assembly - Battery Holder

P1010283.JPG
P1010291.JPG

Place the Battery Holder on the [Back Cover] and apply glue around the sides. The Battery Holder should fit flat and level in the inside edges of the [Back Cover].

Assembly - Modify the UART Module

uart.jpeg

Prepare the UART Module for installation. First, drill 2mm holes where the screws go, since the holes that come by the factory are too small to be useful. The second thing to modify is to reinforce the USB connector, adding more solder on the pads on each side of the USB connector.

Assembly - UART Module

P1010294.JPG
P1010296.JPG

Screw the UART Module to the [Back Cover]. Use M2x6mm HEX screws for that. It should go directly to the plastic so there's no need for nuts.

Assembly - Buttons

YouTube Subscriber Counter 2_000000.jpeg
P1010299.JPG

Glue the [Buttons] to the [Back Cover].

Assembly - Wall Mount Cover

P1010301.JPG
P1010303.JPG

Glue the [Wall Mount Cover] to the [Back Cover].

Assembly - Modify the Display SPI Module

mod1.jpeg
mod2.jpeg
P1010287.JPG

The E-Paper Display should come with a module that adapts the Ribbon Flex Cable to the SPI protocol. This module is a bit too thick so we need to modify it by removing the Raspberry Pi connector. It's surprisingly easy to remove. Just use pliers and pull it off. Remove also the little pieces of metal from the connector that might remain in the module.

Assembly - Display SPI Module

P1010306.JPG
P1010308.JPG

Install the Display SPI Module to the [Back Cover] using 4 M3x12mm HEX screws and 4 M3 nuts. The nuts should go in the inside part of the [Back Cover], leaving the screw heads on the outside.

Assembly - Main PCB

P1010310.JPG
P1010311.JPG

Screw the main PCB with all the electronic components to the [Back Cover] using 4 M3x12mm HEX screws and 4 M3 nuts. The nuts should go in the inside part of the [Back Cover], leaving the screw heads on the outside.

Assembly - Cables

P1010312.JPG

Place all the cables and secure them with zip ties. It's also a good idea to label the connectors, if you choose to use connectors. Make sure to test everything again.

Assembly - Leg

P1010332.JPG
P1010330.JPG

Join the [Leg] and [Leg Support] and put them on the [Back Cover] with 4 M3x8mm HEX screws and 4 M3 nuts. The nuts should go in the inside part of the [Back Cover], leaving the screw heads on the outside.

Assembly - Lock Clips

P1010334.JPG
locks_000000.jpeg
P1010338.JPG

To install each [Lock Clip] on the [Back Cover], make sure to place the hardware in the right position. First you put a 3x7mm washer in a M3x12mm HEX screw, then insert on a [Lock Clip], after that it goes another washer. Place it on one of the corresponding holes of the [Back Cover] and put 2 M3 nuts on the other side. We use two nuts to lock them to each other and prevent them from unscrewing them-selves accidentally.

Assembly - Hole on Shadow Box for Lock Clips

YouTube Subscriber Counter 2_000000.jpeg
lock clip mark_000000.jpeg
lock clip mark_000002.jpeg
lock clip mark_000003.jpeg

My shadow box came with some flaps that I removed because they brake too easily after bending them a few times. Now we are ready to put the display assembly and the back cover assembly into the Shadow Box. Remember to place the Frame Mat too. All this will allow us to mark where the holes should be made for the locking clips to extend and support the back cover assembly against the Shadow Box.

Final Assembly and Stickers

finish_000000.jpeg
P1010319.JPG
P1010430.JPG
front_000000.jpeg

Connect everything and put everything on the Shadow Box in the following order:

  1. Transparent Front Cover (make sure to remove the protective film on each side)
  2. Frame Mat
  3. Display Assembly
  4. Connect the Ribbon Flex Cable for the display
  5. Turn the Battery Holder (switch) ON and put the [Back Cover] on the Shadow Box

The last touch is adding some stickers in the [Back Cover] to indicate the buttons and the USB connector.