ESP8266 YouTube Subscriber Display On LED Matrix

Not an Arduino or Pi? Post it here.
Post Reply
Posts: 236
Joined: Fri Feb 21, 2014 4:52 pm

ESP8266 YouTube Subscriber Display On LED Matrix

Post by Eric »

How I made an EASY Wifi connected subscriber display using the MAX7219 LED Matrix display to show current YouTube subscriber count or any other text you wish!

Full code and instructions on my GitHub here: ... LED-Matrix

The whole playlist of maker videos this week: ... VD3-2XxHox
I make videos and content on all things electronics, 3D printing and DIY
Posts: 4
Joined: Sun Mar 16, 2014 8:17 am

Re: ESP8266 YouTube Subscriber Display On LED Matrix

Post by hamrad88 »

This was an awesome project but as usual I got lost. Is there an app or program that will display your sub count using a PC or Android tablet?

Thanks and I love this new series you are doing.

Tom Stiles
Posts: 236
Joined: Fri Feb 21, 2014 4:52 pm

Re: ESP8266 YouTube Subscriber Display On LED Matrix

Post by Eric »

Hey Tom,Easiest as mentioned in the comments is to use one of the free services like SocialBlade. Lots of others too.
I make videos and content on all things electronics, 3D printing and DIY
Posts: 1
Joined: Sun Sep 23, 2018 9:29 am

Re: ESP8266 YouTube Subscriber Display On LED Matrix

Post by Fiatbravodriver »

Hi Eric,

I am trying to get a variant of this working. It uses wifimanager to allow the user to enter the required info it does away with the need to hardcode the network credentials. I am always changing network providers when an offer is on.

I am using a MAX7219 9 digit display.
Your Matrix display is far far better but I don't have one as yet.

I can get wifi manager working but the code for operating the display must be wrong. It compiles ok but It just does not communicate with the display.

I would really appreciate it if you could take a look for me?

Kind Regards

Code: Select all

 *  Read YouTube Channel statistics from the YouTube API           *
 *  This sketch uses the WiFiManager Library for configuraiton     *
 *  Using DoubleResetDetector to launch config mode                *
 *                                                                 *
 *  By Brian Lough                                                 *
 *       *

#include <YoutubeApi.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>

#include "DigitLedDisplay.h"
DigitLedDisplay ld = DigitLedDisplay(5, 0, 4);

#include <DoubleResetDetector.h>
// For entering Config mode by pressing reset twice
// Available on the library manager (DoubleResetDetector)

#include <ArduinoJson.h>
// Required for the YouTubeApi and used for the config file
// Available on the library manager (ArduinoJson)

#include <WiFiManager.h>
// For configuring the Wifi credentials without re-programing
// Availalbe on library manager (WiFiManager)

// For storing configurations
#include "FS.h"

// Additional libraries needed by WiFiManager
#include <DNSServer.h>            //Local DNS Server used for redirecting all rs to the configuration portal
#include <ESP8266WebServer.h>     //Local WebServer used to serve the configuration portal

char apiKey[45] = "******";
char channelId[30] = "*********";

WiFiClientSecure client;
YoutubeApi *api;

unsigned long api_mtbs = 60000; //mean time between api requests
unsigned long api_lasttime;   //last time api request has been done

long subs = 0;

// flag for saving data
bool shouldSaveConfig = false;

// Number of seconds after reset during which a
// subseqent reset will be considered a double reset.
// This sketch uses drd.stop() rather than relying on the timeout
#define DRD_TIMEOUT 10

// RTC Memory Address for the DoubleResetDetector to use
#define DRD_ADDRESS 0

DoubleResetDetector drd(DRD_TIMEOUT, DRD_ADDRESS);

//callback notifying us of the need to save config
void saveConfigCallback () {
  Serial.println("Should save config");
  shouldSaveConfig = true;

void configModeCallback (WiFiManager *myWiFiManager) {
  Serial.println("Entered config mode");

  // You could indicate on your screen or by an LED you are in config mode here

  // We don't want the next time the boar resets to be considered a double reset
  // so we remove the flag

void setup() {



  /* Set the brightness min:1, max:15 */

  /* Set the digit count */

  if (!SPIFFS.begin()) {
    Serial.println("Failed to mount FS");

  pinMode(LED_BUILTIN, OUTPUT);     // Initialize the LED_BUILTIN pin as an output
  digitalWrite(LED_BUILTIN, LOW);   // Turn the LED on (Note that LOW is the voltage level

  WiFiManager wifiManager;

  // Adding an additional config on the WIFI manager webpage for the API Key and Channel ID
  WiFiManagerParameter customApiKey("apiKey", "API Key", apiKey, 50);
  WiFiManagerParameter customChannelId("channelId", "Channel ID", channelId, 35);

  if (drd.detectDoubleReset()) {
    Serial.println("Double Reset Detected");
    wifiManager.startConfigPortal("YouTube-Counter", "supersecret");
  } else {
    Serial.println("No Double Reset Detected");
    wifiManager.autoConnect("YouTube-Counter", "supersecret");

  strcpy(apiKey, customApiKey.getValue());
  strcpy(channelId, customChannelId.getValue());

  if (shouldSaveConfig) {

  digitalWrite(LED_BUILTIN, HIGH);  // Turn the LED off by making the voltage HIGH
  // Force Config mode if there is no API key
  if(strcmp(apiKey, "") > 0) {
    Serial.println("Init YouTube API");
    api = new YoutubeApi(apiKey, client);
  } else {
    Serial.println("Forcing Config Mode");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  IPAddress ip = WiFi.localIP();



bool loadConfig() {
  File configFile ="/config.json", "r");
  if (!configFile) {
    Serial.println("Failed to open config file");
    return false;

  size_t size = configFile.size();
  if (size > 1024) {
    Serial.println("Config file size is too large");
    return false;

  // Allocate a buffer to store contents of the file.
  std::unique_ptr<char[]> buf(new char[size]);

  configFile.readBytes(buf.get(), size);

  StaticJsonBuffer<200> jsonBuffer;
  JsonObject& json = jsonBuffer.parseObject(buf.get());

  if (!json.success()) {
    Serial.println("Failed to parse config file");
    return false;

  strcpy(apiKey, json["apiKey"]);
  strcpy(channelId, json["channelId"]);
  return true;

bool saveConfig() {
  StaticJsonBuffer<200> jsonBuffer;
  JsonObject& json = jsonBuffer.createObject();
  json["apiKey"] = apiKey;
  json["channelId"] = channelId;

  File configFile ="/config.json", "w");
  if (!configFile) {
    Serial.println("Failed to open config file for writing");
    return false;

  return true;

void forceConfigMode() {

void loop() {

  if (millis() - api_lasttime > api_mtbs) {
      Serial.print("Subscriber Count: ");
      Serial.print("View Count: ");
      Serial.print("Comment Count: ");
      Serial.print("Video Count: ");
      // Probably not needed :)
      //Serial.print("hiddenSubscriberCount: ");

    api_lasttime = millis();
Post Reply