Warning: Declaration of Db::query($query) should be compatible with mysqli::query($query, $resultmode = NULL) in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 29

Deprecated: Function get_magic_quotes_runtime() is deprecated in /var/www/u1300519/data/www/acoptex.com/_lib/CacheLite/Lite.php on line 757

Deprecated: Function get_magic_quotes_runtime() is deprecated in /var/www/u1300519/data/www/acoptex.com/_lib/CacheLite/Lite.php on line 757

Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 64

Warning: mysqli_fetch_array() expects parameter 2 to be int, string given in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 64

Deprecated: Function get_magic_quotes_runtime() is deprecated in /var/www/u1300519/data/www/acoptex.com/_lib/CacheLite/Lite.php on line 757

Deprecated: Function get_magic_quotes_runtime() is deprecated in /var/www/u1300519/data/www/acoptex.com/_lib/CacheLite/Lite.php on line 757

Warning: Cannot modify header information - headers already sent by (output started at /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php:0) in /var/www/u1300519/data/www/acoptex.com/_config/config.php on line 168

Warning: session_start(): Cannot start session when headers already sent in /var/www/u1300519/data/www/acoptex.com/_config/config.php on line 169

Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 92

Warning: mysqli_fetch_array() expects parameter 2 to be int, string given in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 92

Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 64

Warning: mysqli_fetch_array() expects parameter 2 to be int, string given in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 64
jobs.html_title
0

members

Easy Basics: Project 085a BME280 sensor module and Arduino

of Acoptex.com in UNO

Basics: Project 085a

Project name: BME280 sensor module and Arduino

Tags: Arduino, Arduino Uno, BME280, BME280 sensor, humidity, temperature, pressure, altitude, GY-BME280, Digital Sensor, SPI I2C Humidity Temperature and Barometric Pressure Sensor Module, GY-BME280-3.3

Attachments:I2Cscannersketch,bme280testsketch1,library1 and library2

In this project, you needed these parts :

1.Aruduino Uno R3 (you can also use the other version of Arduino)

2.Arduino IDE ( you can download it from here  )

3. Jumper cables M-M

4. Breadboard 1 pc

5. BME280 sensor module 1 pc

General

We will learn how to get the pressure, temperature and humidity from BME280 sensor module with Arduino board.

Understanding the BME280 module

The BME280 is the next-generation of sensors from Bosch, and is the upgrade to the BMP085/BMP180/BMP183 - with a low altitude noise of 0.25m and the same fast conversion time. 

The BME280 sensor module reads temperature, humidity, and pressure. You can also estimate altitude as the pressure changes with altitude. 

The sensor can communicate using either SPI (supports 3-, 4-wire SPI) or I2C communication protocols (there are modules of this sensor that just communicate with I2C, these just come with four pins).

The sensor comes with an on-board LM6206 3.3V regulator and I2C Voltage Level Translator, so you can use it with a 3.3V or 5V logic microcontroller like Arduino without worry.

The BME280 consumes less than 1mA during measurements and only 5μA during idle. This low power consumption allow the implementation in battery driven devices such as handsets, GPS modules or watches.

Specifications:

  • Supply Voltage: 1.8 - 5V DC
  • Interface: I2C (up to 3.4MHz), SPI (up to 10 MHz)
  • Operational Range: Temperature: -40 to +85° C
  • Humidity: 0-100%
  • Pressure: 300-1100 hPa
  • Resolution:Temperature: 0.01°C Humidity: 0.008% Pressure: 0.18Pa
  • Accuracy:Temperature: +-1°C Humidity: +-3% Pressure: +-1Pa
  • I2C address SDO LOW : 0x76 SDO HIGH: 0x77 

The module features a simple two-wire I2C interface which can be easily interfaced with any microcontroller of your choice. The default I2C address of the BME280 module is 0x76 and can be changed to 0x77 easily with the solder jumper besides chip.

How to change I2C Address?

  1. Locate the solder jumper besides chip. By default the middle copper pad is connected to the left pad.
  2. Scratch the connection between the middle and the left copper pad to disconnect those using a sharp knife.
  3. Add a solder blob between the middle and the right copper pad to join them. It allows you to set the I2C address 0x77.

Signals and connections of the BME280 sensor module

To use SPI communication protocol, you must have the following pins:

