Raspberry Pi Pico ProjectsRaspberry Pi Projects

How To Connect MPU6050 With Raspberry Pi Pico Tutorial

MPU6050 is one of the most popular sensors used in IoT applications. It is an accelerometer and gyroscope sensor that can measure an object’s acceleration and rotation. In this project, we will be using the MPU6050 With Raspberry Pi Pico to get readings from the gyroscope and accelerometer. The sensor can be connected to a Raspberry Pi Pico through the I2C interface.

Required Components

Raspberry Pi Pico


The Raspberry Pi Pico is a microcontroller board based on the RP2040 chip, developed by Raspberry Pi. It was first released on January 2021. The Raspberry Pi Pico board has two main components: the RP2040 chip and a USB controller.

The RP2040 chip is a Cortex M0+-based microcontroller, designed by Raspberry Pi. It has two ARM Cortex M0+ cores, each running at up to 133 MHz. The chip also has 264kB of SRAM, and 2MB of on-chip flash memory. The USB controller is used to connect the Pico to a computer or other USB devices

Raspberry Pi Pico Pinout

The Pico’s 40-pin header is arranged in two rows of 20 pins. The pins in each row are numbered 1-20, starting at the top left of the header.


What is MPU6050?

The MPU6050 is a 6-axis MEMS (Microelectromechanical systems) device that combines a 3-axis gyroscope and a 3-axis accelerometer on a single chip. It also houses an on-chip Digital Motion Processor (DMP) which processes complex 6-axis MotionFusion algorithms.

The device can be used in various applications such as drones, robotics, gaming devices, pedometers, and Wearable devices. The MPU6050 is available in a small 4x4mm QFN package. In this essay, I’ll explain how the MPU6050 works and how you can use it in your projects.

The MPU6050 can be used to measure both acceleration and rotational rate, making it ideal for applications such as monitoring the orientation of a robotic arm or measuring the vibrations of an engine.

MPU6050 Pinout

MPU6050 Accelerometer Gyroscope Pinout e1665120604799
Source- lastminuteengineers.com
  • VCC pin is used to power the sensor
  • GND pin is connected to the ground
  • SCL (serial clock) pin is a clock pulse pin used for I2C communication
  • SDA (serial data) pin transfers data to/from the microcontroller according to the I2C protocol
  • XDA (Auxiliary Serial Data) pin allows connecting external I2C modules with MPU6050
  • XCL (Auxiliary clock) pin enables the auxiliary device from MPU6050
  • AD0 (Address select) pin is an I2C slave address select pin. This pin allows selecting one or more MPU6050 when connected with a single I2S serial bus
  • INT (interrupt) pin is a digital output pin which gives an indication to a microcontroller when data are available to be read. Learn How to Interface MPU6050 Accelerometer and Gyroscope Sensor with Arduino

MPU6050 Features

  • MEMS 3-axis accelerometer and 3-axis gyroscope values combined
  • Power Supply: 3-5V
  • Communication: I2C protocol
  • Built-in 16-bit ADC provides high accuracy
  • Built-in DMP provides high computational power
  • Can be used to interface with other IIC devices like magnetometer
  • Configurable IIC Address
  • In-built Temperature sensor

How to connect MPU6050 with Raspberry Pi Pico

To use the MPU6050, you’ll need to connect it to your Raspberry pi pico. The MPU6050 uses an I2C interface, so you’ll need to use a microcontroller with an I2C interface. I2C is a two-wire interface that allows you to connect multiple devices to a single microcontroller

To join the MPU6050 sensor to the Raspberry Pi Pico, we will use the I2C interface. The I2C interface is a two-wire interface that uses the SDA and SCL pins

MPU6050<======> Raspberry Pi Pico

  • VCC <======> 5v out pin
  • GND <======>Ground pin
  • SDA <======>1 pin //serial data
  • SCL<======> 2pin // serial clock

Schematic Diagram -MPU6050 with Raspberry Pi Pico

How To Connect MPU6050 With Raspberry Pi Pico

Once you’ve connected the MPU6050 to your microcontroller, you can use the I2C interface to read the accelerometer and gyroscope data.

The MPU6050 provides 16-bit data for each axis, so you can use the accelerometer data to calculate acceleration, and the gyroscope data to calculate the rotational rate.

Python Program

To do this Interfacing of the MPU6050 Module project with Raspberry Pi Pico Board we need to:

  • Download and install the latest version of Python3 on your PC
  • Download and install the latest version of either upycraft IDE or Thonny IDE.
  • Setting up a MicroPython within Raspberry Pi Pico.

Guide below tutorials to follow the above steps to complete our Pico board ready for programming.

  1. Getting Started With Raspberry Pi Pico With Thonny IDE
  2. Getting Started Raspberry Pi Pico – Pinout, Specs – Beginner Guide

Setup Thonny IDE

Setup Thonny IDEThonny is a Python IDE that is designed for beginners. It is very user-friendly and has a lot of features that make it perfect for beginner programmers. The Pico is a great fit for Thonny because it is very easy to use and has a lot of GPIO pins that can be used for various purposes.Getting Started With Raspberry Pi Pico With Thonny IDE

First, you need to download and install the Thonny IDE. You can get it here: https://thonny.org/ 

  • Next, open Thonny and go to File > Preferences. In the Preferences window, go to the Interpreters tab.
  • Click the “Add” button and select “Raspberry Pi Pico” from the drop-down menu.
  • Now, you need to connect your Raspberry Pi Pico to your computer via USB.
  • Enter the following into the “Script to run on connected device” text box:
  • Once it is connected, click the “Upload” button in the Thonny IDE.

MicroPython Script for MPU6050

To read the values of the Accelerometer, Gyroscope, and Temperature from MPU6050 we need two libraries: imu.py and vector3d.py. and to program the Raspberry Pi Pico board using MicroPython we will use Pico-Thonny IDE. we have to upload these libraries one by one.





After uploading the All MicroPython script on the Raspberry Pi Pico board the MPU6050 sensor will start Printing the values being read for Accelerometer, Gyroscope, and Temperature. in the thorny IDE Shell window.


ax -0.03 ay -0.0 az 1.24 gx 0 gy -3 gz 1 Temperature 29.02

Read Similar Articles:

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button

Adblock Detected

Please consider supporting us by disabling your ad blocker