如何处理Arduino中M5Stack库的编译错误?

我目前正在尝试给我的M5Stack编程,里面有一个ESP32芯片,我下载了(或至少我认为)所有需要上传到板子上的依赖项,但我甚至无法编译我的程序。我下載了(至少我以為是)所有需要上傳到板子上的依賴,但我甚至無法編譯我的程式。我通过板卡管理器下载了ESP32,我按照M5Stack网站上的教程去做,但似乎在他们的库中发现了错误。我不知道该如何解决,下面是我的代码,下面是我收到的错误信息。

#include <M5Stack.h>
#include <Wire.h>
#define SPEAKER_PIN 25
#include "config.h"

AdafruitIO_Feed *voltage1 = io.feed("V1");
AdafruitIO_Feed *voltage2 = io.feed("V2");
AdafruitIO_Feed *curr = io.feed("Current");

void setup() {
  // put your setup code here, to run once:
  M5.begin(true, true, true, false);
  Serial.begin(115200);
  dacWrite(25,0);
  M5.Lcd.fillScreen(BLACK);
  M5.Lcd.setTextSize(5);

  // wait for serial monitor to open
  while(! Serial);

  Serial.print("Connecting to Adafruit IO");

  // connect to io.adafruit.com
  io.connect();

  // wait for a connection
  while(io.status() < AIO_CONNECTED) {
    Serial.print(".");
    delay(500);
  }

  // we are connected
  Serial.println();
  Serial.println(io.statusText());


//  ads.getAddr_ADS1100(ADS1100_DEFAULT_ADDRESS);
//  ads.setGain(GAIN_ONE);
//  ads.setMode(MODE_CONTIN);
//  ads.setRate(RATE_32);
//  ads.setOSMode(OSMODE_SINGLE);
//  ads.begin();
}

void loop() {

  io.run();

  // put your main code here, to run repeatedly:
  float v1 = (float)analogRead(36) / 4096 * 17.4  * 0.975;
  float v2 = (float)analogRead(35) / 4096 * 17.4 * 0.975;
  float current = (float)analogRead(5);


  Serial.print("v1: ");
  Serial.print(v1);
  Serial.println("V");
  Serial.print("v2: ");
  Serial.print(v2);
  Serial.println("V");

  M5.Lcd.setTextColor(WHITE);
  M5.Lcd.setCursor(10, 10);
  M5.Lcd.print("V1: ");
  M5.Lcd.print(v1);
  M5.Lcd.print("V");

  M5.Lcd.setTextColor(WHITE);
  M5.Lcd.setCursor(10, 70);
  M5.Lcd.print("V2: ");
  M5.Lcd.print(v2);
  M5.Lcd.print("V");

  M5.Lcd.setTextColor(WHITE);
  M5.Lcd.setCursor(10, 140);
  M5.Lcd.print("Current: ");
  M5.Lcd.print(current);
  M5.Lcd.print("A");
  delay(500);

  M5.Lcd.setCursor(10, 10);
  M5.Lcd.setTextColor(BLACK);
  M5.Lcd.print("V1: ");
  M5.Lcd.print(v1);
  M5.Lcd.print("V");

  M5.Lcd.setCursor(10, 70);
  M5.Lcd.setTextColor(BLACK);
  M5.Lcd.print("V2: ");
  M5.Lcd.print(v2);
  M5.Lcd.print("V");

  M5.Lcd.setTextColor(BLACK);
  M5.Lcd.setCursor(10, 140);
  M5.Lcd.print("Current: ");
  M5.Lcd.print(current);
  M5.Lcd.print("A");


  Serial.print("sending v1-> ");
  Serial.println(v1);
  voltage1->save(v1);

  Serial.print("sending v2-> "); 
  Serial.println(v2);
  voltage2->save(v2);

  Serial.print("sending Current-> ");
  Serial.println(current);
  curr->save(current);

}

错误输出。

Arduino: 1.8.12 (Windows 10), Board: "M5Stack-Core-ESP32, QIO, 80MHz, Default, 921600, None"

C:\Users\graff\OneDrive\Documents\Arduino\libraries\M5Stack\src\M5Display.cpp: In member function 'void M5Display::drawPngUrl(const char*, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, double, uint8_t)':

C:\Users\graff\OneDrive\Documents\Arduino\libraries\M5Stack\src\M5Display.cpp:543:3: error: 'HTTPClient' was not declared in this scope
   HTTPClient http;
   ^

C:\Users\graff\OneDrive\Documents\Arduino\libraries\M5Stack\src\M5Display.cpp:545:7: error: 'WiFi' was not declared in this scope
   if (WiFi.status() != WL_CONNECTED) {
       ^

C:\Users\graff\OneDrive\Documents\Arduino\libraries\M5Stack\src\M5Display.cpp:545:24: error: 'WL_CONNECTED' was not declared in this scope
   if (WiFi.status() != WL_CONNECTED) {
                        ^

C:\Users\graff\OneDrive\Documents\Arduino\libraries\M5Stack\src\M5Display.cpp:550:3: error: 'http' was not declared in this scope
   http.begin(url);
   ^

C:\Users\graff\OneDrive\Documents\Arduino\libraries\M5Stack\src\M5Display.cpp:553:19: error: 'HTTP_CODE_OK' was not declared in this scope
   if (httpCode != HTTP_CODE_OK) {
                   ^

C:\Users\graff\OneDrive\Documents\Arduino\libraries\M5Stack\src\M5Display.cpp:559:3: error: 'WiFiClient' was not declared in this scope
   WiFiClient *stream = http.getStreamPtr();
   ^

C:\Users\graff\OneDrive\Documents\Arduino\libraries\M5Stack\src\M5Display.cpp:559:15: error: 'stream' was not declared in this scope
   WiFiClient *stream = http.getStreamPtr();
               ^

Multiple libraries were found for "WiFi.h"
 Used: C:\Users\graff\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi
 Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
 Not used: C:\Users\graff\OneDrive\Documents\Arduino\libraries\WiFi
Multiple libraries were found for "SD.h"
 Used: C:\Users\graff\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\SD
 Not used: C:\Program Files (x86)\Arduino\libraries\SD
 Not used: C:\Users\graff\OneDrive\Documents\Arduino\libraries\SD
exit status 1
Error compiling for board M5Stack-Core-ESP32.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

解决方案:

首先你应该按照编译器的要求去做。

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

这给出了更多的细节,如果解决不了问题 编辑你的问题,用详细的信息替换编译器的输出,在你的程序中手动加入缺失的libs。

#include <WiFi.h>
#include <SD.h>
#include <M5Stack.h>
#include <Wire.h>

并检查你在

#include "config.h"

因为缺少文件,我无法编译。

给TA打赏
共{{data.count}}人
人已打赏
解决方案

Bootstrap 4中的垂直中心项目

2022-5-12 6:00:20

解决方案

在R中使用rbindlists来处理嵌套列表

2022-5-12 6:00:22

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索