PiicoDev Pressure Sensor MS5637 - Micro:bit Guide

Updated 23 September 2021

Introduction

This guide will help you read barometric pressure from your PiicoDev® Pressure Sensor and a Micro:bit

To follow along, it's best to have:

We'll program with Thonny in this tutorial. If you haven't used Thonny before, check out our guide for Programming a Micro:bit with Thonny. If you prefer, you can program your Micro:bit using python.microbit.org instead (see our guide).

Contents

Connect the PiicoDev sensor to your Micro:bit

Plug your Micro:bit into the PiicoDev adapter (buttons + LED matrix facing up), connect your motion sensor to the adapter via the PiicoDev cable and connect your Micro:bit to your computer with a USB lead.

If you're unfamiliar with connecting PiicoDev modules, read the PiicoDev Connection Guide before proceeding.

connect-piicodev-pressure-sensor-to-microbit

Download the PiicoDev Modules and Example Code

Download the following files and save them to your working directory (Right Click > "Save Link As")

It will be best to keep this file wherever you like to keep your coding projects eg. Documents > PiicoDev

Example Code

We'll be working in Thonny - if you're unfamiliar working with Thonny see our guide for Thonny and Micro:bit.

Open Thonny, connect to your Micro:bit and upload the three files. (Hint: View the files menu with View > Files)

Restart your Micro:bit with keyboard shortcut, Ctrl+D and it should begin printing barometric pressure measurements in hectopascal, which is equivalent to millibar - a commonly used unit for describing barometric pressure: 1hPa = 100Pa = 1mbar.

piicodev-pressure-sensor-demo-code

Above: Pressure data streams up the Shell, while the Plot shows historic data.

Remix

Did you know you can also infer altitude from air pressure? Comment out the pressure print statement and uncomment the altitude print statement. Run the script again and now the Pico will infer altitude-above-sea-level from air pressure. There can be a bit of error here since your local weather conditions will affect the reading. You can optionally pass in the local air pressure at sea level to the read_altitude() function to correct for weather effects. You can find the current air pressure at sea level for your area with an internet search.

piicodev-pressure-sensor-ms5637-altitude-measurement-remix

Conclusion

We can now measure air pressure from our PiicoDev Pressure Sensor, and use it to infer altitude.

If you make something cool with this starter project we'd love for you to share it on our forums! And if you'd like some help with this guide, start the conversation below - We're full-time makers and here to help!

Have a question? Ask the Author of this guide today!

Please enter minimum 20 characters

Your comment will be posted (automatically) on our Support Forum which is publicly accessible. Don't enter private information, such as your phone number.

Expect a quick reply during business hours, many of us check-in over the weekend as well.

Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.