Test ecran LED TM1637

Bonjour à tous,

Je fait mes premiers pas dans le monde de l'arduino et j'ai décidé de me lancer dans un compteur de vues youtube, relié à ma chaine via la clef API.

J'utilise :

1 - Module ESP8266 Wifi "ESP-12E"

1 - 4 bits Digital Tube LED Display "TM1637"

1 - Circuit imprimé avec cables.


  1. Pour commencer, j'ai testé la carte ESP8266.

Test Blink = OK
Test Wifi Acess Point = OK

  1. J'ai ensuite cable mon écran led comme ceci :

CLK -> D6 (VERT)
CS -> D7 (JAUNE)
DIN -> D8 (ORANGE)]

  1. Ce qui donne ceci :


Mon problème est le suivant :

Lorsque je charge le code Exemple pour la librairie TM1637 TEST, le téléversement se passe bien, mais l'écran s'allume après un délais de 30min au moins... Je n'ai pas pu vérifier si ce délais est régulier (toutes les 30min) mais le problème est récurrent.
Après ce délais, l'écran reste allumé en mode Test et fonctionne correctement.

J'ai essayé de rechercher dans le code si il y avait une ligne concernant un délais mais je ne trouve pas.

Auriez vous une idée de mon problème ?

Voici mon code :

#include <Arduino.h>
#include <TM1637Display.h>

// Module connection pins (Digital Pins)
#define CLK D6
#define DIO D8

// The amount of time (in milliseconds) between tests
#define TEST_DELAY   2000

const uint8_t SEG_DONE[] = {
SEG_B | SEG_C | SEG_D | SEG_E | SEG_G,           // d
SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F,   // O
SEG_C | SEG_E | SEG_G,                           // n
SEG_A | SEG_D | SEG_E | SEG_F | SEG_G            // E
};

TM1637Display display(CLK, DIO);

void setup()
{
}

void loop()
{
 int k;
 uint8_t data[] = { 0xff, 0xff, 0xff, 0xff };
 uint8_t blank[] = { 0x00, 0x00, 0x00, 0x00 };
 display.setBrightness(0x0f);

 // All segments on
 display.setSegments(data);
 delay(TEST_DELAY);

 // Selectively set different digits
 data[0] = display.encodeDigit(0);
 data[1] = display.encodeDigit(1);
 data[2] = display.encodeDigit(2);
 data[3] = display.encodeDigit(3);
 display.setSegments(data);
 delay(TEST_DELAY);

 /*
 for(k = 3; k >= 0; k--) {
display.setSegments(data, 1, k);
delay(TEST_DELAY);
}
 */

 display.clear();
 display.setSegments(data+2, 2, 2);
 delay(TEST_DELAY);

 display.clear();
 display.setSegments(data+2, 2, 1);
 delay(TEST_DELAY);

 display.clear();
 display.setSegments(data+1, 3, 1);
 delay(TEST_DELAY);


 // Show decimal numbers with/without leading zeros
 display.showNumberDec(0, false); // Expect: ___0
 delay(TEST_DELAY);
 display.showNumberDec(0, true);  // Expect: 0000
 delay(TEST_DELAY);
display.showNumberDec(1, false); // Expect: ___1
delay(TEST_DELAY);
 display.showNumberDec(1, true);  // Expect: 0001
 delay(TEST_DELAY);
 display.showNumberDec(301, false); // Expect: _301
 delay(TEST_DELAY);
 display.showNumberDec(301, true); // Expect: 0301
 delay(TEST_DELAY);
 display.clear();
 display.showNumberDec(14, false, 2, 1); // Expect: _14_
 delay(TEST_DELAY);
 display.clear();
 display.showNumberDec(4, true, 2, 2);  // Expect: 04__
 delay(TEST_DELAY);
 display.showNumberDec(-1, false);  // Expect: __-1
 delay(TEST_DELAY);
 display.showNumberDec(-12);        // Expect: _-12
 delay(TEST_DELAY);
 display.showNumberDec(-999);       // Expect: -999
 delay(TEST_DELAY);
 display.clear();
 display.showNumberDec(-5, false, 3, 0); // Expect: _-5_
 delay(TEST_DELAY);
 display.showNumberHexEx(0xf1af);        // Expect: f1Af
 delay(TEST_DELAY);
 display.showNumberHexEx(0x2c);          // Expect: __2C
 delay(TEST_DELAY);
 display.showNumberHexEx(0xd1, 0, true); // Expect: 00d1
 delay(TEST_DELAY);
 display.clear();
 display.showNumberHexEx(0xd1, 0, true, 2); // Expect: d1__
 delay(TEST_DELAY);
 
// Run through all the dots
for(k=0; k <= 4; k++) {
display.showNumberDecEx(0, (0x80 >> k), true);
delay(TEST_DELAY);
}

 // Brightness Test
 for(k = 0; k < 4; k++)
data[k] = 0xff;
 for(k = 0; k < 7; k++) {
   display.setBrightness(k);
   display.setSegments(data);
   delay(TEST_DELAY);
 }
 
 // On/Off test
 for(k = 0; k < 4; k++) {
   display.setBrightness(7, false);  // Turn off
   display.setSegments(data);
   delay(TEST_DELAY);
   display.setBrightness(7, true); // Turn on
   display.setSegments(data);
   delay(TEST_DELAY);  
 }


 // Done!
 display.setSegments(SEG_DONE);

 while(1);
}

