ESP8266 Projects

Display your Instagram Likes – with an ESP8266 and LEDs

Instagram Likes ESP8266

You post photos and videos on Instagram? But notifications about new likes on your smartphone are too boring for you? Then try something new!

With this ESP8266 project you regularly request the number of your Likes for your latest Instagram Post online. Depending on how many Likes have been added since the last request, LEDs will light up to quench your thirst for recognition 😉

What do you learn in this ESP8266 project?

The setup of this project is intentionally kept simple so that you can fully concentrate on the code under the hood. You will learn in this project

Beginner- Advanced

1 – 2 hours

approx. $8

For this project you need (quantities see description):

Elegoo 3mm 5mm Diffus und klar Sortiert LED Kit 5 Farben fĂŒr Arduino (600er Set)
3mm und 5mm / Diffus und Klar Rund LED Kit; Kopf: Rund. Weiß emittierende Dioden...
13,99 EUR
10 StĂŒck MetallschichtwiderstĂ€nde 1/4 Watt - 220 Ohm
10 StĂŒck MetallschichtwiderstĂ€nde 1/4 Watt - 220 Ohm; Dauerspannung max.: 250 V |...
AZDelivery Mini Breadboard 400 Pin mit 4 Stromschienen kompatibel mit Arduino und Jumper Wire Kabeln
✔ Breadboard – kaufen Sie jetzt zum Vorteilspreis!; ✔ Steckbrett fĂŒr...

The set up of the project

As already mentioned, the first step is to set up the system on the breadboard. You can let your creativity run free later.

Just connect the anodes (long leg) of the 4 LEDs of your choice to pins D2, D5, D6 and D8. The cathode (short leg) comes to GND. Do not forget to connect a resistor to each LED. That’s it. This is how it could look like on your breadboard:

Setting up ESP8266 Project Instagram Likes

The sketch

Somewhat more sophisticated is the code you need. So let’s go through the most important parts step by step. The link to the full sketch on GitHub is below.

The required libraries

Insgesamt brauchst du drei Bibliotheken fĂŒr dieses Projekt: Eine fĂŒr die Internetverbindung (ESP8266WiFi.h), eine fĂŒr das Herunterladen der Daten (WiFiClientSecure.h) und eine, um die JSON-Daten zu parsen (ArduinoJson.h).

#include <ArduinoJson.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>

If you have not yet installed these libraries in your Arduino IDE, you can do so in the Library Manager.

Further information and variables

In order for your ESP8266 to be able to access the Internet, you must of course give it your credentials. You also have to specify the URL to which he should then connect – here, of course,

#define WIFI_SSID "your SSID"
#define WIFI_PASSWORD "your password"

#define REQUEST_HOST ""

Then you specify the part of the address that contains the name of the account whose Likes you want to request. In this example the account is spacex – the space company of Elon Musk. You can simply replace this name with your own Instagram account. But be careful not to accidentally delete the adjacent slashes (/).

#define REQUEST_PATH "/spacex/?__a=1"

Finally you need two variables to compare the likes of the requests. This way you can find out if there are new likes for your latest post.

int likesOld;
int likesNew;

The setup function

Here you first define the four pins to which your LEDs are connected. Then you start the serial monitor and connect your ESP8266 to the internet.

void setup() {

  //Pins festlegen
  pinMode (4, OUTPUT); // am ESP8266: D2
  pinMode (12, OUTPUT); // am ESP8266: D6
  pinMode (14, OUTPUT); // am ESP8266: D5
  pinMode (15, OUTPUT); // am ESP8266: D8

  // Seriellen Monitor starten

  // Mit dem WLAN verbinden
  while (WiFi.status() != WL_CONNECTED) {
    Serial.println(F("Connecting to WiFi"));

The Loop

In the Loop you parse the data of your Likes and let your LEDs light up.

Your ESP8266 first sends a request to Instagram to get the desired data in JSON format. You can view this data in raw format, for example, by opening this address in your browser:

In this mess are not only your Likes of the last 24 of your posts, but also the number of your followers, meta data of your account and much more. You can find the code for this request in the full sketch.

Parsing JSON and picking out the Likes

Your ESP8266 now has the connection to the data it needs. As you may have seen in your browser, the amount of data is very large – too large even for the memory of your small microcontroller. Therefore, you do not load all the data (of which you only need a single number anyway) into memory, but stream it. That means, you read it bit by bit.

The library ArduinoJson, which you have already included in your sketch above, is perfectly suited for parsing the data. Here you can learn more about the JSON format.

This is how the beginning of the JSON data of Instagram accounts from Spacex looks formatted:

JSON from Instagram

We save the first few lines and jump directly to the “user”element, because this is where your Likes are hidden. For this you use the function client.find():

  if (!client.find("\"user\":")) {
    Serial.println(F("Array \"user\" not found in response"));

But that’s not all, you need to go deeper into the JSON data:

Even more JSON from Instagram

Further down in the JSON you find the two elements “edge_owner_to_timeline_media” and “edges”. Again you jump to these elements (code in the complete sketch) before you start parsing:

//JSON parsen
auto err = deserializeJson(doc, client);
if (err) {
  Serial.print(F("deserializeJson() failed with code "));

//Die gefundenen Likes in die Variable likesNew speichern
likesNew = doc["node"]["edge_liked_by"]["count"];

In the last line of the code above, you drag the current likes into the variable likesNew. You can find them in the JSON here:

Likes in JSON from Instagram

If you want to see the whole structure of this data, copy the unformatted data from your browser into a JSON formatting tool – this way you can find the parts you are looking for much easier.

Let the LEDs light up with your Likes

There are four LEDs on your ESP8266 project, which you light up depending on the number of your Likes. You could, of course, just turn them on and off – but if they do that slowly like a dimmer, it looks a lot more satisfying.

The function you need for this is called pulse width modulation (PWM). In short: With PWM you can slowly increase and decrease the brightness of your LEDs. Here you can read all about PWM.

In your code it will look like this. In a for-loop you turn the dimmer “slowly” up until it reaches the value 255 – the full brightness. Then you wait a short time and turn the brightness down again.

In this example you do this for all four LEDs at the same time, because you have received more than five Likes since the last request. The other loops (for less Likes) can be found in the full sketch.

  if (likesNew > likesOld + 5) {
    for (int light = 0; light <= 255; light++) {
      analogWrite(15, light);
      analogWrite(12, light);
      analogWrite(14, light);
      analogWrite(4, light);
    for (int light = 255; light >= 0; light--) {
      analogWrite(15, light);
      analogWrite(12, light);
      analogWrite(14, light);
      analogWrite(4, light);
    likesOld = likesNew;

Now all that remains is a delay that controls how often you want to request the likes. It’s exciting to follow the likes in real time – for example, than to request a query every two seconds. But we recommend to set the value a bit higher, also so that you can collect enough Likes in the meantime to make all LEDs light up 😉 How about 30 seconds?


You can find the whole sketch on GitHub for copying and trying out:

One more note: The function of this project depends heavily on the Instagram API. If something is changed there, you might have to adapt the sketch accordingly.

What’s next?

Now you are in charge. The setup of this project is very easy with the simple LEDs. Find more creative ideas: Maybe a bell that you strike with a servo? Or even a display that shows you a heart when a new Like is released. Learn here how to connect an OLED display to your ESP8266 and show pictures on it.

Letzte Aktualisierung am 2021-01-09 / Affiliate Links / Bilder von der Amazon Product Advertising API

You may also like

Comments are closed.