Partage
  • Partager sur Facebook
  • Partager sur Twitter

Compteur instagram

Arduino esp8266

    3 mars 2021 à 9:00:40

    Bonjour à tous,

    J'ai besoin d'aide pour un projet de compteur Instagram.

    J'ai acheter un code mais celui-ci est à se qu'il parait erroné ...

    Je n'ai aucune connaissance sur la programmation Arduino, je comprend un peu mais je ne sais pas écrire le code.

    On m'a dit que la clé API d'Instagram à changer et donc c'est pour cela qu'il ne fonctionne pas.

    Le code que je possède est en dossier ZIP. Je peux vous l'envoyer en message privée.

    Pour le projet, j'ai un module esp8266 et une matrice Max7219 à ma disposition.

    J'ai installer toutes les librairies etc ... mais rien y fait.

    J'ai déjà réaliser un compteur Youtube en suivant un tuto sur internet mais la, en faire un que pour Instagram je bloque et ne trouve personne pour m'aider.

    Comment faire ?

    Ci-dessous le code (acheté) :

    /* Version 1.1 21/05/2019  by nabu3d
     *  v.1.1 - Adapted to support different MAX7219 8x32 displays (FC16_HW, PAROLA_HW, ICSTATION_HW, GENERIC_HW)
     *  
     *  Following code use the library InstagramStats by Brian Laugh, no sensible information are needed, just any Instagram user name, the data are parsed from public Instagram website
     *  for this reason the followers number may be slightly different from what available on your profile, this data is taken and visible from your Instagram public web page.
     *  
     *  Instagram followers info is updated every minute, a short display freeze may occur during update
     *  
     *  Bill of material:
     *  - Display: MAX7219 display 8x32
     *  - Microcontroller: ESP8266 NodeMCU Amica V2 ESP-12E WiFi development board with CP2102 for Arduino
     *  - Micro USB cable (for power supply and data transfer during software upload)
     *  
     *  Below a short summary of installation and settings:
     *  - Install drivers for ESP8266 NodeMCU Amica V2 ESP-12E WiFi development board: https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers
     *  - Go to Arduino/Preferences/ Additionals Boards Manager URLs and add following url (if you have other urls, separate them by a comma): http://arduino.esp8266.com/stable/package_esp8266com_index.json
     *  - Install ESP8266 board on Arduino (go to Tools/Board/Boards Manager), search "esp8266" (esp8266 by ESP8266 Community).
     *  - Choose the right board (Tools/Boards/...) and check that settings are:
     *     - Board: "NodeMCU 1.0 (ESP-12E Module)"
     *     - Upload Speed: "115200"
     *     - CPU frequency: "80 MHz"
     *     - Flash Size: "4M (3M SPIFFS)"
     *     - Debug port: "Disabled"
     *     - Debug Level: "None"
     *     - IwIP Variant: "v2 Lower Memory"
     *     - VTables: "Flash"
     *     - Exceptions: "Disabled"
     *     - Erase Flash: "Only Sketch"
     *     - Port: "COM" on Windows, "ttyUSB" or "...SPPDev" on MacOS
     *     - Programmer: "Arduino as ISP"
     *   - Install following libraries (go to Tools/Manage Libraries):
     *      - For Instagram Statistics: "InstagramStats" (InstagramStats by Brian Lough), "Json Streaming Parser" (Json Streaming Parser by Daniel Eichhorn)
     *      - For MAX7219 display: MD_Parola, MD_MAX72xx
     *   - Go to Documents/Arduino/libraries/InstagramStats/src/InstagramStats.cpp, open this file with a text editor (e.g. notepad) and and change from "3000" to "30000" the value in the following line "while (millis() - now < 30000) {"
     *     (above change is done to solve issues that may occur were returned followers number is zero)
     *
     * INSTRUCTION FOR USE, change following variables in the following code:
     *  - ssid --> "your network SSID (name)"
     *  - password --> "your network password"
     *  - userName --> "your Instagram user name"  - from your instagram url https://www.instagram.com/"your_username"
     *  - scrollSpeed --> adjust the scrolling speed
     *  if you find strange display behaviour choose the right display seettings (uncomment //#define HARDWARE_TYPE MD_MAX72XX.....)
     *  
     * Connect your display to following PIN of WiFi dev board:
     *  - CLK_PIN   D5
     *  - DATA_PIN  D7
     *  - CS_PIN    D8
     *  - VCC       3v3
     *  - GND       GND
     *  
     * For debugging and for your info you can see the WiFi connection status and the followers number also on Arduino Serial Monitor (choose speed 115200 baud)
     */


    /*
     * Following code is used for MAX7219 display setup
    */
    //-----------------------------------------------------
    #include <MD_Parola.h>
    #include <MD_MAX72xx.h>
    #include <SPI.h>

    //Here you can choose from different display types (uncomment the right one),
    //try other types if you find strange display behaviour (texts flipped/reveresed, etc.)

    #define HARDWARE_TYPE MD_MAX72XX::FC16_HW          //version of the display we used (FC-16 type)

    //#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW      //< Use the Parola style hardware modules.
    //#define HARDWARE_TYPE MD_MAX72XX::GENERIC_HW     //< Use 'generic' style hardware modules commonly available.
    //#define HARDWARE_TYPE MD_MAX72XX::ICSTATION_HW   //< Use ICStation style hardware module.
    //#define HARDWARE_TYPE MD_MAX72XX::FC16_HW        //< Use FC-16 style hardware module.

    #define MAX_DEVICES 4          //number of 8x8 led modules

    // connect your display to following PIN of WiFi dev board
    #define CLK_PIN   D5
    #define DATA_PIN  D7
    #define CS_PIN    D8

    // Hardware SPI connection
    MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
    // Arbitrary output pins
    //MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);


    //Other parameters for manage the MAX7219 display output
    //They are used in the following function: P.displayText(curMessage, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);

    uint8_t scrollSpeed = 80;    // this parameter change the scrolling speed, it's the only to be adjusted
    textEffect_t scrollEffect = PA_SCROLL_LEFT;
    textPosition_t scrollAlign = PA_LEFT;
    uint16_t scrollPause = 0; // in milliseconds

    //-----------------------------------------------------


    /*
     * Following code is used for ESP8266 NodeMCU Amica V2 ESP-12E WiFi development board and Instagram Statistics
    */
    //-------------------------------------------------------------------------------------------------------------

    #include "InstagramStats.h"

    // define and initialize followers variable
     unsigned long followers =0;
     char buffer [17]; //to store followers formatted text (with thousands separator points)

    // ----------------------------
    // Standard Libraries - Already Installed if you have ESP8266 set up
    // ----------------------------

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

    // ----------------------------
    // Additional Libraries - each one of these will need to be installed.
    // ----------------------------

    #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

    //------- Replace the following! ------
    char ssid[] = "yourSSD";         //<------------------------------------------------- your network SSID (name)
    char password[] = "yourPassword"; // <------------------------------------------------your network key

    WiFiClientSecure client;
    InstagramStats instaStats(client);

    unsigned long delayBetweenChecks = 60000; //mean time between api requests
    unsigned long whenDueToCheck = 0;

    //Inputs
    String userName = "nabu_3d"; // example from instagram url https://www.instagram.com/nabu_3d

    //-------------------------------------------------------------------------------------------------------------



    void setup()
    {

      //for MAX7219 display
      P.begin();
      P.displayText(buffer, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);
     
     
      // for ESP8266 NodeMCU Amica V2 ESP-12E WiFi development board
      Serial.begin(115200);

      // Set WiFi to station mode and disconnect from an AP if it was Previously
      // connected
      WiFi.mode(WIFI_STA);
      WiFi.disconnect();
      delay(100);

      // Attempt to connect to Wifi network:
      Serial.print("Connecting Wifi: ");
      Serial.println(ssid);
      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);

      // If using ESP8266 Core 2.5 RC, uncomment the following
      client.setInsecure();   //keep uncommented if you use ESP8266 NodeMCU Amica V2 ESP-12E WiFi development board
    }


    //Function to get Instagram followers number
    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);
     
      //get followers number
      followers = response.followedByCount;
    }




    void loop()
    {
      unsigned long timeNow = millis();
      if ((timeNow > whenDueToCheck))
      {
        getInstagramStatsForUser();
        whenDueToCheck = timeNow + delayBetweenChecks;
      }

       // following code is to format the followers number with a thousand comma (point) separator, works up to 999.999.999 followers
       if (followers < 1000){
       sprintf(buffer, "%d", followers);
       }
     
       if (followers >=1000 && followers< 1000000){
       int thousands = followers / 1000;
       int hundreds = followers % 1000;
       sprintf(buffer, "%d.%03d", thousands, hundreds);
       }
       
       if (followers >=1000000 && followers< 1000000000){
       int hundredthousands = followers / 1000000;
       int thousands_temp = followers % 1000000;
       int thousands = thousands_temp / 1000;
       int hundreds = thousands_temp % 1000;
       sprintf(buffer, "%d.%03d.%03d", hundredthousands, thousands, hundreds);
       }
       
       
        //for MAX7219 display
        if (P.displayAnimate())
           {
           P.displayReset();
           }
        
    }

    Merci d'avance !

    • Partager sur Facebook
    • Partager sur Twitter
      10 mars 2021 à 10:05:51

      Bonjour,

      En l'état, le code est assez illisible... je t'invite à éditer ton message pour utiliser les balises codes avec le petit bouton </> au dessus de la zone d'édition.

      Sinon, pour en revenir au problème de l'API Instagram, si celle-ci a changé, une bonne chose à faire serait d'essayer de la dernière version de la lib arduino-instagram-stats : https://github.com/witnessmenow/arduino-instagram-stats/tree/master/src

      Vérifie aussi que les champs ssid et password de configuration de ton réseau WIFI sont correct, ainsi que le champ userName du compte Instagram.

      Si le problème persiste, il faudrait que tu nous donne ce que tu vois sur la console arduino, il y a peut-être un message d'erreur qui pourrait nous mettre sur la piste.

      • Partager sur Facebook
      • Partager sur Twitter

      Compteur instagram

      × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
      × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
      • Editeur
      • Markdown