Introduction: Facebook Fan Count

Picture of 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.

This is what you need for this project:

Software

Facebook APP https://developers.facebook.com/

Facebook fingerprint https://github.com/gbrault/esp8266-Arduino/blob/master/doc/esp8266wifi/client-secure-examples.md#how-to-verify-servers-identity

Arduino IDE https://www.arduino.cc/en/Main/Software

Libaries for Arduino IDE

    WIFI ESP8266 https://github.com/esp8266/Arduino

    Seven segment display https://github.com/bremme/arduino-tm1637

    JSON https://github.com/bblanchon/ArduinoJson

    Hardware

    Ikea Ribba 000.783.34 (or another frame to hold the project) http://www.ikea.com/no/no/catalog/products/0007833...

    NodeMCU (mini) https://www.banggood.com/Mini-NodeMCU-ESP8266-WIFI...

    Display https://www.banggood.com/RobotDyn-LED-Display-Tube...

    Tools

    Rotary tool or something to make a square hole in the backplate of the frame.

    Step 1: Create Facebook APP

    Picture of Create Facebook APP

    This can be done at developers.facebook.com. After the APP is created, note the App ID and App Secret. You'll need this in the code.

    Wanna test the access for your APP? Head over to https://developers.facebook.com/tools/explorer/

    Enter the following: AAA?access_token=BBB|CCC&fields=fan_count

    • AAA = Facebook Page ID or name,
    • BBB = App ID
    • CCC = App Secret

    Note the | (pipe) between App ID and App Secret.

    Step 2: Hardware – Electronics

    Picture of 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

    Picture of 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.

    JSON: The last library is for handling JSON-data from Facebook. Download ArduinoJson - C++ JSON library for IoT from https://github.com/bblanchon/ArduinoJson

    Facebook Fingerprint: To connect to Facebook we also needs a fingerprint. Instead of trying to explain this to you, I recommend taking a look at the documentation https://github.com/gbrault/esp8266-Arduino/blob/ma...

    Step 5: Software – Code

    Download the code here: https://www.hackster.io/code_files/114510/download

    • AAA = Facebook Page ID or name
    • BBB = Facebook App ID
    • CCC = App Secret
    • DDD = Fingerprint

    Comments

    jayzirl (author)2017-07-30

    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?

    Would really like to get this running!

    sjsd (author)jayzirl2017-07-31

    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

    jayzirl (author)sjsd2017-08-14

    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?

    sjsd (author)jayzirl2017-08-15

    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.

    jayzirl (author)jayzirl2017-08-14

    Seem to be getting "certificate doesn't match" on every try.

    PiotrK15 (author)2017-07-17

    idk how to obtain fingerprint

    jayzirl (author)PiotrK152017-07-30

    https://github.com/gbrault/esp8266-Arduino/blob/master/doc/esp8266wifi/client-secure-examples.md#how-to-verify-servers-identity

    jayzirl (author)PiotrK152017-07-30

    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.

    FlaviuB2 (author)2017-05-26

    Can you explaing more detalied about Hardware – Electronics?

    Can you tell us exact part that you use for this project?

    Thanks! Great project!

    sjsd (author)FlaviuB22017-05-30

    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.

    Just ask if there is something else you wanna know.

    FlaviuB2 (author)sjsd2017-05-31

    Hi,

    Thanks for your response!

    Do you think, this is ok?

    https://ardushop.ro/ro/home/223-nodemcu-mini.html

    Because I don`t find NodeMCU Mini in my country :)

    Thank you!

    sjsd (author)FlaviuB22017-06-08

    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.

    Swansong (author)2017-05-23

    That looks good, it would be fun to have a tracker like that :)

    About This Instructable

    1,101views

    25favorites

    License:

    Bio: ...
    More by sjsd:Facebook Fan Count
    Add instructable to: