Esp32 C3 mini with mpu 6050

Hi i want to connect esp32 C3 mini with mpu6050 . Could you tell me how i could connect the mpu6050 pins (sda , scl , ad0, int) to esp32C3 mini dev kit .
I will attach the image of the esp32 C3 mini and mpu6050 .
Could you help me in writing down the pin mapping for mp6050 with esp32C3

Secondly i want to make a virtual mouse . I will attach the code . Could you tell me if it works as a mouse with scrolling on the monitor as well as clicking ?

#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);
    }
  
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.