Secondary Menu

Facebook Fan Count

Inspired by Becky Stern's YouTube Subscriber Counter, I wanted to make a display of the number of likes for a Facebook page. My goal with this project was to bring out the number of fans from a Facebook page. Not any one but one I administer. To code C is not my field so I started with a lot of trial and error. But ended up with a result that worked.

Step 2: Hardware – Electronics

Now over to the fun part. I have used a NodeMCU Mini. These are available in various varieties and price ranges in a variety of online stores and on eBay. There were two reasons I chose a mini. The first reason was that I already had a lying one in my drawer. The other reason was that it is small and takes up little space in a picture frame.

I bought a display consisting of four segments mounted on a board of electronics so I only need to use four of NoceMCUen's IOs.

NOTE: NodeMCU has only 3.3V output while the display will preferably have 5V. It will work with 3.3V but will light slightly. Fortunately for me my NodeMCU gives 5V outputs via VIN.

As you can see on my somewhat blurry image the VIN, VCC and data pin are aligned. This means I don't need any wires between the NodeMCU and display. Just slide the boards together and add some soldering.

VIN --> 5V

GND --> GND

D4 --> DIO

D3 --> CLK

Disclaimer: I do not take responsibility for connecting your equipment together and any damage that may occur on your equipment if you follow my example. Fortunately, this setup seems to work me.

Step 3: Hardware – Frame

I bought a Ikea Ribba 000.783.34. The reason why I bought this frame is that it has a deep frame. Then I can easily fit the display and the electronics.

The picture above shows that I have made holes for the display. I made a template that I attached to the backplate and marked where I wanted to have the display. Then I used a rotary tool to make the hole.

The next step was to tweak the placement of the display and make it as bright as possible through the paper in front. As you probably understand, I did not start with the frame itself. For it would be useless to build a display in a frame if I did not have a number to display.

After I had created a Facebook APP, I had to put myself into a somewhat unknown world. I do not know much about programming C ++. But ended up with a satisfactory result after much trial and error.

Step 4: Software – Arduino Libaries

WIFI: In order to connect to wireless networks, we need a library for ESP8266. If you do not have this before, go here https://github.com/esp8266/Arduino and follow the steps for adding it to Arduino IDE.

Display: The next library is for the seven segment display. Download the SevenSegmentTM1637 Arduino Library from https://github.com/bremme/arduino-tm1637 I tried several different libraries for the display. This one was the first I found that worked with my display board.

Hi All, here the code that work for me, very small changes I figured for sleeping late in the last 2 days (I have no skill in coding at all, so just trial here and there comparing the code I got from the examples). I add blinking every refresh to verify it does pulling new number if any.

One question though I love to get answered. There is about 15 seconds delay on the code (my setup) to push the new value from the facebook like number. How to make it updated every 1 seconds instead 'this 15 seconds'?

Would love to get this working but am having issue where i compile and get this...

exit status 1

'd3' was not declared in this scope

I have changed D3 and D4 to simply 3 and 4 to check if that might be it and that compiles and uploads fine but i dont think that correct. but no matter what i do it just tells me the pin was not declared in the code.

Also, does it matter what board you select in the Ardiuno program... (tools -> board). Should it be generic ESP8266 Module or maybe NodeMCU 0.9 or the 1.0?

Depending on what type of board you have you should select the board that fits in Arduion IDE. There are several types and you might have to download a libary for your type of board.

Depending what works for your board you can define the pins in different way. Try some of the examples from the display libary to check if it works: https://github.com/bremme/arduino-tm1637/tree/master/examples

I have the exact same boards and display as you have listed. I did get this running, but gives ERR1 now everytime it connects. Im guessing my access token needs to be renewed every hour? Is there a way of getting an access token that has no expiry?

To be honest, I have never received the ERR1 message myself. The reason for ERR1 is that fancount is not greater than 0. That is, it is 0 or less. It may also be that fancount is not a number. A little bad code, because this should have been checked in advance.

Try a Serial.println(fancount); Between lines 69 and 70. Is there a number or something else?

I have never renewed my access token. My display has run without errors since May. There may be a problem with your Facebook APP or settings.

obtain the fingerprint for specific host using a web browser. For instance on Chrome press Ctrl+Shift+I and go to Security > View Certificate > Details > Thumbprint. This will show a window like below where you can copy the fingerprint and paste it into sketch.

Hi FlavuiB2, I have updated the instruction with more details about the hardware. As you can see I use a NodeMCU Mini and a display (both bought at Banggoods, but you can get similar products elsewhere).

As you can see from the photo (it a little blurry) the IOs align. So I just slide the NodeMCU into the existing pins on the display board. Then added some soldier to make sure it stayed like this.

It looks similar and it will probably work. What you have to check is the VCC and if it's capable to drive the display directly from the NodeMCU-board. Otherwise you have to power the display in another way.