Introduction: YouTube Subscriber Counter Using an ESP8266 Board

Dear friends welcome to another ESP8266 project Today we are going to build a DIY YouTube subscriber counter with a big LCD display and a 3D printed enclosure. Let’s get started!

In this tutorialwe will be making this: A DIY YouTube subscriber counter. It uses the big I2C display I reviewed a few weeks ago to display the subscriber count with big easy to see from distance numbers. The enclosure of the counter is 3D printed using wood filament. I used two different wood filaments this time and I really love the color combination! In my opinion it looks so cool. I really wanted a YouTube subscriber counter to help me stay motivated! Producing videos requires a great amount of time and effort. When you know that 35.000 people are waiting for a video from you, you work harder and harder to keep all these people satisfied, it gives you a great motive. So, this counter will help me stay focused. Let’s now see how to build this project!

Step 1: Get All the Parts

Picture of Get All the Parts

The project is really simple and easy to build. The parts needed in order to build this project are the following:

The cost of the electronics is less than 10$!

If you are going to 3D print the enclosure you are also going to need two rolls of the wood filament. I used FormFutura’s Easy Wood Birch and Coconut filaments.

Coconut filament ▶ http://bit.ly/WoodFilamentCoconut

Birch filament ▶ http://bit.ly/WoodFilamentBirch

For the enclosure, we need about 100gr of material, so it will cost us around 5$.So the total cost of the project is around 15$.

Step 2: The Wemos D1 Mini Board

Picture of The Wemos D1 Mini Board

The Wemos D1 mini is fantastic new board which costs around $5!

The board is very small. It uses the ESP8266 EX chip which can operate at a frequency up to 160MHz. It has a lot of memory, 64Kb of instruction RAM, 96Kb of data RAM and 4MBs of flash memory to store your programs. It offers WiFi connectivity, Over the Air updates and much more. The D1 mini board offers 11 GPIO pins and one analog input. Despite its small size many shields are being developed for this board which I think is great, since this way we can easily build great Internet of Things projects! Of course we can program this board using the Arduino IDE.

The board despite its small size it outperforms all the other Arduino compatible boards in performance. I have performed a comparison between the ESP8266 and Arduino, you can check the video I have attached in this step. This board is 17 times faster than an Arduino Uno! It also outperforms the fastest Arduino board, the Arduino Due. All that, with a cost of less than $6! Impressive.

Get it here ▶ http://bit.ly/WemosD1Mini

Step 3: The 20x4 Character LCD Display

Picture of The 20x4 Character LCD Display

I discovered this display some time ago on Banggood.com. It drew my attention because it inexpensive, it costs around 7$, it is big, and it uses the I2C interface. Since it uses the I2C interface it is extremely easy to use with Arduino. We only need to connect two wires. I needed a big, easy to connect display for prototyping some projects and the only display that was using the I2C interface was this tiny OLED display. Now we have a big I2C display to use in our projects! Great!

As you can see, the display is really big. It can display 20 characters per line, and it has 4 lines. It cannot draw graphics, just characters. At the back we can find a small black board soldered on the display. On the black board there is a trimpot which controls the contrast of the LCD.

Get it here ▶ http://bit.ly/20x4LCD

Step 4: Build the Prototype Circuit

Picture of Build the Prototype Circuit

The connection couldn’t be easier.

Connecting the LCD Display

  • Vcc of the display goes to the 5V output of the Wemos D1 mini
  • GND of the display goes to the Wemos GND
  • SDA pin of the display goes to D2 pin of the Wemos Board
  • SCL pin of the display goes to D1 pin of the Wemos Board

That’s it! Now if we power up the project we can see that after a few seconds the board is connected to the WiFi network and on the screen the number of the Subscribers of this channel is displayed with big numbers. The project works as expected so we can move on.

Step 5: 3D Print the Enclosure

Picture of 3D Print the Enclosure

The next step is to 3D print the enclosure. I designed this enclosure using Fusion 360 free software.

I tried a lot of different 3d design software but Fusion 360 became my favorite for the following reasons.

  • It is very powerfulIt is free
  • It is relatively easy to use
  • There are a lot of tutorials online on how to use this software

I took me around an hour to design this enclosure and have in mind that I am very new to 3D design and 3D printing. I have uploaded the design files to thingiverse and can download them for free.

I used Formfutura’s EasyWood Coconut filament for the two parts, and Birch filament for the front part.

Get it here ▶ https://www.thingiverse.com/thing:2338562

Step 6: Finish the 3D Print

