loading

I was inspired by the Play Button awards YouTube sends out for subscriber milestones and whipped up a simple circuit using an ESP8266 wifi board and seven segment display to show off my realtime subscriber count. This is a great IoT beginner project, with just a little soldering and a code personalization required to make it work for your own account.

Before attempting this project, you should be generally familiar with uploading new programs to your Arduino board and installing code libraries, both of which you can learn for free in my Arduino Class, though you really don't have to understand any of the actual Arduino code to get this project running.

For this project, you will need the following materials:

and the following tools:

Required software libraries:

Unique data required:

As an alternative to the Feather Huzzah, you can also use your favorite ESP8266 microcontroller board, some of which require an FTDI cable to upload new programs. Use the standard 7-segment backpack rather than the FeatherWing version.

Step 1: Assemble Circuit

Follow the official assembly instructions for the Feather Huzzah using female headers (or stacking headers, though you'd have to cut the long legs off) Likewise follow the assembly instructions for your seven-segment FeatherWing display.

Before you dive into the code for this project, you should first make sure you've got your Arduino software set up properly to program the board you are using, which in my case involves installing the SiLabs USB driver and installing ESP8266 board support (explained in more detail in the Feather Huzzah tutorial):

  • Go to Arduino-> Preferences...
  • Look for a text field labeled "Additional Boards Manager URLs:" and paste the following URL into the field (separate multiple URLs with commas if applicable):
    <a href="http://arduino.esp8266.com/stable/package_esp8266com_index.json">http://arduino.esp8266.com/stable/package_esp8266c...</a>
  • Click OK
  • Go to Tools->Board-> Boards Manager...
  • Search for ESP8266 and click the Install button in the box "esp8266 by ESP8266 Community" when it shows up

Huzzah ESP8266 boards have an LED connected to pin 0, and you can find a sample blink sketch by navigating to File->Examples->ESP8266->Blink, or copy it from here:

void setup() {
  pinMode(0, OUTPUT);
}
void loop() {
  digitalWrite(0, HIGH);
  delay(500);
  digitalWrite(0, LOW);
  delay(500);
}

Plug in your USB cable to the board and configure your settings under the Tools menu as follows:

  • Board: Adafruit Huzzah ESP8266
  • CPU Frequency: 80MHz
  • Flash Size: 4M (3M SPIFFS)
  • Upload Speed: 115200
  • Port: whichever one ends in SLAB_USBtoUART (Mac) or COMx (Windows)

Click the Upload button to send the program to your board. This will take several seconds (longer than you are used to with Arduino Uno). After complete, the onboard LED should start blinking.

While the Feather Huzzah auto-detects when it's being sent a new program, other ESP8266 boards may require a sequence of button presses to get into bootloader mode.

Do not proceed until you've successfully uploaded a blink test program to your board.

<p>Hey Becky,</p><p>A user pointed out an issue with the example sketch of the library, that I just checked that you have the same issue in your sketch. Sorry, my bad!</p><p>The issue is that millis() will eventually roll over and start counting up from 0 again (I think it roughly about 40 days when this happens). When that happens your sketch will stop checking youtube as the if statement in the loop will never be true.</p><p><a href="https://github.com/witnessmenow/arduino-youtube-api/blob/master/examples/ESP8266/ChannelStatistics/ChannelStatistics.ino#L24" rel="nofollow">It's fixed on github now if you want to check it out</a> (just change the two time holding variables to unsigned long):</p><p><a href="https://github.com/tzapu/WiFiManager" rel="nofollow">I added a new example</a> to the library as well that uses <a href="https://github.com/tzapu/WiFiManager" rel="nofollow">WiFiManager library</a>, you should check it out as it means you don't need to reprogram the device to change the Wifi Network and you can also configure the API key and Channel ID using it too.</p><p>I've More Info on <a href="https://www.instructables.com/id/Managing-Configurations-on-Your-ESP8266-Using-WiFi/" rel="nofollow">WifiManager here</a>.</p>
<p>Thank you! I've updated the sketch to correct the variable types. And I will check out your new example soon too! Sounds like a great upgrade for v2, configurable wifi would allow this project to be given as a gift! Thanks again for your great code and amazing follow-through.</p>
<p>Nice Project for my YouTube Channel Subs. </p><p>I would love it to have the source code also for Instagram, Facebook Page or Twitter. Maybe i have to learn the API&acute;s Requests:( </p>
Hey, <br><br>I wrote the Youtube api library and i absolutely love coming across somebody using it! <br><br>Project looks great, thanks a lot for sharing!<br><br>I haven't even made one for myself yet, although i would only need 3 digits! (And only just!).<br><br>For people asking about making other counters, if you let me know which services you'd like i can take a look into if it possible!<br><br>Brian
<p>I am a bit nob stil,</p><p>i have the TM1637 4 digit 7 seg display, but i dont get it to work, what to do or change ??</p>
<p>Hello sir,</p><p>YOU ROCK!!!!</p><p>WannaDuino.</p>
<p>Yay hi Brian! Great library, thank you so much!</p>
<p>What does API stand for?</p>
Hey DGW,<br>It stands for Application Program Interface. But I guess more important this is what is it! <br><br>Basically it's a way for an application or service to be easily interacted with by a program. So the library mentioned is making a call to the YouTube API and returning the results. Lots of APIs are available for different services
<p>Please help,</p><p> i have uploaded al on my esp8266 board the nodemcu V3 Lolin.</p><p>And i see the data ( same as webserver ) in the serial monitor so it must be good i think.</p><p>but i have a display with only 4 pins, 2 for voltage and ground, and 1 for CLK and 1 for DIO,</p><p>how to connect that????</p><p>i made some pictures my great master <a href="https://www.instructables.com/member/bekathwia" style="">bekathwia</a>, ooo please help. ( or anybody )</p><p>My name is WannaDuino!!! and are an INSTRUCTABLES MEMBER with PROUD. HELP Me!!!</p><p>WannaDuino!!!</p>
<p>in the code i see nothing about the display, also no pinouts?</p><p>mine is the TM1637.</p><p>yep i am a noob, so what am i missing here.</p><p>LOL.</p>
<p>extra picture</p>
<p>I LOVE IT!! now I just need to find a 6 digit display.</p>
<p>I ordered an 76856432100000.00000 digit display. For the Trump Tower.</p><p>Al the Dis -Likes he gets.:)</p><p>WannaDuino!!!</p>
<p>LOL</p>
<p>I am almost finished with this project but when I uploaded the code <br>to the board, it looks like this! I uploaded the basic 7-segment example<br> sketch and it works fine. So I know for sure its not a problem with the<br> hardware. Please help!!</p><p>Thanks</p>
<p>Looks like it's not connecting to the net-- the display will spit out random info until it gets told what to display for the first time. Work on your Feather Huzzah setup, follow the setup tutorial to verify your network settings etc.</p>
<p>Its working now! Thanks for your help Becky</p>
<p>Additionally, there could be a problem with your Google API key. Brian who wrote the library has a step for verifying that your key and youtube id are working: </p><ul><br><li>Make sure the following URL works for you in your browser (Change the key at the end!):<a href="https://www.googleapis.com/youtube/v3/channels?part=statistics&id=UCu7_D0o48KbfhpEohoP7YSQ&key=PutYourNewlyGeneratedKeyHere">https://www.googleapis.com/youtube/v3/channels?part=statistics&id=UCu7_D0o48KbfhpEohoP7YSQ&key=PutYourNewlyGeneratedKeyHere</a></li></ul>
<p>wow cool, great job and a very neat project!!!! was wondering whether instead of counting the number of subscribers, whether it could count the number of views or likes instead?</p>
Hey, <br><br>if you look at the example on the github page of the YouTube API library you'll see the stats the library supports.<br><br>View count is one, likes isn't though (doesnt come back in the statistics api request)<br><br>Brian
<p>that is so cool</p>
<p>Live counters are awesome! Like it very much ^^</p>
<p>You got my vote. Great proyect. i will to make this project this afternoon. Great to learn about IoT</p>
Wonderfull!!<br>Can i use this tutorial for a instagram follower counter?
<p>Thanks! The code uses the Google API right now, so a significant change would be required to make it work for other platforms.</p>
you got my vote! you are insanely awesome! Keep it up!
<p>great project! I wonder if this would work for a Facebook business page &quot;likes&quot; counter?</p>
this should work for facebook becuase theg are using json rest api for the count. but you should have facebook app id for that.
nice
<p>Wires. No thanks ;-) Anyway a nice app</p>
<p>I love it sooo much. I need one. Because I'm a Youtube too. Amazing post.</p>
<p>Could this be easily transformed to count Facebook likes for a certain page?</p>
<p>Easy is a relative term, depending on your skills/background! To switch to any other site would require a substantial edit to the code, which may be easy for you!</p>
This is great but what will you do when you get over 9999?
<p>Add another display to add more digits! You have to solder a jumper to change the I2C address of the second one: https://learn.adafruit.com/adafruit-led-backpack/changing-i2c-address?view=all#changing-i2c-address</p>
<p>That is exactly what I have been looking around how to make! Thanks </p>

About This Instructable

11,977views

246favorites

License:

Bio: Becky Stern is a content creator at Instructables. She has authored hundreds of tutorials about everything from wearable electronics to knitting. Before joining Instructables, Becky ... More »
More by bekathwia:Quilted Vinyl Pencil Case Hair Scrunchie YouTube Subscriber Counter With ESP8266 
Add instructable to: