Hi , My name is Alen .
I want to know how i could connect mpu6050 to esp32 C3 mini dev kit . I will put the code too. It runs on arduino ide .
Below i am attaching the esp32c3 mini Dev Kit and mpu6050 links.
I want to connect sda , scl , AD0, and Int to esp32c3 Mini . Please help me by sharing a figure or mapping the mpu 6050 pins to esp32C3 Mini dev kit pins
esp32 C3 mini dev kit : https://docs.espressif.com/projects/esp ... itm-1.html
Mpu6050 : https://circuitsgeek.com/getting-starte ... d-mpu6050/
Code :
#include <MPU6050_light.h>
MPU6050 mpu(Wire);
unsigned long timer = 0;
#include <BleMouse.h>
BleMouse bleMouse;
#define btnL 2
#define btnR 1
#define btnM 3
#include <Wire.h>
#define SDA 7
#define SCL 8
#define AD0 11
#define INT 12
void setup() {
pinMode(btnR,INPUT);
pinMode(btnL,INPUT);
pinMode(btnM,INPUT);
pinMode(INT, INPUT); //int goes high when activity is detected(wakeup?)
pinMode(AD0, OUTPUT);
digitalWrite(AD0, LOW);//sets I2C adress
delay(50);
Serial.begin(115200);
Wire.begin(SDA,SCL);
Serial.println("Starting BLE work!");
bleMouse.begin();
byte status = mpu.begin();
Serial.print(F("MPU6050 status: "));
Serial.println(status);
while(status!=0){ } // stop everything if could not connect to MPU6050
Serial.println(F("Calculating offsets, do not move MPU6050"));
delay(2000);
// mpu.upsideDownMounting = true; // uncomment this line if the MPU6050 is mounted upside-down
mpu.calcOffsets(); // gyro and accelero
Serial.println("Done!\n");
}
void loop() {
if(bleMouse.isConnected()) {
clicking();
mpu.update();
int x = map(mpu.getAngleX(),-90,90,10,-10);
int y = map(mpu.getAngleY(),-90,90,-10,10);
int z = map(mpu.getAngleZ(),-90,90,-10,10);
bleMouse.move(x,y);
if((millis()-timer)>10){ // print data every 10ms
Serial.print("X : ");
Serial.print(mpu.getAngleX());
Serial.print(x);
Serial.print("\tY : ");
Serial.print(mpu.getAngleY());
Serial.print(y);
Serial.print("\tZ : ");
Serial.println(mpu.getAngleZ());
Serial.print(z);
timer = millis();
}
}
}
void clicking(){
bool Lclick = digitalRead(btnL);
bool Mclick = digitalRead(btnM);
bool Rclick = digitalRead(btnR);
if (Lclick == 0){
bleMouse.click(MOUSE_LEFT);
}
if (Rclick == 0){
bleMouse.click(MOUSE_RIGHT);
}
if (Mclick == 0){
bleMouse.click(MOUSE_MIDDLE);
}
}
esp32 C3 Mini with mpu6050
-
- Posts: 1
- Joined: Wed Apr 17, 2024 8:54 am
Return to “General Discussion”
Jump to
- English Forum
- Explore
- News
- General Discussion
- FAQ
- Documentation
- Documentation
- Sample Code
- Discussion Forum
- Hardware
- ESP-IDF
- ESP-BOX
- ESP-ADF
- ESP-MDF
- ESP-WHO
- ESP-SkaiNet
- ESP32 Arduino
- IDEs for ESP-IDF
- ESP-AT
- ESP IoT Solution
- ESP RainMaker
- Rust
- ESP8266
- Report Bugs
- Showcase
- Chinese Forum 中文社区
- 活动区
- 乐鑫活动专区
- 讨论区
- 全国大学生物联网设计竞赛乐鑫答疑专区
- ESP-IDF 中文讨论版
- 《ESP32-C3 物联网工程开发实战》书籍讨论版
- 中文文档讨论版
- ESP-AT 中文讨论版
- ESP-BOX 中文讨论版
- ESP IoT Solution 中文讨论版
- ESP-ADF 中文讨论版
- ESP Mesh 中文讨论版
- ESP Cloud 中文讨论版
- ESP-WHO 中文讨论版
- ESP-SkaiNet 中文讨论版
- ESP 生产支持讨论版
- 硬件问题讨论
- 项目展示
Who is online
Users browsing this forum: No registered users and 120 guests
- All times are UTC
- Top
- Delete cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. ESP8266EX and ESP32 are some of our products.