Merci pour votre aide.

Cdt, Florian

Bonjour et Bienvenue

Bien prendre connaissance des Règles du forum et de la publication de code
Tel quel ton code est lisible mais il est demandé d'utiliser les balises spécifiques pour le code
Ainsi édité le transfert propre dans l'IDE Arduino sera facilité et ça favorisera les réponses

Câblage ESP8266: eviter dans la mesure du possible d'utliser GPIO0 GPIO2 et GPIO15 (D3,D4 et D8)
(ces trois pins ont des particularités liée sau démarrage de l'ESP8266)

Il se pourrait que l'entrée /sortie DIO du TM1637 , actuellement reliée à GPIO15, perturbe le démarrage de l'ESP8266

La carte que tu mets en photo est connue comme carte "NodeMCU" , c'est un module ESP12 .....entouré de quelques composants,pas un ESP12 seul.

Bonjour,

Merci à vous, je viens d'éditer mon post en incluant les balises spécifiques.

Cdt

tester , comme ajouté plus haut, en reliant DIO ("DIN") à une broche autre de GPIO15 (éviter aussi GPIO0 et GPIO2)

(La broche marquée DIN sur le module afficheur est en fait une entrée/sortie notée DIO sur la doc de la puce TM1637)

Bonjour,

Un énorme merci à vous.

J'ai effectué la modification en passant le DIN de D8 à D7 et cela fonctionne.

Il ne me reste plus qu'a comprendre comment paramètrer le code que l'écran affiche le nombre d'abonnés youtube.

Il y a déja des codes tout fait, mais en utilisant d'autre écrans..

A investiguer...

Me voici de retour.

J'ai réussi à récupèrer un code pour configurer un compteur youtube.

J'ai récupéré :

  • ma clef API.
  • Mon chanel ID.

Je possède toutes les librairies qui sont présentes dans le code et je sais que celui ci a été fait pour un autre écran de la marque ADAFRUIT.

VOICI LE CODE :

#include <YoutubeApi.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <Wire.h>                  // installed by default
#include <TM1637Display.h>


// For storing configurations
#include "FS.h"
#include <TM1637Display.h>

// WiFiManager Libraries
#include <DNSServer.h>            //Local DNS Server used for redirecting all rs to the configuration portal
#include <ESP8266WebServer.h>     //Local WebServer used to serve the configuration portal
#include <WiFiManager.h>          //https://github.com/tzapu/WiFiManager WiFi Configuration Magic

const int resetConfigPin = D8; //When high will manually reset the wifi manager config

char apiKey[45] = "AIzaSyu_htq1VTmk";
char channelId[30] = "UCEFCscew";

// label the displays with their i2c addresses
struct {
  uint8_t           addr;         // I2C address
  Adafruit_7segment seg7;         // 7segment object
} disp[] = {
  { 0x71, Adafruit_7segment() },  // High digits
  { 0x70, Adafruit_7segment() }   // Low digits
};

WiFiClientSecure client;
YoutubeApi *api;

unsigned long api_mtbs = 60000; //mean time between api requests
unsigned long api_lasttime;   //last time api request has been done

long subscriberCount = 0;

// flag for saving data
bool shouldSaveConfig = false;

//callback notifying us of the need to save config
void saveConfigCallback () {
  Serial.println("Should save config");
  shouldSaveConfig = true;
}

void setup() {

  Serial.begin(115200);
  
  for(uint8_t i=0; i<2; i++) {       // Initialize displays
    disp[i].seg7.begin(disp[i].addr);
    disp[i].seg7.clear();
    disp[i].seg7.writeDisplay();
  }

  if (!SPIFFS.begin()) {
    Serial.println("Failed to mount FS");
    return;
  }

  pinMode(LED_BUILTIN, OUTPUT);     // Initialize the LED_BUILTIN pin as an output
  digitalWrite(LED_BUILTIN, LOW);   // Turn the LED on (Note that LOW is the voltage level
  loadConfig();

  WiFiManager wifiManager;
  wifiManager.setSaveConfigCallback(saveConfigCallback);

  // Adding an additional config on the WIFI manager webpage for the API Key and Channel ID
  WiFiManagerParameter customApiKey("apiKey", "API Key", apiKey, 50);
  WiFiManagerParameter customChannelId("channelId", "Channel ID", channelId, 35);
  wifiManager.addParameter(&customApiKey);
  wifiManager.addParameter(&customChannelId);

  // If it fails to connect it will create a YouTube-Counter access point
  wifiManager.autoConnect("YouTube-Counter", "supersecret");

  strcpy(apiKey, customApiKey.getValue());
  strcpy(channelId, customChannelId.getValue());

  if (shouldSaveConfig) {
    saveConfig();
  }

  digitalWrite(LED_BUILTIN, HIGH);  // Turn the LED off by making the voltage HIGH
  // Force Config mode if there is no API key
  if(strcmp(apiKey, "") > 0) {
    Serial.println("Init YouTube API");
    api = new YoutubeApi(apiKey, client);
  } else {
    Serial.println("Forcing Config Mode");
    forceConfigMode();
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  IPAddress ip = WiFi.localIP();
  Serial.println(ip);

}

bool loadConfig() {
  File configFile = SPIFFS.open("/config.json", "r");
  if (!configFile) {
    Serial.println("Failed to open config file");
    return false;
  }

  size_t size = configFile.size();
  if (size > 1024) {
    Serial.println("Config file size is too large");
    return false;
  }

  // Allocate a buffer to store contents of the file.
  std::unique_ptr<char[]> buf(new char[size]);

  configFile.readBytes(buf.get(), size);

  StaticJsonBuffer<200> jsonBuffer;
  JsonObject& json = jsonBuffer.parseObject(buf.get());

  if (!json.success()) {
    Serial.println("Failed to parse config file");
    return false;
  }

  strcpy(apiKey, json["apiKey"]);
  strcpy(channelId, json["channelId"]);
  return true;
}

bool saveConfig() {
  StaticJsonBuffer<200> jsonBuffer;
  JsonObject& json = jsonBuffer.createObject();
  json["apiKey"] = apiKey;
  json["channelId"] = channelId;

  File configFile = SPIFFS.open("/config.json", "w");
  if (!configFile) {
    Serial.println("Failed to open config file for writing");
    return false;
  }

  json.printTo(configFile);
  return true;
}

void forceConfigMode() {
  Serial.println("Reset");
  WiFi.disconnect();
  Serial.println("Dq");
  delay(500);
  ESP.restart();
  delay(5000);
}

void loop() {

  if (digitalRead(resetConfigPin) == HIGH) {
    forceConfigMode();
  }
  if (millis() - api_lasttime > api_mtbs) {
    if(api->getChannelStatistics(channelId))
    {
      Serial.println("---------Stats---------");
      Serial.print("Subscriber Count: ");
      Serial.println(api->channelStats.subscriberCount);
      Serial.print("View Count: ");
      Serial.println(api->channelStats.viewCount);
      Serial.print("Comment Count: ");
      Serial.println(api->channelStats.commentCount);
      Serial.print("Video Count: ");
      Serial.println(api->channelStats.videoCount);
      // Probably not needed :)
      //Serial.print("hiddenSubscriberCount: ");
      //Serial.println(api->channelStats.hiddenSubscriberCount);
      Serial.println("------------------------");
      
      subscriberCount = api->channelStats.subscriberCount;
      
      uint16_t hi = subscriberCount / 10000, // Value on left (high digits) display
               lo = subscriberCount % 10000; // Value on right (low digits) display
      disp[0].seg7.print(hi, DEC);   // Write values to each display...
      disp[1].seg7.print(lo, DEC);

      // print() does not zero-pad the displays; this may produce a gap
      // between the high and low sections. Here we add zeros where needed...
      if(hi) {
        if(lo < 1000) {
          disp[1].seg7.writeDigitNum(0, 0);
          if(lo < 100) {
            disp[1].seg7.writeDigitNum(1, 0);
            if(lo < 10) {
              disp[1].seg7.writeDigitNum(3, 0);
            }
          }
        }
       } else {
         disp[0].seg7.clear(); // Clear 'hi' display
        }
       disp[0].seg7.writeDisplay(); // Push data to displays
       disp[1].seg7.writeDisplay();


    }
    api_lasttime = millis();
  }
}

J'ai modifié ma clef api et chanel id pour ne pas divulger mes infos perso..

**Seulement, comment est il possible d'adapter ce code pour que mon écran soit compatible à la place de l'adafruit... Je ne trouve pas de documentation qui pourrait m'éclairer.. (c'est une phrase de noob je sais, mais il faut bien débuter, et essayer de mener ses projets à bout, même en ne comprenant pas tout, cela vient au fur et à mesure..)

Ma deuxième question, ce code possède un wifimanager, j'amagine qu'une fois le code implanté, la carte vas créer un réseau wifi, avec une page web qui me permettra d'entrer la configuration wifi ?

Merci pour vos réponses..

Ma deuxième question, ce code possède un wifimanager, j'amagine qu'une fois le code implanté, la carte vas créer un réseau wifi, avec une page web qui me permettra d'entrer la configuration wifi ?

oui

Merci pour votre retour.

Concernant le code, avez vous une piste pour que je puisse adapter mon écran à la place de l'ADAFRUIT...

non pas de piste , je ne connais pas cet afficheur, sa notice, sa ou ses librairies

Je dirais que ce code exploite 2 afficheurs.

La seule librairie que j'ai trouvé avec une classe nommée Adafruit_7segment est celle-ci :

Ton code vient d'ici ?
http://forum.arduino.cc/index.php?topic=569755.0

C'est toi qui a remplacé ceci ?

#include "Adafruit_LEDBackpack.h"  
// par 
#include <TM1637Display.h>

Apparemment, l'afficheur correspondant à Adafruit_LEDBackpack 7 segments est celui-ci :

Effectivement incompatible avec ton TM1637 car le contrôleur ADAFRUIT est un HT16K33.

Si tu veux remplacer Adafruit_LEDBackpack par TM1637Display, changer de fichier .H ne suffit pas.
Il vaudrait mieux repartir de l'exemple de TM1637 de ton premier post, et remplacer toute la gestion de l'affichage Adafruit_7segment par des équivalents TM1637.

@+

Première question : as-tu deux afficheurs de 4 chiffres à ta disposition ?

Ci dessous les modifs à appliquer :

///////////////////////////////////////////

// Les deux afficheurs ADAFRUIT sont I2C.
struct {
  uint8_t           addr;         // I2C address
  Adafruit_7segment seg7;         // 7segment object
} disp[] = {
  { 0x71, Adafruit_7segment() },  // High digits
  { 0x70, Adafruit_7segment() }   // Low digits
};

// à remplacer par :

Les deux TM1637 sont branchés en CLK=2 et DIO=3, CLK=4 et DIO=5
TM1637Display disp[] = {
  TM1637Display(2, 3),  // High digits
  TM1637Display(4, 5)  // Low digits
};

///////////////////////////////////////////

Virer les lignes suivantes :

  for(uint8_t i=0; i<2; i++) {       // Initialize displays
    disp[i].seg7.begin(disp[i].addr);
    disp[i].seg7.clear();
    disp[i].seg7.writeDisplay();
  }

///////////////////////////////////////////

      disp[0].seg7.print(hi, DEC);   // Write values to each display...
      disp[1].seg7.print(lo, DEC);

// à remplacer par :

      disp[0].showNumberDec(hi);
      disp[1].showNumberDec(lo);

// Il y a d'autres appels à disp[x].seg7.print()
// Remplace de la même façon.

Par contre je ne peut pas tester ce code. Je n'ai pas ce genre d'afficheur.
Ça va aller ?
N'hésite pas à revenir.

@+

Ton afficheur a 8 digits. Je ne pense pas qu'il s'agisse d'un TM1637.

Le TM1637 n'en gère que 6. Il a 20 pattes.
Le MAX7219 en gère 8. Il a 24 pattes.

Sur la photo on voit un circuit à 24 pattes.
Où est l'erreur ?

Bonjour

sur cette ce site on voit effectivement un MAX7219 à 24 pins au dos d'un afficheur ressemblant.
Dans ce cas je comprend moins bien le conflit avec GPIO15, le DIN du MAX7219 n'atant pas le DIO (entrée/sortie) du TM1637.
Le mieux serait que bretzel nous donne la référence effective du (ou des circuits) au dos de son afficheur.

Bonjour,

Pour commencer, je tiens à vous remercier pour toutes vos réponses et je ne manquerai pas de tenir ce poste à jour au fur et à mesure de son avancement.

Une fois le code trouvé et opérationel, je le communiquerai pour que ce post puisse servir à d'autres personnes dans le même cas que moi.


Pour répondre à vos questions


--->Le code que j'ai récupéré viens de :

J'aime beaucoup le projet que la fille à fait parce que son compteur à l'air "simple", éfficace et estétique.

En bas de la page vous avez 2 codes différents en téléchargement. J'ai choisi celui avec un WifiManager integré pour me permettre une configuration simplifiée du SSID.

-> Elle utilise 2 afficheurs de cette marque (4digit / 7 segments / I2C) :

-> Que je souhaiterai remplacer par l'afficheur (8digit / 7 segments / I2C) :

Mon choix c'est porté sur cet afficheur car il est moins chère, et j'ai besoin de 8 chiffres puisque la chaine youtube que je souhaite relier possède un nombre d'abonnés qui necessites autant de chiffres...


J'ai essayé de créer un SSID avec le module ESP8266 (exemples) et tout fonctionne correctement.

Voici l'écran en fonction :

__

Merci à vous

Ton afficheur est un MAX7219.

Ce qui m'étonne, c'est que tu aies pu piloter un MAX7219 avec une librairie TM1637.

Utilises-tu la librairie LedControl ?

Voici l'écran en fonction :

côté afficheurs oui ....mais de l'autre côté ? (celui ou se trouve le circuit intégré pour pouvoir l'identifier indépendemnent des déclarations du vendeur)

