Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
arduino ESP8266和wemos d1 mini出现错误_Arduino - Fatal编程技术网

arduino ESP8266和wemos d1 mini出现错误

arduino ESP8266和wemos d1 mini出现错误,arduino,Arduino,在wemos d1迷你板上编译youtube订户计数器的代码时,我遇到了一个错误,不确定如何修复它,希望有人能给我指出正确的方向。我已经将ArduinoJson版本更改为5.13.4,希望这样做可以奏效,但错误仍然存在 错误: C:\Users\georg\OneDrive\Documents\Arduino\libraries\YoutubeApi\src\YoutubeApi.cpp: In member function 'bool YoutubeApi::getChannelStati

在wemos d1迷你板上编译youtube订户计数器的代码时,我遇到了一个错误,不确定如何修复它,希望有人能给我指出正确的方向。我已经将ArduinoJson版本更改为5.13.4,希望这样做可以奏效,但错误仍然存在

错误:

C:\Users\georg\OneDrive\Documents\Arduino\libraries\YoutubeApi\src\YoutubeApi.cpp: In member function 
'bool YoutubeApi::getChannelStatistics(char*)':
C:\Users\georg\OneDrive\Documents\Arduino\libraries\YoutubeApi\src\YoutubeApi.cpp:106:9: error: 
'DynamicJsonDocument' was not declared in this scope
     DynamicJsonDocument doc(bufferSize);
     ^
C:\Users\georg\OneDrive\Documents\Arduino\libraries\YoutubeApi\src\YoutubeApi.cpp:106:29: error: 
expected ';' before 'doc'
     DynamicJsonDocument doc(bufferSize);
                         ^
C:\Users\georg\OneDrive\Documents\Arduino\libraries\YoutubeApi\src\YoutubeApi.cpp:109:9: error: 
'DeserializationError' was not declared in this scope
     DeserializationError error = deserializeJson(doc, *client);
     ^
C:\Users\georg\OneDrive\Documents\Arduino\libraries\YoutubeApi\src\YoutubeApi.cpp:109:30: error: 
expected ';' before 'error'
     DeserializationError error = deserializeJson(doc, *client);
                          ^
C:\Users\georg\OneDrive\Documents\Arduino\libraries\YoutubeApi\src\YoutubeApi.cpp:110:14: error: 
'error' was not declared in this scope
     if (!error)
          ^
C:\Users\georg\OneDrive\Documents\Arduino\libraries\YoutubeApi\src\YoutubeApi.cpp:114:41: error: 
'doc' was not declared in this scope
         JsonObject itemStatistics = doc["items"][0]["statistics"];
                                     ^
exit status 1
Error compiling for board LOLIN(WEMOS) D1 R2 & mini.
以下是主要代码:

/* 
Erics Wemos D1 Mini displaying YouTube Subscriber Count with MAX7219 LED Matrix Displays

Original Library here https://github.com/squix78/MAX7219LedMatrix but contains no function to rotate 
for my displays
Brian Lough's library contains rotate: https://github.com/witnessmenow/MAX7219LedMatrix
Brians doesnt work with Wemos D1 mini unless you comment out this line 
https://github.com/witnessmenow/MAX7219LedMatrix/blob/master/LedMatrix.cpp#L34
Done in the cpp file contained with this sketch
Eric originally followed this tutorial here for the YouTube API info etc: 
http://www.joeybabcock.me/blog/projects/arduino-esp8266-live-subscriber-display/
Wiring for Wemos D1 Mini:
| Pin On 7219| Pin on Wemos D1 Mini |
| ------- |----------------|
| GND     | G |
| VCC     | 3V3 |
| DIN     | D7 |
| CS      | D4 |
| CLK     | D5 |

Support my projects by picking up the display/board here:
Wemos D1: https://amzn.to/2ACRWRA
LED Matrix: https://amzn.to/2McsuUl

My Youtube Channel  : http://www.youtube.com/mkmeorg
My website   : http://www.mkme.org

*/
#include <SPI.h>
#include "LedMatrix.h"
#define NUMBER_OF_DEVICES 4
#define CS_PIN 2
LedMatrix ledMatrix = LedMatrix(NUMBER_OF_DEVICES, CS_PIN);
int x = 0;
#include <YoutubeApi.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <ArduinoJson.h> // This Sketch doesn't technically need this, but the library does so it 
must be installed.

//------- Replace the following! ------
char ssid[] = "----";       // your network SSID (name)
char password[] = "----";  // your network key
#define API_KEY "----"  // your google apps API Token
#define CHANNEL_ID "----" // Channel URL text - get from YT advanced Dashboard

WiFiClientSecure client;
YoutubeApi api(API_KEY, client);

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