Picture of Finish the 3D Print

It was an easy and quick print. It took me around 5 hours to print all the parts using my Wanhao i3 3d printer. but The result was fantastic!

After the parts were printed, I sanded them with fine sand paper and then I applied wood varnish to them. I used different wood varnish for each color and I applied it using a small piece of cloth.

Next, I let the varnish to dry for 24 hours and the end result is great!

Step 7: Connecting Everything Together

Picture of Connecting Everything Together

After thevarnish was dry it was time to put the electronics inside the enclosure.

I glued the front piece in place and then I placed the display to its exact position.

I used some hot glue to keep the display in place as well. Then I soldered some female wires to the Wemos D1 mini pins we are using, and then I connected them to the display. I tested the project to see that everything is working fine, and then I used hot glue to glue the board in place. The last step was to glue the back cover of the enclosure!

Our project is ready and it looks so cool! In my opinion it does not look plastic like most 3D printed objects look! I really love how it turned out. Let’s now see the code of the project.

Step 8: The Code of the Project

Picture of The Code of the Project

The project retrieves the number of the subscribers of a given YouTube channel using the YouTube API. We send a request to a google server and the server replies with a JSON file with the number of subscribers. In order to use the YouTube API we need to have an API Key.

Let’s do that first. So, we have log in to our Google Account and visit the developer console. (https://console.developers.google.com) We click to create a new project, we give it a name and we press create. Then with the new project selected we enable the YouTube Data API. The last step is create Credentials. We press the Credentials key and then from the window that appears we select to create a new API key. We press close and we are done. For more details, watch the video attached to the first step.

Let’s now take a quick look at the code of the project. First of all we have to download some libraries. We need a version of the LiquidCrystal_I2C library which works with the ESP8266 chip. We also need the excellent ArduinoJSON library.

  1. Arduino JSON: https://github.com/bblanchon/ArduinoJson
  2. Display Library: https://github.com/esp8266/Basic/tree/master/libr...

Next we have to define some variables. We set the ssid and the password for the WiFi connection. We also need to enter the API key we created in the appropriate variable. Lastly we need to enter the channelID of the YouTube channel we want to check the subscriber count.

<p>const char* ssid     = "SSID";       // SSID of local network<br>const char* password = "PASSWORD";   // Password on network
String apiKey = "YOURAPIKEY";       //API KEY
String channelId = "UCxqx59koIGfGRRGeEm5qzjQ";   // YouTube channel id</p>

The code is relatively simple. At first we initialize the display and we create some custom characters for the display. We need these characters in order to produce big digits. Don’t forget, the display we are using is character LCD display, it cannot display graphics. It can just display 4 lines of text. In order to create big numbers, we use two lines of text and some custom characters!

<p>void setup()  <br>{
  Serial.begin(9600);
  int cursorPosition=0;</p><p>  lcd.begin(20,4); 
  lcd.setCursor(0,0);
  lcd.print("Connecting ....");</p><p>  createCustomChars();
  
  WiFi.begin(ssid, password);
  
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    lcd.setCursor(cursorPosition,1); 
    lcd.print(".");
    cursorPosition++;
  }</p>

Then we connect to the WiFi and we get the subscribers every minute. In order to get the subscriber count, we send a request to a google server, and we parse the JSON fine it responds using the ArduinoJSON library. We save the subscriber count into a variable. In the loop function we check if there is a change in the subscriber count, we clear the display and we print the new number.

<p>void loop() <br>{
  int length;
  String subscribersString = String(getSubscribers());
  if(subscribers != subscribersBefore)
  {
    lcd.clear();
    length = subscribersString.length();
    printSubscribers(length,subscribersString);
    subscribersBefore = subscribers;
  }  
  delay(60000);
}</p>

As always you can find the code of the project attached in this Instructable. Since I update the code from time to time, for the latest version of the code please visit the project's website: http://educ8s.tv/diy-youtube-subscriber-counter/

Step 9: Final Result

Picture of Final Result

As a final thought, I really love this project. It was really easy to build and inexpensive. Of course there is room for improvements. We can add a battery inside the enclosure or even sound. I am thinking about adding an 18650 lithium battery along with the wemos battery shield. I didn’t do it in this project because I need to test the Wemos Battery shield some more. This small shield can charge and protect Lithium Batteries so it provides an easy way to add rechargeable batteries to our projects.

I would love to hear your opinion about this project. Do you like how it looks and can you think of any improvements to this project? Please post your comments in the comments section below.

Comments

WannaDuino made it! (author)2017-07-13

oke, this is going crazy...

NOW i have the 2004 LCD ordered and conected it, and i see only blocks????

and on the smaller screen a bit of my subs, and also the message when starting up, ( connecting succsesful or so ) and on the bigger lcd NOTHING.

am i going nuts or do i have the fricking bad luck that this lcd is bad.

gromas (author)WannaDuino2017-09-29

This might be a bit late to comment, but you need to change de LCD address.

I had to change mine to this:

LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address

WannaDuino (author)gromas2017-10-04

i know i had to message you also, i figured it out myself THANXXXXXXX

because you did not told it then NOQW i know how to do it..and help others because this is one off the biggest issues evver by a lot.

educ8s (author)WannaDuino2017-07-13

Try to adjust the contrast using the pot at the back.

WannaDuino (author)educ8s2017-07-14

i did that all, also simple examples, if i power it on, DIRECT BLOCKS, maybe a flaw?

what do you see when you turn it on WITHOUT any uno running, and what do you see when powering it with an sckech running, my small one says conecting. this bigger 2004, does NOTHING, only BLOCKS like the picture my friend, thanx for helping i REALLY APRICIATE IT.

educ8s (author)WannaDuino2017-07-14

Did you buy the display from the link I provided? Maybe you got a display that uses a different driver.

WannaDuino (author)educ8s2017-07-16

No friend, but that i canT believe, i have the GREEN screen yours is blue, i also ordered, but it is absolute a signal problem, i used simple sketches and it did not work, same blocks, in the lcd, i tested the smaller one, i pulled a signal wire out, BOOM same blocks. so the code it is not coming true or so, i really can not stand this.

But enjoy your honeymoon and wife friend, i will wait. have a GREAT wedding.

gromas made it! (author)2017-09-29

I made it with a few (a lot?) tweaks and modifications to the case and
source code. Now it will search and connect to 3 Wifi networks (home,
work, my phone as hotspot) and show some other special messages on the
LCD. :-)

