MPU6050 Accelerometer and Gyroscope interface with Raspberry Pi using WiringPi

The MPU6050 sensor module is a widely used 6-axis motion tracking device, integrating the following components:
0x68 (can be changed to 0x69 by connecting AD0 to VCC).Connect the MPU6050 to the Raspberry Pi as follows:
| MPU6050 Pin | Raspberry Pi Pin (BCM) | Function |
|---|
| VCC | 3.3V (Pin 1) | Power |
|---|
| GND | GND (Pin 6) | Ground |
|---|
| SCL | GPIO3 (Pin 5) | I2C Clock (SCL) |
|---|
| SDA | GPIO2 (Pin 3) | I2C Data (SDA) |
|---|
| AD0 | GND (For 0x68 address) | Address Select |
|---|
Install WiringPi (if not installed)
sudo apt update
sudo apt install wiringpi
Enable I2C on Raspberry Pi
Run sudo raspi-config → "Interfacing Options" → Enable I2C.
Check I2C Connection
Ensure the ADS1115 is detected using:
i2cdetect -y 1
You should see an entry at 0x68 (default address).
Read Data via WiringPi
If you're using the i2c command-line tool from WiringPi, try:
gpio i2c 1 0x68 0x00
#include <stdio.h>
#include <stdint.h>
#include <wiringPi.h>
#include <wiringPiI2C.h>
#define MPU6050_ACCEL_XOUT_H 0x3B // R
#define MPU6050_ACCEL_YOUT_H 0x3D // R
#define MPU6050_ACCEL_ZOUT_H 0x3F // R
#define MPU6050_GYRO_XOUT_H 0x43 // R
#define MPU6050_GYRO_YOUT_H 0x45 // R
#define MPU6050_GYRO_ZOUT_H 0x47 // R
#define MPU6050_PWR_MGMT_1 0x6B // R/W
#define MPU6050_I2C_ADDRESS 0x68 // I2C
int main()
{
int fd = wiringPiI2CSetup(MPU6050_I2C_ADDRESS);
if (fd == -1){
return 0;
}
wiringPiI2CReadReg8(fd, MPU6050_PWR_MGMT_1);
wiringPiI2CWriteReg16(fd, MPU6050_PWR_MGMT_1, 0);
signed long int x,y,z;
signed long int ax,ay,az;
while(1)
{
ax = wiringPiI2CReadReg8(fd, MPU6050_ACCEL_XOUT_H);
ay = wiringPiI2CReadReg8(fd, MPU6050_ACCEL_YOUT_H);
az = wiringPiI2CReadReg8(fd, MPU6050_ACCEL_ZOUT_H);
x = wiringPiI2CReadReg8(fd, MPU6050_GYRO_XOUT_H);
y = wiringPiI2CReadReg8(fd, MPU6050_GYRO_YOUT_H);
z = wiringPiI2CReadReg8(fd, MPU6050_GYRO_ZOUT_H);
printf("Accel x=%li Accel y=%li Accel z=%li \n", ax,ay,az);
printf("Gyro x=%li Gyro y=%li Gyro z=%li \n", x,y,z);
delay(500);
}
return 0;
}

“LVGL is the only framework that I've seen as open source Graphics Library for Microcontrollers. It’s easy to customize, adapts to any design, and the build size is tiny.”

Nokia 5110 LCD PCD8544 driver with a Raspberry Pi using WiringPi

OLED ssd1306 display interface with Raspberry Pi using WiringPi

To control a 4-channel relay using an ESP32 with a touch display (via LVGL library), you can integrate the relay control with a graphical user interface (GUI).

Interface the ADS1115 analog-to-digital converter (ADC) with a Raspberry Pi using WiringPi

MPU6050 Accelerometer and Gyroscope interface with Raspberry Pi using WiringPi

To perform HTTP GET and HTTP POST requests on an ESP32, you can use the WiFi and HTTPClient libraries.