纸染 2023-03-26 22:26 采纳率: 75%
浏览 25
已结题

关于在arduino中编译现成程序失败

求帮忙,在arduino中编译一个现成的程序,在库文件安装完成的情况下,编译报错,以下为报错信息

In file included from C:\Users\李祖祎\OneDrive\桌面\ESPCar_fashe\ESPCar_fashe.ino:13:0:
c:\Users\����t\OneDrive\�ĵ�\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:64:24: error: conflicting declaration 'typedef int8_t prog_int8_t'
         typedef int8_t prog_int8_t;
                        ^
In file included from C:\Users\����t\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32/WString.h:29:0,
                 from C:\Users\����t\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32/Arduino.h:146,
                 from C:\Users\����t\AppData\Local\Temp\arduino\sketches\B5716108DB741043B1770932FCA1086B\sketch\ESPCar_fashe.ino.cpp:1:
C:\Users\����t\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32/pgmspace.h:25:14: note: previous declaration as 'typedef char prog_int8_t'
 typedef char prog_int8_t;
              ^
In file included from C:\Users\李祖祎\OneDrive\桌面\ESPCar_fashe\ESPCar_fashe.ino:13:0:
c:\Users\����t\OneDrive\�ĵ�\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:68:25: error: conflicting declaration 'typedef int32_t prog_int32_t'
         typedef int32_t prog_int32_t;
                         ^
In file included from C:\Users\����t\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32/WString.h:29:0,
                 from C:\Users\����t\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32/Arduino.h:146,
                 from C:\Users\����t\AppData\Local\Temp\arduino\sketches\B5716108DB741043B1770932FCA1086B\sketch\ESPCar_fashe.ino.cpp:1:
C:\Users\����t\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32/pgmspace.h:29:14: note: previous declaration as 'typedef long int prog_int32_t'
 typedef long prog_int32_t;
              ^
In file included from C:\Users\李祖祎\OneDrive\桌面\ESPCar_fashe\ESPCar_fashe.ino:13:0:
c:\Users\����t\OneDrive\�ĵ�\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:69:26: error: conflicting declaration 'typedef uint32_t prog_uint32_t'
         typedef uint32_t prog_uint32_t;
                          ^
In file included from C:\Users\����t\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32/WString.h:29:0,
                 from C:\Users\����t\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32/Arduino.h:146,
                 from C:\Users\����t\AppData\Local\Temp\arduino\sketches\B5716108DB741043B1770932FCA1086B\sketch\ESPCar_fashe.ino.cpp:1:
C:\Users\����t\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32/pgmspace.h:30:23: note: previous declaration as 'typedef long unsigned int prog_uint32_t'
 typedef unsigned long prog_uint32_t;
                       ^
 
exit status 1
 
Compilation error: exit status 1
 

以下为源代码


```c
 
```c
 
//B站找 :arduino捣鼓室 欢迎大家评论区一起交流!如有不足请大家指正 共同进步!网址:https://space.bilibili.com/307396549
//根据需要下载要的库 可以根据编译查看结果
//所有的库打包在这个连接下方 https://www.bilibili.com/video/BV1r34y147SL?spm_id_from=333.999.0.0
 
 
 
#include <esp_now.h>
#include <WiFi.h>
 
//需要的安装库
#include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
 
#include "Wire.h"
#endif
 
// MPU control/status vars
MPU6050 mpu;
bool dmpReady = false;   //
uint8_t devStatus;       //
uint8_t fifoBuffer[64];  //
Quaternion q;            // [w, x, y, z]
VectorFloat gravity;     // [x, y, z]
float ypr[3];            // [yaw, pitch, roll]
 
// 记录MAC地址 // E0:5A:1B:75:36:6C
 
uint8_t receiverMacAddress[] = { 0xE0, 0x5A, 0x1B, 0x75, 0x36, 0x6C };
 
struct PacketData {
  byte xAxisValue;
  byte yAxisValue;
  byte zAxisValue;
};
PacketData data;
 
// callback when data is sent
void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
  //Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Message sent" : "Message failed");
}
 
void setupMPU() {
// join I2C bus (I2Cdev library doesn't do this automatically)
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
  Wire.begin();
  Wire.setClock(400000);  // 400kHz I2C clock. Comment this line if having compilation difficulties
#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
  Fastwire::setup(400, true);
#endif
 
  mpu.initialize();
  devStatus = mpu.dmpInitialize();
  // make sure it worked (returns 0 if so)
  if (devStatus == 0) {
    // Calibration Time: generate offsets and calibrate our MPU6050
    mpu.CalibrateAccel(6);
    mpu.CalibrateGyro(6);
    mpu.setDMPEnabled(true);
    dmpReady = true;
  }
}
 
void setup() {
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  // Init ESP-NOW
  if (esp_now_init() != ESP_OK) {
    Serial.println("Error initializing ESP-NOW");
    return;
  } else {
    Serial.println("Succes: Initialized ESP-NOW");
  }
 
  esp_now_register_send_cb(OnDataSent);
 
  // Register peer
  esp_now_peer_info_t peerInfo;
  memcpy(peerInfo.peer_addr, receiverMacAddress, 6);
  peerInfo.channel = 0;
  peerInfo.encrypt = false;
 
  // Add peer
  if (esp_now_add_peer(&peerInfo) != ESP_OK) {
    Serial.println("Failed to add peer");
    return;
  } else {
    Serial.println("Succes: Added peer");
  }
 
  //This is to set up MPU6050 sensor
  setupMPU();
}
 
void loop() {
  // if programming failed, don't try to do anything
  if (!dmpReady) return;
  // read a packet from FIFO. Get the Latest packet
  if (mpu.dmpGetCurrentFIFOPacket(fifoBuffer)) {
    mpu.dmpGetQuaternion(&q, fifoBuffer);
    mpu.dmpGetGravity(&gravity, &q);
    mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
 
    int xAxisValue = constrain(ypr[2] * 180 / M_PI, -90, 90);
    int yAxisValue = constrain(ypr[1] * 180 / M_PI, -90, 90);
    int zAxisValue = constrain(ypr[0] * 180 / M_PI, -90, 90);
    data.xAxisValue = map(xAxisValue, -90, 90, 0, 254);
    data.yAxisValue = map(yAxisValue, -90, 90, 0, 254);
    data.zAxisValue = map(zAxisValue, -90, 90, 0, 254);
 
    esp_err_t result = esp_now_send(receiverMacAddress, (uint8_t *)&data, sizeof(data));
 
    String inputData = inputData + "values " + xAxisValue + "  " + yAxisValue + "  " + zAxisValue;
    Serial.println(inputData);
    delay(50);
  }
}
 
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/470373757976136.png "#left")
 
 

```

  • 写回答

2条回答 默认 最新

  • IT_service_mesh 2023-03-26 22:32
    关注

    参考GPT和自己的思路:根据错误信息,看起来是库文件之间存在冲突,可能由于库文件版本不匹配或缺少必要的库文件导致。建议检查以下几个方面:

    1. 确认库文件是否完全安装,包括所需的所有依赖项。
    2. 确认库文件版本是否与代码兼容。
    3. 尝试删除库文件并重新安装。
    4. 如果问题仍然存在,请尝试其他类似的库文件。

    另外,建议遵循 Arduino 官方文档建议的方式安装和使用库文件,以避免潜在的问题和错误。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 4月5日
  • 已采纳回答 3月28日
  • 创建了问题 3月26日

悬赏问题

  • ¥15 在若依框架下实现人脸识别
  • ¥15 网络科学导论,网络控制
  • ¥100 安卓tv程序连接SQLSERVER2008问题
  • ¥15 利用Sentinel-2和Landsat8做一个水库的长时序NDVI的对比,为什么Snetinel-2计算的结果最小值特别小,而Lansat8就很平均
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同