Automating on Instagram
Many users are interested in enhancing their Instagram experience through automation, such as liking, following, and commenting. However, it is important to note that automated interactions are often detected by Instagram, which may result in temporary restrictions or account limitations. This page focuses on a more straightforward and compliant feature: retrieving the follower count of a public Instagram profile using an IoT device.

This guide demonstrates how to build a device that displays the current time, Instagram username, and follower count on an SSD1306 OLED display using the Arduino IDE and C++. For those interested in broader automation, resources such as InstaPy are available, but this tutorial will focus solely on follower count retrieval.
The hardware setup is intentionally simple to facilitate learning and experimentation with the ESP32 microcontroller, a successor to the ESP8266. The ESP32 board is wider than its predecessor, which may affect access to certain pins, but standard micro USB power can be used. The circuit requires only four connections, making it accessible for beginners.
Begin by connecting the 3.3V pin of the ESP32 to the positive rail of the breadboard and the GND pin to the negative rail. These rails then supply power to the SSD1306 display: connect the positive rail to the VCC pin and the negative rail to the GND pin of the display. Next, connect the D4 and D5 pins of the ESP32 to the SCL and SDA pins of the SSD1306, respectively. With these connections, the circuit is complete.
Proceed by installing the Arduino IDE, configuring the necessary libraries, and preparing the program for upload. The ESP32 board library can be found at the following URL:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
Add this link to File > Preferences > Additional Boards Manager URLs in the Arduino IDE. Then, select the appropriate board settings under Tools after installing the library:
Field | Value |
---|---|
Board | ESP32 Arduino > DOIT ESP32 DEVKIT V1 (This depends on the board you have) |
Upload Speed | 921600 |
Flash Frequency | 80 Mhz |
Core Debug Level | None |
Port | (This depends on the USB port the ESP32 was plugged into) |
Next lets go over our necessary packages for our script
Package | Comment |
---|---|
Wire.h | This library should already be included (if not see package SSD1306.h) |
SSD1306.h | Search for 'SSD1306' under Tools > Manage Libraries... and Install |
WiFi.h | This library should already be included (if not see package SSD1306.h) |
NTPClient.h | This library should already be included (if not see package SSD1306.h) |
WiFiUdp.h | This library should already be included (if not see package SSD1306.h) |
HTTPClient.h | This library may already be installed but labeled 'httpclient.h' which needs to be renamed 'HTTPClient.h' in order for the program to compile or vice versa |
Adafruit_GFX.h | https://github.com/adafruit/Adafruit-GFX-Library (*) |
Adafruit_LEDBackpack.h | https://github.com/adafruit/Adafruit_LED_Backpack (*) |
ArduinoJson.h | https://github.com/bblanchon/ArduinoJson (*) |
InstagramStats.h | https://github.com/witnessmenow/arduino-instagram-stats (*) |
JsonStreamingParser.h | https://github.com/squix78/json-streaming-parser (*) |
WiFiClientSecure.h | This library should already be included (if not see package SSD1306.h) |
For (*) download the zip and extract to the Arduino installation folder. Typically, under Documents > Arduino > libraries.
Next, we must specify our SSID and PWRD for our wireless network as well as indicate the IG username that we wish to return the follower count for. Here it’s important to note that we are using " (quotation marks) and not ' (single quotes).
const char* ssid = "YOUR_SSID_NAME";
const char* password = "YOUR_SSID_PWRD";
String userName = "YOUR_IG_USERNAME";
Next, we verify our script and upload to the ESP32.
The above should be the output produced after compiling assuming you have no errors. Next, we flash the program to the ESP32. This may be device dependent; on first load my ESP32 was not connecting via the COM port. Holding the BOOT button for 2 seconds successfully flashed the script.
The script should automatically load within seconds and attempt to connect to the SSID with the PWD that was provided. The script updates the follower count every hour on the hour. The interval can be changed though the Instagram AI tends to be less forgiving for small time intervals which eventually breaks the bot.
#include <Wire.h> // Only needed for Arduino 1.6.5 and earlier
#include "SSD1306.h" // alias for `#include "SSD1306Wire.h"`
#include <WiFi.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <HTTPClient.h>
#include <Adafruit_GFX.h> // https://github.com/adafruit/Adafruit-GFX-Library
#include "Adafruit_LEDBackpack.h" // https://github.com/adafruit/Adafruit_LED_Backpack
#include <ArduinoJson.h> // https://github.com/bblanchon/ArduinoJson
#include "InstagramStats.h" // https://github.com/witnessmenow/arduino-instagram-stats
#include "JsonStreamingParser.h" // https://github.com/squix78/json-streaming-parser
#include "<WiFiClientSecure.h>"
#define NTP_OFFSET +4 * 60 * 60 // segundos
#define NTP_INTERVAL 60 * 1000 // milissegundos
#define NTP_ADDRESS "0.pool.ntp.org" // Url NTP
#define SDA_PIN 5 // GPIO5 -> SDA
#define SCL_PIN 4 // GPIO4 -> SCL
#define SSD_ADDRESS 0x3c // i2c
char string[25];
const char* ssid = "YOUR_SSID_NAME";
const char* password = "YOUR_SSID_PWRD";
String formattedTime;
String ipStr;
String text;
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, NTP_ADDRESS, NTP_OFFSET, NTP_INTERVAL);
SSD1306 display(SSD_ADDRESS, SDA_PIN, SCL_PIN);
WiFiClientSecure secureClient;
WiFiClient client;
InstagramStats instaStats(secureClient);
String userName = "IG_USERNAME";
String stats;
unsigned long api_delay = 1 * 60000; //time between api requests (1mins)
unsigned long api_due_time;
void setup()
{
Serial.begin(115200);
Serial.println("");
Serial.println("ESP32 Instagram Stats");
Serial.println("");
display.init();
// display.flipScreenVertically();
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.setFont(ArialMT_Plain_10);
connectWiFi();
timeClient.begin();
InstagramUserStats response = instaStats.getUserStats(userName);
text = (String) response.followedByCount;
}
void loop()
{
timeClient.update();
formattedTime = timeClient.getFormattedTime();
Serial.print("TIME: ");
Serial.println(formattedTime);
if(timeClient.getMinutes() == 00) //updates every hour.
{
Serial.print("The number of Instagram followers of user " + userName + " is: ");
InstagramUserStats response = instaStats.getUserStats(userName);
Serial.println(response.followedByCount);
text = (String) response.followedByCount;
}
display.clear();
display.setFont(ArialMT_Plain_24);
display.drawString(17, 0, formattedTime);
display.setFont(ArialMT_Plain_10);
display.drawString(0, 25, "Instagram: ");
display.drawString(60, 25, userName);
display.setFont(ArialMT_Plain_24);
display.drawString(40, 35, text);
display.display();
delay(1000);
}
void connectWiFi(void)
{
int i;
Serial.println();
Serial.print("Connecting to: ");
Serial.println(ssid);
display.drawString(2, 10, "Connected to: ");
display.drawString(1, 25, String(ssid));
display.display();
WiFi.begin(ssid, password);
while ((WiFi.status() != WL_CONNECTED) && i < 100)
{
i ++;
delay(500);
Serial.print(".");
display.drawString((3 + i * 2), 35, "." );
display.display();
}
if ( WiFi.status() == WL_CONNECTED)
{
IPAddress ip = WiFi.localIP();
ipStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);
display.clear();
display.setFont(ArialMT_Plain_16);
display.drawString(0, 0, "WiFi Connected!");
display.drawString(0, 25, ipStr);
Serial.println("");
Serial.println("WiFi Connedcted.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Serial.print("Subnet Mask: ");
Serial.println(WiFi.subnetMask());
Serial.print("Gateway: ");
Serial.println(WiFi.gatewayIP());
display.display();
}
else
{
ipStr = "NOT CONNECTED";
display.clear();
display.setFont(ArialMT_Plain_16);
display.drawString(0, 0, "WiFi not connected.");
display.drawString(0, 25, ipStr);
Serial.println("");
Serial.println("WiFi not connected.");
display.display();
}
delay(1000);
}