Skip to content
Buy 10+ on select items — save 10% auto-applied
Free US shipping on orders $35+
Order by 3pm ET — ships same-day from the US
Skip to main content

Raspberry Pi Pico MPU6050: Read motion data | ShillehTek

October 22, 2023

Raspberry Pi Pico MPU6050: Read motion data | ShillehTek
Project

Build a Raspberry Pi Pico (or Pico W) + MPU6050 setup to read acceleration, gyro, and temperature in Thonny for fast motion sensing with ShillehTek.

20 min Beginner5 parts

Video Tutorial

Watch first if you want to see the physical setup and Thonny configuration for reading MPU6050 data on the Raspberry Pi Pico W.

Project Overview

In this tutorial, you will connect a Raspberry Pi Pico (or Pico W) to an MPU6050 accelerometer and run MicroPython code in Thonny to start getting live sensor readings (acceleration, gyro, and temperature) in the console.

The MPU6050 is a low-cost and accurate acceleration sensor commonly used with microcontrollers like the Raspberry Pi Pico and Arduino.

  • Time: 20 to 40 minutes
  • Skill level: Beginner
  • What you will build: A wired MPU6050-to-Pico setup that prints motion and temperature readings in Thonny

Parts List

From ShillehTek

You can also purchase the bundle for this project here

External

Note: This tutorial uses four wires (power, ground, and I2C SDA/SCL). Wire color does not affect signal transmission.

Step-by-Step Guide

Step 1 - Gather the components

Goal: Make sure you have everything needed to wire the MPU6050 to the Raspberry Pi Pico and run MicroPython.

What to do: Collect the MPU6050, jumper wires, a Raspberry Pi Pico (or Pico W) with MicroUSB, and a breadboard.

Expected result: All hardware and your USB cable are ready before you start wiring.

Step 2 - Attach the Raspberry Pi Pico to the breadboard

Goal: Seat the Pico firmly so you can wire it easily.

What to do: Press the Raspberry Pi Pico into the breadboard so it sits securely. Pin depth is fine even if the pins insert fully. Placement on the board is flexible, but aligning it across the center can make wiring clearer.

Raspberry Pi Pico mounted on a breadboard, positioned across the center gap

Expected result: The Pico is stable on the breadboard and you can access its pins easily.

Step 3 - Wire the MPU6050 to the Pico

Goal: Provide power and connect the I2C communication lines (SDA and SCL) between the Pico and the MPU6050.

What to do: Plug your MicroUSB cable from your computer into the Raspberry Pi Pico. Then take four jumper wires and connect them using the same pin numbers shown in the original build:

  • Red wire: Pin 39
  • Black wire: Pin 38
  • White wire: Pin 1
  • Yellow wire: Pin 2
Raspberry Pi Pico wired to an MPU6050 module using four jumper wires on a breadboard

The pins on the Pico are arranged like this:

Raspberry Pi Pico pin layout diagram showing the physical pin numbering

On the MPU6050, connect the wires to the matching pins for power and I2C. VCC provides power, GND is ground, and SCL/SDA are the communication lines between the Raspberry Pi Pico and the accelerometer module.

MPU6050 pin labels showing VCC, GND, SCL, and SDA connections for wiring to a Raspberry Pi Pico

Expected result: The MPU6050 powers up and the module LED lights up red, indicating it is receiving power.

Step 4 - Add the library and main script in Thonny

Goal: Put the required MicroPython files onto the Pico and run the script that prints MPU6050 readings.

What to do: In Thonny, create two files on your Pico: one for the library (do not change the library filename) and one for your main script. Copy the code from these links into the matching files:

If you do not have Thonny installed yet, you can download it here:

If Thonny is set up properly with your Raspberry Pi Pico, you should see a file browser showing your Pico files on the bottom left.

Thonny IDE connected to a Raspberry Pi Pico showing the device file browser and editor

Run the main file to start getting readings.

Expected result: MPU6050 readings for all 6 degrees of acceleration plus temperature begin printing in the Thonny console.

Conclusion

You now have an MPU6050 connected to a Raspberry Pi Pico (or Pico W) and can read acceleration, gyro, and temperature values in Thonny using MicroPython. This setup is a solid starting point for motion-based projects and DIY sensor logging.

Want the exact parts used in this build? Grab what you need from ShillehTek.com. If you want help customizing this project or building something similar for your product, check out our IoT consulting services.