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 086k ESP8266 ESP-12E module, BME 280 - MicroPython

of Acoptex.com in ESP8266 ESP-12

Basics: Project 086k

Project name: ESP8266 ESP-12E module, BME 280 - MicroPython

Tags: Arduino, Arduino IDE, ESP8266 ESP-12E module, ESP, ESP8266, WI FI module, ESP-12E, LoLin NODEMCU V3, NODEMCU, BME280, temperature, humidity,pressure, BME280  sensor, micropython

Attachments: main.pyBME280.py 

In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):

1.ESP8266 ESP-12E module with micro USB cable 1 pc

2. Jumper cables F-M

3. Breadboard 1 pc

4. BME280 sensor module 1 pc

5. uPyCraft IDE (you can download and read more about it here)

General

We will learn how to use the BME280 sensor module with the ESP8266 ESP-12E module to get pressure, temperature and humidity readings using MicroPython firmware.

In order to program the ESP8266 ESP-12E module with MicroPython you need to:

  1. Install uPyCraft IDE or Thonny IDE in your PC;
  2. Upload MicroPython firmware to your ESP8266 ESP-12E module

Understanding the ESP8266 ESP-12E WI FI module (LoLin NODEMCU V3)

You can read more about it here.

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 

Signals and connections of the ESP8266 ESP-12E WI FI module (LoLin NODEMCU V3)

TX - transmit pin. GPIO pin

RX  - receive pin.  GPIO pin

3V3 (or 3V or 3.3V) - power supply pin (3-3.6V). 

GND ( or G) - ground pin.

RST - reset pin. Keep it on high (3.3V) for normal operation. Put it on 0V to reset the chip.

EN - Chip enable. Keep it on high (3.3V) for normal operation.

Vin - External power supply 5VDC.

D0-D8 - GPIO (General Purpose Input Output) pins 

D5-D8 - SPI interface

D1-D2– I²C/TWI Interface

SC (or CMD) - (Chip Select) - the pin that the master can use to enable and disable specific devices. GPIO pin

SO (or SDO) - Master In Slave Out (MISO) - SPI communication. The Slave line for sending data to the master. GPIO pin

SK (or CLK) - SCK (Serial Clock) - SPI communication.The clock pulses which synchronize data transmission generated by the master. GPIO pin

S1 (or SD1) - Master Out/Slave In (MOSI). SPI communication. The Master line for sending data to the peripherals. GPIO pin

S2 (or SD2) - GPIO pin

S3 (or SD3) - GPIO pin

VU (or VUSB) - external power 5VDC.

A0 - ADC output.

RSV - reserved

Wiring

BME280 sensor mudue Nodemcu 1.0

GND                 G (GND)

Vin                   3V3

SDA                 GPIO 4 (D2)

SCL                  GPIO 5 (D1)

Step by Step instruction

  1. Do wiring.
  2. Install uPyCraft IDE on your PC;
  3. Plug the ESP8266 ESP-12E module to your PC and wait for the drivers to install (or install manually any that might be required).
  4. ESP8266 ESP-12E module - Uploading MicroPython firmware.
  5. Open uPyCraft IDE. Double-click uPyCraft_V1.1.exe file. A new window opens with the uPyCraft IDE software.
  6. Go to Tools -> Board. If you are using ESP8266 ESP-12E module select esp8266.
  7. Go to Tools -> Serial and select your ESP8266 ESP-12E module COM port (in our case it’s COM6). If you don’t see the COM Port, you need to install the ESP32 CP210x USB to UART Bridge VCP Drivers , check your USB cable too (it should be data cable).
  8. You have established a serial communication with your board. The >>> should appear in the Shell window after a successful connection with your board.
  9. Press New file button to create a new file.
  10. Press Save file button to save the file in your PC. Input file name BME280.py and press ok button.
  11. Copy the following BME280.py to the Editor on the BME280.py file.

  12. Press Save file button to save the file in your PC. 
  13. Press Download and run button to upload the file to your ESP8266 ESP-12E module. The device directory should now load the BME280.py file. You should see a message download ok in the Shell window.
  14. Press New file button to create a new file.
  15. Press Save file button to save the file in your PC. Input file name main.py and press ok button.
  16. You should see a new tab with the main.py file.
  17. Copy the following main.py to the Editor on the main.py file.
  18. Press Save button to save the changes.
  19. Press Stop button to stop any script from running in your board.
  20. Press Download and run button to upload the file to your ESP8266 ESP-12E module. The device directory should now load the main.py file. Your ESP8266 ESP-12E module has three files - boot.py, BME280.py and main.py stored now. You should see a message download ok in the Shell window.
  21. Press the ESP8266 ESP-12E module on-board RST button to reboot it.
  22. The temperature, humidity and pressure will be printed into the shell every 5 seconds.

Code

First, we need to import the necessary libraries, including the BME280 module library. Set the I2C pins. In this case, we will be using the default I2C pins. In the while loop, create a BME280 object called bme with the I2C pins defined earlier. Reading temperature, humidity and pressure is as simple as using the temperature, humidity and pressure methods on the bme object. Finally, we print the readings on the shell. At the end, we add a delay for 5 seconds.

Summary

We have learnt how to use the BME280 sensor module with the ESP8266 ESP-12E module to get pressure, temperature and humidity readings using MicroPython firmware.

Libraries

  • All libraries attached on the begining of this project description.
  • BME280 MicroPython library. This library is not a part of the standard MicroPython library by default. You will need to upload the BME280.py to your ESP8266 ESP-12E module.

Sketch

  • See on the begining of this project


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