Introduction: 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:
Facebook APP https://developers.facebook.com/
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
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...
Rotary tool or something to make a square hole in the backplate of the frame.
Step 1: 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
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.
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