Bonjour,

Ce que je ne comprend pas, c'est que dans la description Amazon, il est précisé que l'écran utilise la librairie TM1637...
Dans les commentaires égallement.

J'utilise la librairie TM1637-Master

Après vérification :

Au dos de l'écran, sur le circuit intégré, je lis bien MAXIM MAX7219CWG (1823)

Vous aviez donc bien raison...

Je reviens vers vous.

J'ai réussi à trouver un code pour un compteur youtube utilisant le MAX7219.

J'ai rentré ma clef API, Chanel ID ainsi que les PIN utilisés.

Quand j'allume l'ESP, je voit bien qu'il se connecte à mon téléphone en partage de connection. donc : WIFI OK

Seulement j'ai un message d'erreur, que je retrouve dans la ligne de code, mais je ne sais pas à quoi il correspond...

// YouTube Channel View Counter
// Kenneth Finnegan, 2017
//
// Given a WiFi SSID + password, and YouTube API key + channel ID, displays the
// current total views count on an attached MAX7219 eight digit display

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

//------- Replace the following! ------
char ssid[] = "iPhone de Florian";       // your network SSID (name)
char password[] = "lebretez";  // your network key
#define API_KEY "AIzaSyBYzKZ0QaKFs_PU0wDruzOA"  // your google apps API Token
#define CHANNEL_ID "UCEF5o10EG3V7C_asEscew" // makes up the url of channel

// This depends on which pins you've wired the MAX7219 driver to.
#define DISP_CS D7
#define DISP_CLK  D6
#define DISP_DATA D5


WiFiClientSecure client;
YoutubeApi api(API_KEY, client);

// The total channel view count is updated very rarely (daily?) so we don't need to check regularly
unsigned long api_mtbs = 5 * 60 * 1000; // Desired update interval in milliseconds
unsigned long api_lasttime = 0-api_mtbs;   //last time api request has been done
  // Note that we're pre-loading the "last update" variable to an interval before zero so the
  // display updates immediately on boot

////////////////////////////
// DISPLAY DRIVER SECTION //
////////////////////////////

// Soft implementation of SPI because I don't even know if the ESP-12 has SPI hardware available
// [TODO: insert rant about how much Arduino platform documentation sucks these days]
// This only sends eight bits, which is half a MAX7219 command
void disp_send(uint8_t data) {
  int i;
  for (i=0; i<8; i++) {
    // Send the most significant bit first
    digitalWrite(DISP_DATA, !!(data & (1<<(7-i))));
    delay(1); // These delays might not be needed, but I like the visual effect of the slow update
    // Then toggle the clock line
    digitalWrite(DISP_CLK, HIGH);
    delay(1);
    digitalWrite(DISP_CLK, LOW);
    delay(1);
  }
}

// Sends two bytes, the register select and the payload for that data
// See the datasheet for the full memory map:
// https://datasheets.maximintegrated.com/en/ds/MAX7219-MAX7221.pdf
void disp_cmd(uint8_t reg, uint8_t data) {
  digitalWrite(DISP_CS, LOW);
  disp_send(reg);
  disp_send(data);
  digitalWrite(DISP_CS, HIGH);
}

// Given an integer, write it to the display
void disp_number(int data) {
  int i;
  for (i=1; i<=8; i++) {
    int output = data % 10;
    // Turn on the decimal place at 4 and 7 to make it easier to read
    if (i == 4 || i == 7) output |= 0x80;
    // Blank leading zeros if we've run out of data and we're not the first digit
    if (data == 0 && i != 1) output = 0x0F;
    disp_cmd(i,output);
    data = data / 10;
  }
}

// When we aren't working, display "00000000" then "--HELP--"
void disp_error() {
  int i;
  for (i=8; i>0; i--) {
    disp_cmd(i,0x00);
  }
    
  disp_cmd(0x08,0x0A); // -
  disp_cmd(0x07,0x0A); // -
  disp_cmd(0x06,0x0C); // H
  disp_cmd(0x05,0x0B); // E
  disp_cmd(0x04,0x0D); // L
  disp_cmd(0x03,0x0E); // P
  disp_cmd(0x02,0x0A); // -
  disp_cmd(0x01,0x0A); // -
}


////////////////////////////////
// MAIN SETUP AND MASTER LOOP //
////////////////////////////////

void setup() {

  Serial.begin(115200);

  // Set up the MAX7219 display and load the command registers
  pinMode(DISP_CS, OUTPUT);
  pinMode(DISP_CLK, OUTPUT);
  pinMode(DISP_DATA, OUTPUT);
  disp_cmd(0x0C,0x01); // Leave shutdown
  delay(30);
  disp_cmd(0x0F,0x00); // Leave display test
  delay(30);
  disp_cmd(0x09,0xFF); // Use B code on all eight digits
  delay(30);
  disp_cmd(0x0A,0x02); // Set software intensity 0-15
  delay(30);
  disp_cmd(0x0B,0x07); // Scan all eight digits (blank individual digits with 0xF)
  delay(30);
  disp_error();

  // 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);


  
}

void loop() {

  if (millis() - api_lasttime > api_mtbs)  {
    Serial.println("Trying to query API");
    if(api.getChannelStatistics(CHANNEL_ID)) {
      Serial.println("---------Stats---------");
      Serial.print("Subscriber Count: ");
      Serial.println(api.channelStats.subscriberCount);
      Serial.print("View Count: ");
      Serial.println(api.channelStats.viewCount);
      Serial.print("Comment Count: ");
      Serial.println(api.channelStats.commentCount);
      Serial.print("Video Count: ");
      Serial.println(api.channelStats.videoCount);
      Serial.println("------------------------");

      disp_number(api.channelStats.viewCount);

      api_lasttime = millis();
    } else {
      // Something went wrong, so try again in 30s
      Serial.println("YOUTUBE API ERROR!");
      disp_error();
      api_lasttime += 30 * 1000;
    }
  }
}

