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

关于在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 14:32
    关注

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

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

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

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

报告相同问题?

问题事件

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

悬赏问题

  • ¥15 nginx使用nfs进行服务器的数据共享
  • ¥15 C#i编程中so-ir-192编码的字符集转码UTF8问题
  • ¥15 51嵌入式入门按键小项目
  • ¥30 海外项目,如何降低Google Map接口费用?
  • ¥15 fluentmeshing
  • ¥15 手机/平板的浏览器里如何实现类似荧光笔的效果
  • ¥15 盘古气象大模型调用(python)
  • ¥15 传人记程序做的plc 485从机程序该如何写
  • ¥15 已知手指抓握过程中掌指关节、手指各关节和指尖每一帧的坐标,用贝塞尔曲线可以拟合手指抓握的运动轨迹吗?
  • ¥50 libwebsockets 如何添加其他socket事件回调
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部