WannaDuino made it! (author)2017-06-24

I need help my friend,

I am a long time subscriber on youtube dude, and now i also have a SMALL channel, but i wanted this so long, but the inventor Becky of this counter, never helped. But that was the 7 segment display.

in the code i seen the line with subscribers, must i also place there my 89 sybscribers? i think not but i ask it, because it says 0 in the code.

So my problem is this, i have not your 20-4 display mine is smaller, its the 1602A display, so i have only half screen now, and its using 1 line, see pictures, can you PLEASE make or change the code for me to mine? thanx bro.

educ8s (author)WannaDuino2017-07-07

The easiest way around this problem is to use the display I use. The project won't work on a smaller display like yours without modifications. Since I don't own a display like yours I can't make the modifications needed, sorry.

WannaDuino (author)educ8s2017-07-09

Actually that is NOT TRU sir.. ., you used it in the weather station also, it is EXACT the same firmware and coding but has buttons added.

I just wanted some help, but instead, I put you on blast.

educ8s (author)WannaDuino2017-07-11

I am using a shield in the weather station project. The shield has a similar display but not the i2c backpack. So, there is no way to test it with an i2c library.

WannaDuino (author)educ8s2017-07-11

Thanx, glad i got your attention finally, but i already ordered the larger lcd, but wanted to see if it was possible WITH MINOR changes to run it on the smaller screen, hope you will buy that one, and let me know how to change the code then. the screen plus driver board costs 1.90Euro total on Ali express.

try it man, you will have your NEXT edu video.

WannaDuino, from The Real LiVe. www.wannaduino.simplesite.com. see me and read my SHORT story.

WannaDuino (author)educ8s2017-07-09

wow, yeah haha,

i could figure that one out to bro!!

but thanx anyWAY.

Iqbal Samin (author)2017-06-15

How did you get those big characters on your LCD?

educ8s (author)Iqbal Samin2017-06-16

The software library for the display we are using, allows us to create some custom characters. In order to create those big digit, we just create some custom characters and we combine them together.

watchmeflyy (author)2017-06-10

Nice job with explaining everything. :)

About This Instructable

2,440views

50favorites

License:

Bio: I am Nick Koumaris from Sparta, Greece. I'm extremely passionate about electronics, making things and design. I love teaching what I know and sharing ... More »
More by educ8s:Arduino Temperature Monitor and Real Time Clock with 3.2" DisplayArduino TEA5767 FM Radio ReceiverArduino Weather Station with a Nextion Display
Add instructable to: