Advertisement

Quick Links

Welcome!
Thank you for purchasing our AZ-Delivery BME280 temperature, humidity
and air pressure sensor. On the following pages, you will be introduced to
how to use and set-up this handy device.
Have fun!

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the BME280 and is the answer not in the manual?

Questions and answers

Summary of Contents for AZ-Delivery BME280

  • Page 1 Welcome! Thank you for purchasing our AZ-Delivery BME280 temperature, humidity and air pressure sensor. On the following pages, you will be introduced to how to use and set-up this handy device. Have fun!
  • Page 2 Areas of application Education and teaching: Use in schools, universities and training institutions to teach the basics of electronics, programming and embedded systems. Research and development: Use in research and development projects to create prototypes and experiments in the fields of electronics and computer science. Prototype development: Use in the development and testing of new electronic circuits and devices.
  • Page 3 consult a doctor. Caution: Keep the product out of the reach of children and pets to avoid accidental contact and swallowing of small parts. Note: Store the product in a safe, closed container when not in use. Attention: Avoid contact of the product with food and drinks.
  • Page 4: Table Of Contents

    Table of Contents Introduction....................3 Specifications....................4 How to set-up Arduino IDE................5 How to set-up the Raspberry Pi and Python..........9 The pinout....................10 Connecting the module with microcontroller..........11 Arduino IDE library..................12 Sketch example..................13 Connecting the sensor with Raspberry Pi...........17 Enabling the I2C interface................18 Python scripts..................20 - 2 -...
  • Page 5: Introduction

    Introduction The BME280 sensor is a digital barometric sensor in one small package. The sesnors consists of temperature, humidity and pressure sensors combined. The BME280 sensor can be used in a variety of applications such as home automation for heating and air conditioning, health monitoring devices, navigation systems, weather stations, handset devices, IoT and many other applications.
  • Page 6: Specifications

    Specifications » Operating voltage range: from 3.3V to 5V DC » Current consumption: < 1mA » Temperature range: from -40°C to 85 °C » Temperature accuracy: ±1.0°C » Pressure range: from 300 to 1100 hPa » Pressure accuracy: ±1hPa » Humidity range: from 0 to 100% RH »...
  • Page 7 The pinout The BME280 sensor has four pins. The pinout is shown on the following image: The sensor has an on-board LM6206 3.3V voltage regulator and a voltage level translator. The pins of the BME280 sensor can operate on voltages in range from 3.3V or 5V without a danger for the sensor itself.
  • Page 8: How To Set-Up Arduino Ide

    How to set-up Arduino IDE If the Arduino IDE is not installed, follow the link and download the installation file for the operating system of choice. For Windows users, double click on the downloaded .exe file and follow the instructions in the installation window. - 6 -...
  • Page 9 For Linux users, download a file with the extension .tar.xz, which has to be extracted. When it is extracted, go to the extracted directory and open the terminal in that directory. Two .sh scripts have to be executed, the first called arduino-linux-setup.sh and the second called install.sh.
  • Page 10 Almost all operating systems come with a text editor preinstalled (for example, Windows comes with Notepad, Linux Ubuntu comes with Gedit, Linux Raspbian comes with Leafpad, etc.). All of these text editors are perfectly fine for the purpose of the eBook. Next thing is to check if your PC can detect an Arduino board.
  • Page 11 If the Arduino IDE is used on Windows, port names are as follows: For Linux users, for example port name is /dev/ttyUSBx, where x represents integer number between 0 and 9. - 9 -...
  • Page 12: How To Set-Up The Raspberry Pi And Python

    How to set-up the Raspberry Pi and Python For the Raspberry Pi, first the operating system has to be installed, then everything has to be set-up so that it can be used in the Headless mode. The Headless mode enables remote connection to the Raspberry Pi, without the need for a PC screen Monitor, mouse or keyboard.
  • Page 13: Connecting The Module With Microcontroller

    Connecting the module with microcontroller Connect the BME280 sensor with the microcontroller as shown on the following connection diagram: BME280 pin MC pin Wiring color 3.3V Red wire Black wire Orange wire Blue wire - 11 -...
  • Page 14 Adafruit BME280. To download and install it, open Arduino IDE and go Tools > Manage Libraries When a new window opens, type BME280 in the search box and install the library called Adafruit BME280 Library made by Adafruit as shown...
  • Page 15: Sketch Example

    Sketch example The following sketch example is modified sketch from the Adafruit BME280 library: File > Examples > Adafruit BME280 Library > bme280test #include <Wire.h> #include <Adafruit_Sensor.h> #include <Adafruit_BME280.h> Adafruit_BME280 bme; // I2C void setup() { Serial.begin(9600); // default address from library is 0x77 // bool communication = bme.begin();...
  • Page 16 void loop() { Serial.print("Temperature = "); Serial.print(bme.readTemperature()); Serial.println(" *C"); Serial.print("Pressure = "); Serial.print(bme.readPressure() / 100.0F); Serial.println(" hPa"); Serial.print("Humidity = "); Serial.print(bme.readHumidity()); Serial.println(" %\n"); delay(1000); - 14 -...
  • Page 17 Upload the sketch to the microcontroller and open Serial Monitor (Tools > Serial Monitor). The result should look like the output on the following image: - 15 -...
  • Page 18 The sketch begins with including three libraries: Wire, Adafruit_Sensor and Adafruit_BME280. Next, the object called bme is created with the following line of code: Adafruit_BME280 bme; In the setup() function the serial communication is started with the baud rate of 9600bps. Then, the bme object is initialized with the following line of the code: bme.begin(0x76) where 0x76 is the I2C address of the sensor.
  • Page 19 In the loop() function the temperature, pressure and humidity data is read with the following lines of code: bme.readTemperature() bme.readPressure() / 100.0F bme.readHumidity() After that the data is displayed in Serial Monitor with following lines of code: Serial.print(bme.readTemperature()); Serial.print(bme.readPressure() / 100.0F); Serial.print(bme.readHumidity());...
  • Page 20: Connecting The Sensor With Raspberry Pi

    Connecting the sensor with Raspberry Pi Connect the BME280 sensor with the Raspberry Pi as shown on the following connection diagram: BME280 pin Raspberry Pi pin Physical pin No. Wire color Black wire Red wire GPIO3 Blue wire GPIO2 Green wire...
  • Page 21: Enabling The I2C Interface

    Enabling the I2C interface In order to use the module with Raspberry Pi, the I2C interface has to be enabled. Open following menu: Application Menu > Preferences > Raspberry Pi Configuration In the new window, under the tab Interfaces, enable the I2C radio button, as shown on the following image: - 19 -...
  • Page 22 To detect the I2C address of the sensor connected to the I2C interface of the Raspberry Pi, the i2c-tools tool has to be installed, if not, open the terminal and run the following command: sudo apt-get install i2c-tools To detect the I2C address, open terminal and run the following command: i2cdetect -y 1 The result should look like the output on the following image: Where 0x76 is the I2C address of the sensor.
  • Page 23: Python Scripts

    Python scripts Two scripts are created, one for all functions and the other for using these functions, because of a better readability. The code for the first script is the following: import smbus import time from ctypes import c_short from ctypes import c_byte...
  • Page 24 getUChar(data, index): # return one byte from data as an unsigned char result = data[index] & 0xFF return result readBME280ID(addr=DEVICE): # Chip ID Register Address REG_ID 0xD0 (chip_id, chip_version) bus.read_i2c_block_data(addr, REG_ID, 2) return (chip_id, chip_version) readBME280All(addr=DEVICE): # Register Addresses REG_DATA 0xF7 REG_CONTROL 0xF4...
  • Page 25 # one tab # Convert byte data to word values dig_T1 getUShort(cal1, 0) dig_T2 getShort(cal1, 2) dig_T3 getShort(cal1, 4) dig_P1 getUShort(cal1, 6) dig_P2 getShort(cal1, 8) dig_P3 getShort(cal1, 10) dig_P4 getShort(cal1, 12) dig_P5 getShort(cal1, 14) dig_P6 getShort(cal1, 16) dig_P7 getShort(cal1, 18) dig_P8 getShort(cal1, 20) dig_P9...
  • Page 26 # one tab temp_raw (data[3] << (data[4] << (data[5] >> hum_raw (data[6] << data[7] # Refine temperature var1 ((((temp_raw >> 3) – (dig_T1 << 1))) (dig_T2)) >> var2 (((((temp_raw >> – (dig_T1)) ((temp_raw >> (dig_T1))) >> 12)*(dig_T3)) >> t_fine var1 var2 temperature float(((t_fine...
  • Page 27 # one tab humidity > 100: humidity elif humidity < humidity return temperature 100.0, pressure 100.0, humidity Save the script by the name bme280.py. The script code is modified from script - 25 -...
  • Page 28 The following is code for the main script: import bme280 from time import sleep u'\xb0' print('[Press CTRL + C to end the script!]') try: while(True): temperature,pressure,humidity bme280.readBME280All() print('Temperature = {}{}C'.format(temperature, dgr)) print('Humidity = {.2f}%'.format(humidity)) print('Pressure = {.2f}hPa\n'.format(pressure)) sleep(1) except KeyboardInterrupt:...
  • Page 29 Save the script by the name bme280main.py into the same directory where you saved the bme280.py script. To run the main script open the terminal in the directory where the scripts are saved and run the following command: python3 bme280main.py The result should look like the output on the following image: To stop the script press CTRL + C on the keyboard.
  • Page 30 The bme280main.py script starts with importing bme280 script and the sleep function from the time library. Then, the dgr variable is created, where UTF degree sign value is stored. Next, the try-except block of code is created. In the try block of code, the indefinite loop block (while True:) is created.
  • Page 31 Internet. If you are looking for the high quality microelectronics and accessories, AZ-Delivery Vertriebs GmbH is the right company to get them from. You will be provided with numerous application examples, full installation guides, eBooks, libraries and assistance from our technical experts.

Table of Contents