Ordinato entro le 14:00 nei giorni lavorativi = spedito in giornata 30 giorni per il recesso Garanzia di 1 anno
← Torna alla panoramica

La riproduzione carica il video da YouTube.

Schema di collegamento ed esempio di codice

Ecco come collegare il Accelerometro e giroscopio I2C - MPU-6050 a un Arduino UNO o ESP32, con uno sketch di esempio che puoi caricare subito.

Demo di accelerometro e giroscopio MPU-6050

Questo progetto legge i dati di accelerazione e velocità angolare dal sensore di motion tracking a 6 assi MPU-6050 tramite I2C. Collega il sensore all’Arduino Uno, carica il codice e apri il Serial Monitor a 115200 baud per visualizzare le letture di movimento in tempo reale mentre inclini e ruoti il modulo.

Schema di collegamento: Accelerometro e giroscopio I2C - MPU-6050 su un Arduino UNO
Schema di collegamento · Clicca per ingrandire
Tabella di collegamento: Accelerometro e giroscopio I2C - MPU-6050 su un Arduino UNO
Tabella di collegamento · Clicca per ingrandire
MPU_6050_Accelerometer_and_Gyroscope_Dem.ino · compilato e testato
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : MPU-6050 Accelerometer and Gyroscope Demo
 *  Board     : Arduino UNO (arduino:avr:uno)
 *  Parts     : Accelerometer and Gyroscope I2C MPU-6050
 *  Libraries : Adafruit MPU6050 2.2.9, Adafruit Unified Sensor 1.1.15, Adafruit BusIO 1.17.4
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

#include <Wire.h>
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>

Adafruit_MPU6050 mpu;

void setup() {
  Serial.begin(115200);
  while (!Serial) {
    delay(10);
  }

  Serial.println(F("Initializing MPU-6050..."));
  if (!mpu.begin()) {
    Serial.println(F("Failed to find MPU-6050 chip. Check connections!"));
    while (1) {
      delay(10);
    }
  }
  Serial.println(F("MPU-6050 initialized successfully!"));

  // Configure sensor ranges and filter bandwidth
  mpu.setAccelerometerRange(MPU6050_RANGE_8_G);
  mpu.setGyroRange(MPU6050_RANGE_500_DEG);
  mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);
}

void loop() {
  sensors_event_t a, g, temp;
  mpu.getEvent(&a, &g, &temp);

  // Print acceleration in m/s^2
  Serial.print(F("Accel (m/s^2) X: "));
  Serial.print(a.acceleration.x, 2);
  Serial.print(F(", Y: "));
  Serial.print(a.acceleration.y, 2);
  Serial.print(F(", Z: "));
  Serial.print(a.acceleration.z, 2);

  // Print rotation rate in rad/s
  Serial.print(F(" | Gyro (rad/s) X: "));
  Serial.print(g.gyro.x, 2);
  Serial.print(F(", Y: "));
  Serial.print(g.gyro.y, 2);
  Serial.print(F(", Z: "));
  Serial.print(g.gyro.z, 2);

  // Print onboard temperature
  Serial.print(F(" | Temp: "));
  Serial.print(temp.temperature, 1);
  Serial.println(F(" C"));

  delay(500);
}

Librerie necessarie: Adafruit MPU6050 2.2.9, Adafruit Unified Sensor 1.1.15, Adafruit BusIO 1.17.4

Wiring diagram and example code generated by Codey.online — https://www.codey.online

Demo del sensore di movimento ESP32 MPU-6050

Questo progetto legge l’accelerazione su 3 assi, la velocità di rotazione e la temperatura dal sensore MPU-6050 tramite I2C. L’ESP32 legge i dati del sensore a 10 Hz e stampa valori formattati nel Serial Monitor a 115200 baud. Apri il Serial Plotter per visualizzare grafici in tempo reale dei movimenti del sensore.

