ESP8266使用记录(二)

在这里插入图片描述
前文选择开发板类型错误,这里更正如上图

I2C方式获取mpu6050数据

#include <Wire.h>
const int MPU6050_addr = 0x68;
int16_t AccX, AccY, AccZ, Temp, GyroX, GyroY, GyroZ;
void setup() {
  Wire.begin();
  Wire.beginTransmission(MPU6050_addr);
  Wire.write(0x6B);
  Wire.write(0);
  Wire.endTransmission(true);
  Serial.begin(9600);
}

void loop() {
  Wire.beginTransmission(MPU6050_addr);
  Wire.write(0x3B);
  Wire.endTransmission(false);
  Wire.requestFrom(MPU6050_addr, 14, true);
  AccX = Wire.read() << 8 | Wire.read();
  AccY = Wire.read() << 8 | Wire.read();
  AccZ = Wire.read() << 8 | Wire.read();
  Temp = Wire.read() << 8 | Wire.read();
  GyroX = Wire.read() << 8 | Wire.read();
  GyroY = Wire.read() << 8 | Wire.read();
  GyroZ = Wire.read() << 8 | Wire.read();
  Serial.print("AccX = ");
  Serial.print(AccX);
  Serial.print(" || AccY = ");
  Serial.print(AccY);
  Serial.print(" || AccZ = ");
  Serial.print(AccZ);
  Serial.print(" || Temp = ");
  Serial.print(Temp / 340.00 + 36.53);
  Serial.print(" || GyroX = ");
  Serial.print(GyroX);
  Serial.print(" || GyroY = ");
  Serial.print(GyroY);
  Serial.print(" || GyroZ = ");
  Serial.println(GyroZ);
  delay(100);
}

在这里插入图片描述
mpu6050 esp8266
VCC 3V3
GND GND
SCL D1
SDA D2

相关链接地址
https://www.bilibili.com/read/cv4403414/
https://github.com/maksii/Accelerometer_MPU6050/blob/master/MPU6050/MPU6050.cs
http://eeskill.com/group/topic/id/1375

工程地址
https://github.com/xue-fei/Unity.MPU6050

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

地狱为王

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值