Voici ce que l'afficheur donne :

Je ne trouve pas le soucis dans le code...

Tu dois aussi avoir "YOUTUBE API ERROR!" qui s'affiche dans le terminal.

As-tu aussi "Trying to query API" qui s'affiche avant ?

Si api.getChannelStatistics(CHANNEL_ID) retourne une erreur l'afficheur affiche "--HELP--".

Règle le moniteur série sur 115200 baud.

@+

Bonjour,

Toutes mes excuses pour cette réponse tardive.

Sur l'écran il m'affiche : // When we aren't working, display "00000000" then "--HELP--"

J'imagine que c'est un problème de configuration vis à vis de l'écran...


J'ai réglé le moniteur série du 115200 baud, cela n'as pas eu résultat si ce n'est le même message d'erreur...

Quand je vais dans OUTILS -> MONITEUR SERIE, j'ai en effet le message "Trying to queri API"


J'ai trouvé un lien qui me permet de test ma clef API et Chanel ID :

https://www.googleapis.com/youtube/v3/channels?part=statistics&id=YOUR_CHANNEL_ID&key=YOUR_API_KEY

En remplacant "Channel ID et API KEY", j'atteris sur une page qui m'indique les statistiques de ma chaine, nombres video, vues, abonnés etc etc..

J'en conclus donc que ce n'est pas un problème vis à vis de mes identifiants

{
 "kind": "youtube#channelListResponse",
 "etag": "\"XpPGQXs6enD_n8JR4Qk/KQ8FPu0Yf0waSgng-YpbhM\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 1
 },
 "items": [
  {
   "kind": "youtube#channel",
   "etag": "\"XpPGQXgs6enD_n8JR4Qk/7nYRcJU-93riJJoiScDiHrY\"",
   "id": "UCEF5V7C_asEMZscew",
   "statistics": {
    "viewCount": "2404",
    "commentCount": "0",
    "subscriberCount": "13",
    "hiddenSubscriberCount": false,
    "videoCount": "10"
   }
  }
 ]
}