In this project I’ve ported my BME280 driver implementation from the previous project (https://www.instructables.com/id/BME280-Weather-St...) to Arduino and built a Graphical User Interface that plots the received sensor values in real-time on a PC.
The sensor breakout is connected to the Arduino via I2C and data is then streamed to the PC over the board’s serial port. The GUI displays the measurements in real-time. This it's the easiest way to see the response time of the sensor. Furthermore you can use the sensor library for other projects. Also the GUI can be reused separately.
· Arduino Due
· BME280 breakout
· 4x jumper wires
· MicroUSB cable
· Arduino IDE (I’ve used v1.6.8)
· Processing v3
Step 1: Hardware
The BME280 from Bosch can measure temperature, pressure and humidity. It also features a-n integrated IIR filter. The temperature sensor has low noise, high resolution and can operate from -40 to 85°C. The pressure sensor is better than the BMP180 and has a noise of 0.2Pa (equiv. to 1.7cm). The humidity sensor has a fast response time and can measure humidity between 0 and 100% (at temperatures between 0 and 60°C). You can find more details about it and other usage areas in the datasheet: https://cdn-shop.adafruit.com/datasheets/BST-BME2...
This time I have used the Sparkfun BME280 breakout module (https://www.sparkfun.com/products/13676), but you should be able to use about any other breakout as long as it has the same sensor on it (eventually you would need to change the I2C address). Note that this breakout doesn’t have a logic level shifter on it, nor a voltage regulator, so be careful not to hook it up to 5V.
For this project I’ve used an Arduino Due mainly because of the fact that it works on 3.3V so it would be easier to interface with this sensor and not only (today most integrated circuits work on 3.3V). Also it has enough processing power to host any future project. More details about the board at https://www.arduino.cc/en/Main/ArduinoBoardDue
An Arduino Uno modified to work at 3.3V may also work although I haven’t tried yet.
Sensor | Arduino Due
SDA – PIN20(SDA)
SCL – PIN21(SCL)
GND – GND
3.3V – 3.3V
Step 2: Software
On the Arduino side, the software is split in several files and they are all in the same folder so that you don’t need to import any library into the Arduino IDE. Also there is an intermediate I2C module that tries to offer a more standard and abstract I2C API than the Arduino one.
The library is ported from the older project, and it’s still rather C than C++. It only offers functions, without classes, but this is fine as long as you do not interface two BME280 (with different addresses) sensors on the same MCU (and most probably you won’t). The advantage of this library, in my opinion, is that it’s optimized for higher speed and lower resource consumption. One of the improvements is that the I2C traffic is minimized and this should make a difference (in implementations without DMA) as I2C is one of the slowest interfaces.
The app just initializes the sensor and then performs a sensor read every 10ms and sends the data on the serial interface in this format: temperature, space, pressure, space, humidity, new line.
On the PC side we have a GUI made in Processing v3 that opens a serial port to receive the data from the Arduino, and initializes a callback function that splits the data stream in order to extract the individual parameters and pushes them intro a buffer. In the draw() loop I only plot the data and refresh the last received value (the blue labels). The app works, although sometimes fails to start because of untreated exceptions in the code and eventually other reasons. If problems occur, you can try starting the GUI while holding the reset button from the Arduino and releasing it after the GUI has started. Hopefully I will fix this in the future.
You can find the code for the Arduino app and for the GUI here: https://github.com/cosminp12/BME280-plotting-GUI
Step 3: Results
In the video you can see how the output is changing in real time as I am blowing in the sensor and warming it up. It’s interesting how fast the sensor can measure the humidity variation and also the resolution of the temperature. The humidity in my room was quite high as it was raining outside, but in lower humidity you can see a better response time for the humidity measurement.