How to Connect the BME280 Sensor to the Raspberry Pi Pico Using CircuitPython

 

Using the BME280 sensor in CircuitPython is a great way to start getting sensor readings easily. Adafruit makes it easy to port their library and start working with your Temperature, Pressure, and Humidity readings! In general, the BME280 is a powerful and low-cost sensor to start getting such readings. It is superior to its often confused counterpart, the BMP280... since the BMP280 cannot give humidity readings while the BME280 can. As we know, humidity is a vital part of any environmental system so I highly recommend this sensor if you are developing a DIY project! 

Where to Buy BME280 Pressure, Humidity, and Temperature Sensor for the Raspberry Pi Pico:

Amazon

    Step 1-) Connect the Sensor as Follows:

    Note that some BME280 sensors are designed differently, and some have extra connections. You only need to make the 4 connections shown above (VCC, GND, SCL, SDA), which all BME280 sensors explicitly have, to have the physical setup set to start retrieving sensor values. 

    Also, be sure to connect your device to power once you are ready to go!

    Step 2-) Download the Libraries from the AdaFruit Website:

    The library for CircuitPython for the BME280 is found here

    Click Download Project Bundle and it will download a zip file with the library contents, there are two folders you need to extract and port to your lib folder on your Raspberry Pi Pico. 

    Your directory/file structure for the library should resemble the following on your Pico file system:

    If you cannot copy and paste the files over you have to manually create the directory and file names and copy the content sadly. Unfortunately, Thonny is not the most robust IDE...

    Step 3-) Run the sample Code:

    Create a Python file named by your choice and copy the contents from my GitHub page here. You may have to alter the I2C device address in the code to 77 as opposed to 76, depending on what version of the BME280 you are using. But once you have that down you are done!

    You can now run this code in Thonny if you add the libraries and make the proper physical connections! You can also alter the time.sleep() value if you want to get readings slower or faster. 

    Conclusion:

    You should be all set to get your sensor values in CircuitPython if you followed this tutorial. Please like comment and subscribe to the channel if you found this useful. Now go make a weather station or something!

    Create a free account to access full content.

    All access to code and resources on ShillehTek.

    Signup Now

    Already a member? Sign In

    Explore More on Our Blog

    How to Use ADS1115 with the Raspberry Pi (Part 1)

    How to Use ADS1115 with the Raspberry Pi (Part 1)

    Discover how to expand your Raspberry Pi projects by integrating the ADS1115 ADC for precise analog signal reading....

    How to Install Pip Packages in AWS Lambda Using Docker and ECR

    How to Install Pip Packages in AWS Lambda Using Docker and ECR

    Learn how to streamline AWS Lambda deployments by using Docker and Amazon Elastic Container Registry (ECR) to package...

    Create Tabular Product Descriptions on Your Shopify Store

    Create Tabular Product Descriptions on Your Shopify Store

    Enhance your Shopify store's product pages with our comprehensive guide on implementing tabular descriptions. Learn how to add a...

    SSH Into Raspberry Pi with Tailscale VPN

    SSH Into Raspberry Pi with Tailscale VPN

    Effortlessly access and manage your Raspberry Pi from anywhere using Tailscale's secure mesh VPN.

    Send Email with Lua and the ESP32

    Send Email with Lua and the ESP32

    In this tutorial, we delve into sending emails with the ESP32-S3 using Lua, focusing on the Xedge IDE's built-in SMTP...

    How to Code with Lua on ESP32 with XEdge32

    How to Code with Lua on ESP32 with XEdge32

    Learn how to set up Xedge32 and start coding on the ESP32-S3 with Lua programming!

    Stream Audio From Raspberry Pi to Local Computer

    Stream Audio From Raspberry Pi to Local Computer

    Discover the simplicity of streaming live audio directly from a USB microphone connected to your Raspberry Pi to...

    SSH Raspberry Pi via Cell Phone

    SSH Raspberry Pi via Cell Phone

    This beginner-friendly guide will walk you through remotely controlling your Raspberry Pi using SSH through your cell phone.

    Remotely Control Raspberry Pi via SSH from External Network

    Remotely Control Raspberry Pi via SSH from External Network

    Learn how to SSH into your Raspberry Pi from any network. This is critical in IoT since you can control...

    Stream Video from Raspberry Pi Camera to YouTube Live

    Stream Video from Raspberry Pi Camera to YouTube Live

    Learn how to stream to YouTube from a Raspberry Pi Camera.

    Back to blog

    Leave a comment

    Please note, comments need to be approved before they are published.