Introduction
This is a personal tutorial I made on how to create your own facebook page like counter using an Espresso Lite 2.0 as the microcontroller in this project. It runs with Arduino IDE and is an IoT (Internet of Things) product.
Getting Started
For this project, you would need (click on the underlined names in the list to open the link) :
- An Espresso Lite 2.0 (esp8266 module) [Top Left]
- An OLED i2C [Bottom centre]
- 4 different colours of jumper wires [Wires on the right]
- 2 pairs of red and blue LEDs [Top centre]
- USB to UART converter [Bottom Left]
- A breadboard [Top Left, under the Espresso Lite 2.0]
Getting them all together…
1.Connect your OLED i2C on top of the Espresso Lite 2.0 as shown in the picture below:
2.Insert the blue LEDs onto the breadboard ( positive wire/longer wire at the bottom):
3.Do the same for the red LEDs but with their polarity switched( positive/longer wire at the top):
4.Connect the negative side of the blue LEDs to the positive side of the red LEDs:
5.Connect the other side of the negative wire of the blue LEDs to pin 12 on the Espresso Lite 2.0:
6.Connect the other side of the negative wire of the red LEDs to pin 15 on the Espresso Lite 2.0:
7. Connect a jumper wire between the positive of the blue LEDs and negative of the red LEDs:
8. Make your wires nice and tidy by using the OLED as your wire slots:
9. Finally, connect your USB to UART converter to your Espresso Lite 2.0:
Connect your micro USB-cable to your project, your OLED should light up with the ESPERT logo:
LED Schematic :
I have tested out all the pins and found out that when Espresso Lite 2.0 runs my code, only pin 12 and pin 15 are idle, hence that is why I choose pin 12 and pin 15 as GPIO pin instead of the others.
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
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.
To test if your APP is working, go to https://developers.facebook.com/tools/explorer/
Enter the following: AAA?access_token=BBB|CCC&fields=fan_count as shown in the picture:
- AAA = Facebook Page ID or name,
- BBB = App ID
- CCC = App Secret
Note the | (pipe) between App ID and App Secret.
Arduino libraries
Download the following zip files on github.com on and add to your Arduino library:
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
JSON: The last library is for handling JSON-data from Facebook. Download ArduinoJson – C++ JSON library for IoT from https://github.com/bblanchon/ArduinoJson
Espresso Lite 2.0 library: To use the default OLED i2c code download this library https://github.com/JimmySoftware/ESPert2
Arduino Code
Copy and paste the following code into your Arduino IDE:
FacebookLikeCounter
- AAA = Facebook Page ID or name,
- BBB = App ID
- CCC = App Secret
- DDD = Facebook Fingerprint
Result
Tips:
- For those who require username and password web logins, I suggest you download Connectify and run a hotspot on your laptop or just use your mobile hotspot for simplicity.
- If you wish to know how the code works, you can view the explanation here:
saurabhkanswal5
February 17, 2018 — 2:37 pm
Does it can count multiple likes at a time. You put a LED light for count up and count down right but suppose 2 or more person give you like at a same time, now how can you show this through led lights.
Otherwise I like this iot device
#happycoding brother
Chia Tze Hank
February 17, 2018 — 3:01 pm
Great suggestion! Unfortunately the count up and count down is only based on the resultant count( if the increment is 2 likes it will still count as blue light up), I will try to adjust the code to your suggestions 🙂