![]() Also, import the bme280 library which we previously installed. We also import the sleep module so that we will be able to add a delay of 10 seconds in between our readings. This is because we have to specify the pin for I2C communication. Sleep(10) #delay of 10s How the Code Works?įirstly, we will be importing the Pin class and I2C class from the machine module. from machine import Pin, I2C #importing relevant modules & classes This MicroPython script reads Pressure, Temperature and Humidity values from BME280 over I2C lines and prints them on MicroPython shell console. py file and upload the file to Raspberry Pi Pico. Now let’s look at the MicroPython script for BME280 to get sensor readings. We will see a MicroPython script code and after uploading it to our board, we will see readings of temperature, pressure, and relative humidity printed on the MicroPython shell terminal. We will connect our BME280 sensor with the Raspberry Pi Pico via the I2C protocol as shown above in the connection diagram. Let’s now look at an example to show the working of the sensor. The figure below shows the BME280 sensor and its pinout. The Raspberry Pi Pico communicates with the BME280 sensor through the I2C protocol to give temperature, barometric pressure, and relative humidity readings. ![]() With BME280 and the microcontroller, the Raspberry Pi Pico acts as a master, and the BME280 sensor as a slave because it is an external device, acts as a slave. I2C means Inter-Integrated Circuit and works on the principle of the synchronous, multi-master multi-slave system. Although there are several different versions of BME280 available in the market, the one we will be studying uses I2C communication protocol and SPI. ![]() This sensor uses I2C or SPI to communicate data with the micro-controllers. It is mostly used in web and mobile applications where low power consumption is key. The BME280 sensor is used to measure readings regarding ambient temperature, barometric pressure, and relative humidity. Getting Started with Raspberry Pi Pico using uP圜raft IDE. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |