A documentation of my works related to robotics.

Facebook Like Counter with Espresso Lite 2.0

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

26782003_1485241741588672_173843689_o.jpg

For this project, you would need (click on the underlined names in the list to open the link) :

  1. An Espresso Lite 2.0 (esp8266 module) [Top Left]
  2. An OLED i2C [Bottom centre]
  3. 4 different colours of jumper wires [Wires on the right]
  4. 2 pairs of red and blue LEDs [Top centre]
  5. USB to UART converter [Bottom Left]
  6. 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:

26693111_1485241724922007_902298849_o.jpg

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):

26693093_1485241678255345_560586531_o.jpg

4.Connect the negative side of the blue LEDs to the positive side of the red LEDs:

26695449_1485241671588679_651282179_o

5.Connect the other side of the negative wire of the blue LEDs to pin 12 on the Espresso Lite 2.0:

26828418_1485241661588680_2099674831_o

6.Connect the other side of the negative wire of the red LEDs to pin 15 on the Espresso Lite 2.0:

26735938_1485241634922016_172120589_o

7. Connect a jumper wire between the positive of the blue LEDs and negative of the red LEDs:

26695278_1485241608255352_888828511_o

8. Make your wires nice and tidy by using the OLED as your wire slots:

26828688_1485241571588689_280265332_o.jpg

9. Finally, connect your USB to UART converter to your Espresso Lite 2.0:

26732473_1485241551588691_1284017620_o

Connect your micro USB-cable to your project, your OLED should light up with the ESPERT logo:

26695082_1485241524922027_141456977_o

LED Schematic :

26735362_1485357721577074_1026560851_o

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

  1. Facebook APP https://developers.facebook.com/
  2. Facebook fingerprint https://github.com/gbrault/esp8266-Arduino/blob/master/doc/esp8266wifi/client-secure-examples.md#how-to-verify-servers-identity
  3. Arduino IDE https://www.arduino.cc/en/Main/Software

Facebook APP

iii.png

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:

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

Untitled.png

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

2.png

Arduino Code

Copy and paste the following code into your Arduino IDE:
FacebookLikeCounter

Result

Tips:

  1. 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.
  2. If you wish to know how the code works, you can view the explanation here:
« »