VIN -  power supply 3.3V DC

GND - ground

CLK (or SCK or SCL) (Serial Clock) - The clock pulses which synchronize data transmission generated by the master

MISO (or DO or SO or SDO) (Master In Slave Out) - The Slave line for sending data to the master

MOSI (or DI or SI or CMD or SDI or SDA) (Master Out Slave In) - The Master line for sending data to the peripherals

CS (or SS or D3 or CSB) (Chip Select or Slave Select) - the pin on each device that the master can use to enable and disable specific devices

If your BME280 sensor module has 4 pins it can use I2C communication protocol only: 

VIN -  power supply  3.3V DC

GND - ground

SDA - Serial Data Line

SCL  - Serial Clock Line 

Wiring

Connections are very simple. Connect VIN pin to the 5V output on the Arduino and connect GND to ground. 

Note that each Arduino Board has different I2C pins which should be connected accordingly. On the Arduino boards with the R3 layout, the SDA (data line) and SCL (clock line) are on the pin headers close to the AREF pin. They are also known as A5 (SCL) and A4 (SDA). 

Arduino Nano has A5 (SCL) and A4 (SDA). If you have a Arduino Mega and Leonardo/Micro, the pins are different! Arduino Mega - 21 (SCL) and 20 (SDA), Leonardo/Micro -  3 (SCL) and 2 (SDA)

 

 

Code

The sketch starts with including four libraries viz. Wire.h, SPI.h, Adafruit_Sensor.h and Adafruit_BME280.h.

Next, we define SEALEVELPRESSURE_HPA variable needed to calculate the altitude and create an object of Adafruit_BME280 library so that we can access functions related to it.

In setup section of code we initialize the serial communication with PC and call the begin() function.

The begin (I2C_ADDR) function takes the I2C address of the module as parameter. If your module has different I2C address or you changed it, you need to specify it correctly. This function initializes I2C interface with given I2C Address and checks if the chip ID is correct. It then resets the chip using soft-reset & waits for the sensor for calibration after wake-up.

In looping section of the code, we use following functions to read temperature, relative humidity & barometric pressure from the BME280 module.

readTemperature() function returns the temperature from the sensor.

readPressure() function returns the barometric pressure from the sensor.

readAltitude(SEALEVELPRESSURE_HPA) function calculates the altitude (in meters) from the specified atmospheric pressure (in hPa), and sea-level pressure (in hPa).

readHumidity() function returns the relative humidity from the sensor.

Step by Step instruction

  1. Do wiring.
  2. Open Arduino IDE.
  3. Plug your Adruino Uno board into your PC and select the correct board and com port.
  4. Find your BME280 I2C address. Each device has an I2C address that it uses to accept commands or send messages. Compile and upload the I2Cscannersketch to your Arduino board.
  5. Open the Serial Monitor at a baud rate of 115200. Arduino will scan the address range looking for a reply.  Even though the documentation said it was 0x77, this scanner can detect different (in our case 0x76). Adafruit_BME280 library has default I2C address 0x77 and if you are getting 0x76 you need to modify line of code in  bme280testsketch1: status = bme.begin(); to status = bme.begin(0x76);

  6. Verify and upload the bme280testsketch1 to your Adruino Uno board. 
  7. Open the Serial Monitor at a baud rate of 115200. You can see the readings from sensor now.

Summary

We have learnt how to get the pressure, temperature and humidity from BME280 sensor module with Arduino board.

Library:

  • All libraries attached on the begining of this project description.
  • Wire library included in your Arduino IDE.
  • Adafruit BME280 library included. Download, unzip  and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC. You can read more about it here.
  • Adafruit_Sensor library included. Download, unzip  and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC. You can read more about it here.

Sketch:

  • See attachments on the begining of this project description. 


Other projects of Acoptex.com
Medium Basics: Project 083w Sipeed Maixduino board - Using PlatformIO IDE of Acoptex.com in Sipeed Maixduino 08-08-2019
Medium Basics: Project 083e Sipeed Maixduino board - Uploading MaixPy of Acoptex.com in Sipeed Maixduino 04-08-2019
Medium Basics: Project 083f Sipeed Maixduino board - Using MycroPython of Acoptex.com in Sipeed Maixduino 04-08-2019

jobs.published_at
jobs.viewed