Connect the BME280 sensor to your NodeMCU

To connect the BME280 sensor (I2C device) directly to the NodeMCU you only need four wires. Or you can use a solder-less breadboard socket.

NodeMCU v3 and BME280 sensor

Install esp8266 package to the Arduino IDE

Good news is that you can use your favorite Arduino IDE (1.6.4 and higher) to develop this project. You just have to add ESP8266 board: click to the File -> Preferences and copy: http://arduino.esp8266.com/stable/package_esp8266com_index.json to the "Additional Boards Manager URLs" and click OK.

Set Additional Boards Manager URLs

After that go to the Tools -> Board -> Boards Manager and install the esp8266.

install ESP8266 package

And finally select NodeMCU board:

Select NodeMCU 1.0 board

Right now you are ready to verify that you are able to communicate with the NodeMCU:

void setup() { Serial.begin(9600); Serial.println("NodeMCU test"); } void loop() { Serial.println("NodeMCU test"); delay(1000); }

Read data from BME280 sensor

First of all we have to determine sensor I2C address. I recommend to you use I2cScanner or you can just guess it because there are only two options 0x76 or 0x77.

Now you are ready to test reading sensor data. Click to the File -> Examples -> Adafruit BME280 Library -> bme280test. Default I2C address is 0x77 so if your device has the address 0x76 you have to add it:

44: status = bme.begin(0x76);

Now just upload it and after that click to the Serial Monitor. You should see something like this.

Reading data from BME280 sensor

Data storing and visualization

Congratulations - you have successfully read data from BME280 sensor. You can find on the internet many similar tutorials how to connect different sensors to the NodeMCU. My goal is to have real-time monitoring with a long history that I can access from anywhere. I would like to have a private dashboard that I can share with my friends and I do not want pay more than 5€/month. I spent many hours by finding optimal solution and I realized that only time-series database can properly solve this use-case. I decided for the best one InfluxdDB. As visualization tool I used Grafana - the same tool that SpaceX company uses. Generally you have two options:

Buy public IP address and install/configure InfluxDB and Grafana on your own (Pi) server

Buy virtual machine and install/configure Grafana and InfluxDB.

Both options are expensive, performance is not good and proper secure configuration is not easy. I found out new start-up Corlysis that solve this issues. It is affordable InfluxDB and Grafana hosting for your cool projects.

Sending sensor data to the time-series database

Create Corlysis account and by one click create new InfluxDB database. If you have free account your data are stored only for two weeks.

Corlysis app - Create new time-series database

Copy the code that is provided bellow to your Arduino IDE and update those lines:

// Wi-Fi settings const char* ssid = "YOUR-SSID"; const char* password = "YOUR-PASSWORD"; // Sensor settings const uint8_t sensor_address = 0x76; // Corlysis Setting - click to the database to get those info const char* db_name = "YOUR-DB_NAME"; const char* db_password = "YOUR-DB-PASSWORD"; const unsigned long delayTimeMs = 10000;

Upload that code to the NodeMCU and that is all. Right now you are sending data from your sensor to the time-series database InfluxDB by HTTPS POST. You can also easily update this script for different sensors.

Visualize sensor data

We have bme280 data in our database and every 10 seconds new ones are coming. Go to the Corlysis app and click to the Grafana in the top menu. Your database is pre-configured as the data source so you just click to create new dashboard and new graph and select your measurement and field name to see e.g. temperature graph. I recommend to you to see this video:

Using Grafana to visualize bme280 data

Now you can enjoy your amazing interactive graphs from anywhere.