SuperKitz.com Project Manual
Instagram Followers Counter With ESP32 and OLED Display DIY Kit
Using esp32.
Having a display in any electronics project makes it more interesting as you can visualize data with it. With that in mind I thought it’d be useful if I have a small display, connected to the Internet in my work space. In this project to connect my ESP module to Internet to fetch the Instagram stats then display them on my OLED display. This IOT enabled project makes a great inclusion to your workbench if you are an avid Instagram user.
Requirements :
- Computer/Smartphone with an internet connection
- Download and install Arduino IDE
Components
NodeMCU ESp8266
1 nos
Jumper wires
1 nos
0.98" OLED Screen
1 nos
Hardware
Getting
Started with
Web Switch ESP8266
NodeMCU ESP8266
NodeMCU is an open-source Lua based firmware and development board specially targeted for IoT based applications.It includes firmware that runs on the ESP8266 Wi-Fi SoC from Espressif Systems and hardware which is based on the ESP-12 module.
Pin out diagram
ESP32
0.96" inch OLED display (SSD1306)
Pin Wiring to Arduino Uno
Vin-5V GND-GND SCL-A5 SDA-A4
Introducing the 0.96 inch OLED display
This is a 0.96″ inch OLED display which we can use to connect to an arduino so we can display an output .We can interface using an SPI/I2C protocol. This is a very advanced module if you look in terms of features .It has HIGH brightness , HIGH viewing angles ,LOW power consumption , and a very THIN formfactor .It also has a very HIGH resolution (128*64 pixels) . It doesnt need a backlight like the LCD display .It takes around 0.06 W for a normal operations.
The module we are using here has 4 pins and we will be communicationg with it using I2C protocol with the arudino .
there are models which comes with an extra RESET pin /There are also ones which communicate with SPI protocol.
Circuit Diagram
STEP1:
CONNECTING OLED SCREEN TO ESP32
Connections Explained:-
VCC OLED — > Vin of ESP32
GND OLED — > GND of ESP32
SDA OLED — > D21 of ESP32
SCK OLED — > D22 of ESP32
- Connect all the components provided in the kit according to the provided wiring diagram mention in the documentation.
OLED Screen Connection Diagram
With ESP32
Print Paper Template [A4 ]
Here is a printable template.
PROGRAMMING
The NodeMCU programming can be as easy as in Arduino, the main difference is the distribution of pins in the nodemcu board. Following below operations and enjoy your first NodeMCU & Arduino IDE
Step 1: Install the Arduino IDE 1.6.4 or Greater
Download Arduino IDE from Arduino.cc / superkitz.com You can use your existing IDE if you have already installed it. You can also try downloading the ready-to-go package from the ESP8266-Arduino project if the proxy is giving you problems.
In order to upload code to the ESP8266 and use the serial console, connect any data-capable micro USB cable to ESP8266 IOT Board and the other side to your computer’s USB port.
The new version NodeMCUv1.0 comes with the CP2102 serial chip, you can download (also provided with the kit) and install the driver from https://www.silabs.com/products/development-tools/…. The NodeMCUv0.9 comes with the CH340 serial chip, you can download and install the driver from: https://github.com/nodemcu/nodemcu-devkit/tree/mas…
Step 2: Installing NodeMCU package for Arduino IDE
Paste the copied link(givenbelow) and insert it(add. boad Manager URL) in Arduino IDE using the following sequence->File menu -> Preferences-> Paste copied link into the area shown in the black box in the above image. Close and restart the Arduino IDE.
The link should look something like this:
http://arduino.esp8266.com/stable/package_esp8266com_index.json
Paste the copied link and insert it in Arduino IDE using the following sequence->File menu -> Preferences-> Paste copied link into the area shown in the black box in the above image. Close and restart the Arduino IDE.
Tools -> Boards manager and search for ESP8266 and install the libraries/files given under the heading ESP8266 by ESP community.
Restart the Arduino IDE once again.
Scroll down, select the ESP8266 board menu and install “esp8266 by ESP8266 Community”, as shown in the figure below.
If you used the Installer, Windows – from XP up to 10 –
- Delete the Documents -> Arduino -> Libraries to remove all your libraries.
- Delete the User -> AppData -> Local -> Arduino15 folder to remove all the preferences.
- Uninstall Arduino IDE.
- Install a fresh one.
If you used the -Mac OX from –
First of all, make sure to log into your Mac with an administrator account, or you will be asked for a password when you try to delete something.
Open the Applications folder in the Finder (if it doesn’t appear in the sidebar, go to the Menu Bar, open the “Go” menu, and select Applications in the list), search for Arduino 1.6.4 application by typing its name in the search field, and then drag it to the Trash (in the dock) to begin the uninstall process. Alternatively you can also click on the Arduino 1.6.4 icon/folder and move it to the Trash by pressing Cmd + Del or choosing the File and Move to Trash commands.
Remove all components related to Arduino 1.6.4 in Finder
Though Arduino 1.6.4 has been deleted to the Trash, its lingering files, logs, caches and other miscellaneous contents may stay on the hard disk. For complete removal of Arduino 1.6.4, you can manually detect and clean out all components associated with this application. You can search for the relevant names using Spotlight. Those preference files of Arduino 1.6.4 can be found in the Preferences folder within your user’s library folder (~/Library/Preferences) or the system-wide Library located at the root of the system volume (/Library/Preferences/), while the support files are located in “~/Library/Application Support/” or “/Library/Application Support/”.
Open the Finder, go to the Menu Bar, open the “Go” menu, select the entry:|Go to Folder… and then enter the path of the Application Support folder:~/Library
Search for any files or folders with the program’s name or developer’s name in the ~/Library/Preferences/, ~/Library/Application Support/ and ~/Library/Caches/ folders. Right click on those items and click Move to Trash to delete them.
Go to Tools – Boards (scroll down the list of boards) – Select NodeMCU 1.0 ( ESP-12EModule).
Select the Port number at which you have connected nodeMCU. The rest of the settings can be left to default values.
Install Arduino Library for Arduino IDE
Install Arduino-InstagramStats as ZIP file in Arduino IDE
InstagramStats library is available as a downloadable ZIP . Starting with Arduino IDE version 1.0.5, you can install 3rd party libraries in the IDE.
Download InstagramStats Library by clicking the button: Download InstagramStats
Do not unzip the downloaded library, leave it as is.
- In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP Library. At the top of the drop down list, select the option to “Add .ZIP Library‘‘.
- Then select the library zip file you have downloaded.
- Return to the Sketch > Include Library menu. menu. You should now see the library at the bottom of the drop-down menu. It is ready to be used in your sketch. The zip file will have been expanded in the libraries folder in your Arduino sketches directory.
Install json-streaming-parser-master as ZIP file in Arduino IDE
json-streaming-parser-masteri library is available as a downloadable ZIP . Starting with Arduino IDE version 1.0.5, you can install 3rd party libraries in the IDE.
Download json-streaming-parser-master Library by clicking the button: Download json-streaming-parser-master
2.Install Adafruit_SSD1306 as ZIP file in Arduino IDE
- Repeat the above process for the Adafruit_SSD1306 library is available as a downloadable ZIP.
- Download Adafruit_SSD1306 Library by clicking the button: Download Adafruit_SSD1306 Library
Arduino Code
Download the Arduino source code.
We are using adafruit_SSD1306 oled display for the displaying the status.
INSTAGRAM COUNT WITH DIGITAL DISPLAY:
We will use Instastat Library to get the Instagram Followers count. You can download this Instastat library from here. Install the above downloaded library to the Arduino libraries folder.
#include // Only needed for Arduino 1.6.5 and earlier
#include "SSD1306Wire.h" // legacy: #include "SSD1306.h"
#include "InstagramStats.h"
#include
#include
#include "JsonStreamingParser.h"
// Used to parse the Json code within the library
// Available on the library manager (Search for "Json Streamer Parser")
// https://github.com/squix78/json-streaming-parser
SSD1306Wire display(0x3c, SDA, SCL); // ADDRESS, SDA, SCL - SDA and SCL usually populate automatically based on your board's pins_arduino.h
char ssid[] = "POCO PHONE"; // your network SSID (name)
char password[] = "12345678"; // your network key
int followers = 0;
WiFiClientSecure client;
InstagramStats instaStats(client);
unsigned long delayBetweenChecks = 60000; //mean time between api requests
unsigned long whenDueToCheck = 0;
//Inputs
String userName = "_.sibi_"; // from their instagram url
void setup() {
Serial.begin(115200);
display.init();
display.flipScreenVertically();
display.setFont(ArialMT_Plain_10);
// Attempt to connect to Wifi network:
Serial.print("Connecting Wifi: ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
IPAddress ip = WiFi.localIP();
Serial.println(ip);
}
void getInstagramStatsForUser() {
Serial.println("Getting instagram user stats for " + userName );
InstagramUserStats response = instaStats.getUserStats(userName);
Serial.println("Response:");
Serial.print("Number of followers: ");
Serial.println(response.followedByCount);
followers = response.followedByCount;
}
void drawFontFaceDemo() {
// Font Demo1
// create more fonts at http://oleddisplay.squix.ch/
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.setFont(ArialMT_Plain_16);
display.drawString(0, 0, "superkitzdiy");
display.setFont(ArialMT_Plain_10);
display.drawString(0, 16, "Number of followers:");
display.setFont(ArialMT_Plain_24);
display.drawString(0, 26, String(followers));
display.display();
}
void loop() {
unsigned long timeNow = millis();
if ((timeNow > whenDueToCheck)) {
getInstagramStatsForUser();
drawFontFaceDemo();
whenDueToCheck = timeNow + delayBetweenChecks;
}
}
Then, click the Upload button in the Arduino IDE and wait a few seconds until you see the message “Done uploading.” in the bottom left corner.
Output
On the Oled screen You can see the Instagram Follower count.