Subscriber and follower counter
Build it step by step
0 of 8 doneWire the display
Connect the five wires from the module to the D1 mini.
Test the display
Upload a sketch that shows 12345678 on the display.
Get an API key
Create one in the developer console and note your channel ID.
Fill in the placeholders
Add the Wi-Fi details, key and channel ID.
Upload the sketch
Power it from a 5 V adapter or USB.
Watch it update
The count appears after the first request.
Test the flash
Temporarily lower the stored count in code to see the flash on a higher value.
Mount it
Fix it behind a frame or in a small box.
How do you build a subscriber and follower counter?
A MAX7219 LED display shows your channel's subscriber count, refreshed from a public API. You need Wemos D1 Mini ESP8266, 8-digit 7-segment module (MAX7219), 5 V 2 A USB adapter and USB A to micro-USB cable (data). It takes 8 steps and about 60 minutes.
- Level
- Beginner
- Time
- About 60 min
- Parts
- 4
Parts list
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| MAX7219 module VCC | D1 mini 5V | Power |
| MAX7219 module GND | D1 mini GND | Ground |
| MAX7219 module DIN | D1 mini D7 (GPIO13) | Data in |
| MAX7219 module CLK | D1 mini D5 (GPIO14) | Clock |
| MAX7219 module CS | D1 mini D6 (GPIO12) | Chip select |
Code
Create an API key in the platform's developer console for the channel statistics API, and put your own channel ID in the code. Replace the Wi-Fi name and password placeholders. Never share or upload a sketch containing the real key. setInsecure() skips certificate checking, so the connection is encrypted but the server is not verified; it is acceptable for a display that only reads public numbers, but it is a trade-off. Requests every 10 minutes keep well inside the free quota. Subscriber counts are shown rounded by the platform once they are large. The module runs from 5 V and takes 3.3 V logic signals from the D1 mini in practice.
Runs on a virtual Wemos D1 mini in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
// Libraries: LedControl, ArduinoJson (v6 or v7). Board: LOLIN(WEMOS) D1 mini.
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClientSecure.h>
#include <ArduinoJson.h>
#include <LedControl.h>
const char* WIFI_SSID = "YOUR_WIFI_NAME";
const char* WIFI_PASS = "YOUR_WIFI_PASSWORD";
const char* API_KEY = "YOUR_YOUTUBE_API_KEY"; // keep out of shared code
const char* CHANNEL_ID = "YOUR_CHANNEL_ID";
LedControl lc(13, 14, 12, 1); // DIN, CLK, CS, number of chips
long lastCount = -1;
void show(long n) {
lc.clearDisplay(0);
if (n < 0) return;
for (int pos = 0; pos < 8; pos++) {
lc.setDigit(0, pos, n % 10, false); // position 0 is the right-hand digit
n /= 10;
if (n == 0) break;
}
}
long fetchCount() {
WiFiClientSecure client;
client.setInsecure(); // skips certificate checking: fine for a learning project, not for anything sensitive
HTTPClient http;
String url = String("https://www.googleapis.com/youtube/v3/channels?part=statistics&id=") + CHANNEL_ID + "&key=" + API_KEY;
if (!http.begin(client, url)) return -1;
int code = http.GET();
long result = -1;
if (code == 200) {
JsonDocument doc;
if (!deserializeJson(doc, http.getString())) {
result = String((const char*)doc["items"][0]["statistics"]["subscriberCount"]).toInt();
}
}
http.end();
return result;
}
void setup() {
lc.shutdown(0, false);
lc.setIntensity(0, 8);
lc.clearDisplay(0);
WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) delay(300);
}
void loop() {
long n = fetchCount();
if (n >= 0) {
if (lastCount >= 0 && n > lastCount) { // flash when the number goes up
for (int i = 0; i < 3; i++) { lc.shutdown(0, true); delay(200); lc.shutdown(0, false); delay(200); }
}
lastCount = n;
show(n);
}
delay(600000); // every 10 minutes
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| First request | Count shown on the display |
| Count rises | Display flashes three times |
| Wi-Fi off | Display keeps the last number |
| Ten minutes later | Number refreshes |
If it does not work
Display blank
Check the intensity, power and the DIN, CLK and CS wires.
Count stays -1
Check Wi-Fi, the API key and the channel ID.
Garbled digits
Digit order may be reversed on your module; change the position mapping.
Request fails
The quota may be used up; wait for the next day.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the subscriber and follower counter?
Wemos D1 Mini ESP8266, 8-digit 7-segment module (MAX7219), 5 V 2 A USB adapter and USB A to micro-USB cable (data).
How long does the subscriber and follower counter take to build?
About 60 minutes for a beginner maker, in 8 steps.
How do I know the subscriber and follower counter works?
First request: Count shown on the display. Count rises: Display flashes three times. Wi-Fi off: Display keeps the last number.
Display blank: what should I check?
Check the intensity, power and the DIN, CLK and CS wires.
Count stays -1: what should I check?
Check Wi-Fi, the API key and the channel ID.
Garbled digits: what should I check?
Digit order may be reversed on your module; change the position mapping.
Request fails: what should I check?
The quota may be used up; wait for the next day.