Schema di collegamento: Accelerometro e giroscopio I2C - MPU-6050 su un ESP32 DevKit V1
Schema di collegamento · Clicca per ingrandire
Tabella di collegamento: Accelerometro e giroscopio I2C - MPU-6050 su un ESP32 DevKit V1
Tabella di collegamento · Clicca per ingrandire
ESP32_MPU_6050_Motion_Sensor_Demo.ino · compilato e testato
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : ESP32 MPU-6050 Motion Sensor Demo
 *  Board     : ESP32 DEVKIT V1 (esp32:esp32:esp32doit-devkit-v1)
 *  Parts     : Accelerometer and Gyroscope I2C MPU-6050
 *  Libraries : Adafruit MPU6050 2.2.9, Adafruit Unified Sensor 1.1.15
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>

Adafruit_MPU6050 mpu;

void setup() {
  Serial.begin(115200);
  while (!Serial) delay(10);

  Serial.println("Initializing MPU-6050...");

  // Initialize I2C on ESP32 default pins: SDA (GPIO 21), SCL (GPIO 22)
  Wire.begin(21, 22);

  if (!mpu.begin(0x68, &Wire)) {
    Serial.println("Failed to find MPU-6050 chip!");
    while (1) {
      delay(10);
    }
  }

  Serial.println("MPU-6050 Found!");

  // Configure sensor ranges
  mpu.setAccelerometerRange(MPU6050_RANGE_8_G);
  mpu.setGyroRange(MPU6050_RANGE_500_DEG);
  mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);

  delay(100);
}

void loop() {
  sensors_event_t a, g, temp;
  mpu.getEvent(&a, &g, &temp);

  Serial.print("Accel X: ");
  Serial.print(a.acceleration.x, 2);
  Serial.print(" m/s^2, Y: ");
  Serial.print(a.acceleration.y, 2);
  Serial.print(" m/s^2, Z: ");
  Serial.print(a.acceleration.z, 2);
  Serial.println(" m/s^2");

  Serial.print("Gyro X: ");
  Serial.print(g.gyro.x, 2);
  Serial.print(" rad/s, Y: ");
  Serial.print(g.gyro.y, 2);
  Serial.print(" rad/s, Z: ");
  Serial.print(g.gyro.z, 2);
  Serial.println(" rad/s");

  Serial.print("Temperature: ");
  Serial.print(temp.temperature, 1);
  Serial.println(" degC");
  Serial.println("------------------------------------");

  delay(500);
}

Librerie necessarie: Adafruit MPU6050 2.2.9, Adafruit Unified Sensor 1.1.15

Wiring diagram and example code generated by Codey.online — https://www.codey.online

Visti di recente

Dip switch a 5 pin 2,54 mm

Dip switch a 5 pin 2,54 mm

€ 0,90
Dissipatore TO-220 Alluminio

Dissipatore TO-220 Alluminio

€ 1,00
Estensione modulo telecamera ACEBOTT per carrello robot ESP32

Estensione modulo telecamera ACEBOTT per carrello robot ESP32

€ 29,00
Display LCD Nokia 5110 3.3V

Display LCD Nokia 5110 3.3V

€ 6,80
Modulo sensore di vibrazione e urto

Modulo sensore di vibrazione e urto

€ 4,40
Adattatore I2C per LCD 1602/2004

Adattatore I2C per LCD 1602/2004

€ 1,85
Cavo USB Step Up da 5V a 9V

Cavo USB Step Up da 5V a 9V

€ 3,90
Marble Dropper per pista Marblelous

Marble Dropper per pista Marblelous

€ 69,00
Vedi
Portabatterie 2x AA (3V)

Portabatterie 2x AA (3V)

€ 1,00
Alimentazione 5V 3A Micro-USB

Alimentazione 5V 3A Micro-USB

€ 7,49
Dip switch a 7 pin 2,54 mm

Dip switch a 7 pin 2,54 mm

€ 0,95
Diodo 1N5822 Schottky rectifier 40V 3A

Diodo 1N5822 Schottky rectifier 40V 3A

€ 0,45
Scheda breakout USB-C Male Socket

Scheda breakout USB-C Male Socket

€ 0,85