void setup() {
  ledMatrix.init();
ledMatrix.setRotation(true);  //This is Brians MAGICAL rotation function for these displays!
ledMatrix.setText("Loading...");
  Serial.begin(115200);
  // Set WiFi to station mode and disconnect from an AP if it was Previously
  // connected
   WiFi.hostname("ESP8266SubscriberCounter"); //This changes the hostname of the ESP8266 to display 
neatly on the network router.
  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() {
  ledMatrix.clear();
  ledMatrix.scrollTextLeft();
  ledMatrix.drawText();
  ledMatrix.commit();
  delay(100);

if (millis() - api_lasttime > api_mtbs)  {
    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);
      // Probably not needed :)
      //Serial.print("hiddenSubscriberCount: ");
      //Serial.println(api.channelStats.hiddenSubscriberCount);
      Serial.println("------------------------");
      SaveStats();
    }
    api_lasttime = millis();
  }
}

void SaveStats() {
  ledMatrix.setText(String(api.channelStats.subscriberCount));
  }
/*
Erics Wemos D1 Mini通过MAX7219 LED矩阵显示器显示YouTube用户数量
这里是原始图书馆https://github.com/squix78/MAX7219LedMatrix 但不包含旋转功能
我的显示器
Brian Lough的库包含以下内容:https://github.com/witnessmenow/MAX7219LedMatrix
Brians不会与Wemos D1 mini合作,除非您注释掉这一行
https://github.com/witnessmenow/MAX7219LedMatrix/blob/master/LedMatrix.cpp#L34
在包含此草图的cpp文件中完成
Eric最初在这里学习本教程,了解YouTube API信息等:
http://www.joeybabcock.me/blog/projects/arduino-esp8266-live-subscriber-display/
Wemos D1迷你型的布线:
|7219上的销| Wemos D1迷你型上的销|
| ------- |----------------|
|GND|G|
|VCC | 3V3|
|DIN | D7|
|CS | D4|
|CLK | D5|
通过选择此处的显示/板来支持我的项目:
Wemos D1:https://amzn.to/2ACRWRA
LED矩阵:https://amzn.to/2McsuUl
我的Youtube频道:http://www.youtube.com/mkmeorg
我的网站:http://www.mkme.org
*/
#包括
#包括“LedMatrix.h”
#定义\u设备的数量\u 4
#定义CS_引脚2
LEDMARRIX LEDMARRIX=LEDMARRIX(设备数量,CS引脚);
int x=0;
#包括
#包括
#包括
#include//此草图在技术上不需要此功能,但库会这样做
必须安装。
//-------更换以下部件------
字符ssid[]=“---”;//您的网络SSID(名称)
字符密码[]=“---”;//您的网络密钥
#定义API_KEY“----”//您的谷歌应用程序API令牌
#定义频道\u ID“-”//CHANNEL URL文本-从YT高级仪表板获取
WiFiClientSecure客户端;
YoutubeApi(api_密钥,客户端);
无符号长api_mtbs=60000//api请求之间的平均时间
上次未签名的长api_//上次完成api请求的时间
长subs=0;
无效设置(){
ledMatrix.init();
setRotation(true);//这是Brians为这些显示器提供的神奇旋转功能!
ledMatrix.setText(“加载…”);
序列号开始(115200);
//将WiFi设置为站点模式,并断开与AP的连接(如果以前使用过)
//连接的
WiFi.hostname(“ESP8266SubscriberCounter”);//这会将ESP8266的主机名更改为显示
在网络路由器上。
WiFi.模式(WiFi_STA);
WiFi.disconnect();
延迟(100);
//尝试连接到Wifi网络:
串行打印(“连接Wifi:”);
序列号println(ssid);
WiFi.begin(ssid,密码);
while(WiFi.status()!=WL_已连接){
连续打印(“.”);
延迟(500);
}
Serial.println(“”);
Serial.println(“WiFi连接”);
Serial.println(“IP地址:”);
ip地址ip=WiFi.localIP();
序列号println(ip);
}
void循环(){
ledMatrix.clear();
ledMatrix.scrollTextLeft();
ledMatrix.drawText();
ledMatrix.commit();
延迟(100);
if(millis()-api_lasttime>api_mtbs){
if(api.getChannelStatistics(CHANNEL_ID))
{
Serial.println(“-----------Stats----------------”);
串行打印(“用户计数:”);
Serial.println(api.channelStats.subscriberCount);
Serial.print(“查看计数:”);
Serial.println(api.channelStats.viewCount);
Serial.print(“注释计数:”);
Serial.println(api.channelStats.commentCount);
串行打印(“视频计数:”);
Serial.println(api.channelStats.videoCount);
//可能不需要:)
//Serial.print(“hiddenSubscriberCount:”);
//Serial.println(api.channelStats.hiddensubercount);
Serial.println(“---------------------------”);
SaveStats();
}
api_lasttime=millis();
}
}
void SaveStats(){
setText(字符串(api.channelStats.subscriberCount));
}