Skip to content

Temp/Pres/Hum/VOC Wireling Tutorial

TinyCircuits BME680 Wireling product photo

This Wireling lets you measure Temperature, Pressure, Humidity, and Volatile Organic Compounds (VOCs) via the BME680. This Wireling sensor is an upgrade from the Pressure & Humidity Wireling that uses the BME680 to measure relative humidity, barometric pressure, ambient temperature and gas (VOC).

Technical Details

Bosch BME680 Sensor Specs

  • Digital interface I²C (up to 3.4 MHz) and SPI (3 and 4 wire, up to 10 MHz)
  • Operating range -40 - +85°C, 0-100 % r.H., 300-1100 hPa
  • Humidity, Pressure, Gas sensor can be independently enabled / disabled
  • RoHS compliant, halogen-free, MSL1

Pressure Sensor

  • RMS Noise 0.12 Pa, equiv. to 1.7 cm
  • Offset temperature coefficient ±1.3 Pa/K, equiv. to ±10.9 cm at 1 °C temperature change

Humidity Sensor

  • Response time 8 s
  • Accuracy tolerance ±3 % relative humidity
  • Hysteresis ±1.5% relative humidity

Gas Sensor

  • Response time < 1s (for new sensors)
  • Power consumption < 0.1mA in ultra-low power mode
  • Output data processing: direct index for air quality (IAQ) output

    TinyDuino Power Requirements

    • Voltage: 3.0V - 5.5V 
    • Current:
      • 2.1 µA @ 1 Hz humidity and temperature
      • 3.1 µA @ 1 Hz pressure and temperature
      • 3.7 µA @ 1 Hz humidity, pressure, and temperature
      • 0.15 µA in sleep mode

    Materials

    To interface with any TinyCircuits Arduino board, you will need the Arduino IDE and a Micro USB Cable

    There are multiple processor/adapter combinations that can be used with Wirelings. Use the following table to find the combination that works for you.

    Processor Adapter
    *TinyDuino and USB TinyShield Wireling Adapter TinyShield
    *TinyZero Wireling Adapter TinyShield
    *TinyScreen+ Wireling Adapter TinyShield
    WirelingZero N/A
    *RobotZero N/A
    Arduino Wireling Arduino Shield
    Raspberry Pi Wireling Pi Hat

    * These processors have a 32-pin connector and can have multiple Wireling Adapter TinyShields stacked to increase the number of Wireling ports up to a maximum of 32 total Wireling ports.

    In order to interface with Wirelings, you'll need the appropriate number of Wireling Cables and the Wireling.h Library (You can download this from GitHub as linked, or from the Library Manager in the Arduino IDE).

    You will also need the Temp/Pres/Hum/VOC Wireling and the included example Arduino sketch.

    Wireling Code
    Port 0 Temp/Pres/Hum/VOC Example Sketch

    Hardware Assembly

    Depending on the development system you choose, you will need to put together a TinyDuino stack using the 32-pin tan connectors, or you will just need to plug in your Wireling to Port 0 using a Wireling Cable. (You can change this port in the included Arduino Sketch using the Wireling.selectPort() function)

    NOTE: Be mindful when inserting Wireling Cables - the connector pins inside the 5-pin connectors on Wirelings can be bent when cables are inserted at an angle.


    Software Setup

    If you have not already done so, download the example sketch for the Temperature, Pressure, Humidity, and VOC Wireling (found above under Materials) and open it in the Arduino IDE. All the necessary library files for the program are included in the zipped folder.

    Make the correct Tools selections for your development board. If unsure, you can double check the Help page that mentions the Tools selections needed for any TinyCircuits processor.


    Upload Program

    Code
    /*************************************************************************
       BME680 Wireling Tutorial:
       Print the temperature(C), altitude, pressure(hPa), and humidity(%)
       readings the BME680 sensor is capable of reading
       Hardware by: TinyCircuits
       BME680 Library by: Adafruit
       Code by: Laveréna Wienclaw for TinyCircuits
       Initiated: Mon. 11/29/2017
       Updated: Tue. 07/31/2019
     ************************************************************************/
    
    // This library is used for communication with I2C devices
    #include <Wire.h>
    #include <Wireling.h>
    
    // These libraries are used to interface with the BME680 Sensor
    #include "Adafruit_Sensor.h"
    #include "Adafruit_BME680.h"
    
    // Global Sensor Variables
    #define SEALEVELPRESSURE_HPA (1013.25) // used to find approximate altitude 
    Adafruit_BME680 bme; // I2C
    
    // Used to control how often sensor values are updated in the main loop()
    unsigned long delayTime = 1000;
    const bool displayAlt = false; // if set to true, altitude will be displayed on the TinyScreen+ instead of gas 
    
    // Make Serial Monitor compatible for all TinyCircuits processors
    #if defined(ARDUINO_ARCH_AVR)
      #define SerialMonitorInterface Serial
    #elif defined(ARDUINO_ARCH_SAMD)
      #define SerialMonitorInterface SerialUSB
    #endif
    
    void setup() {
      SerialMonitorInterface.begin(9600); // Bandwidth for our communication
      // Print to Serial Monitor
      // You can pass flash-memory based strings to SerialMonitorInterface.print() by wrapping them with F().
      // This means you're using flash memory instead of RAM to print stuff
      SerialMonitorInterface.println(F("BME680 test"));
    
      Wire.begin();
      Wireling.begin();
      Wireling.selectPort(0); // The adapter board has 4 different ports (0-3),
    
      // If the bme sensor is not found, throw statement and stop program
      // If you end up here, check to make sure your value in selectPort() is correct!
      if (!bme.begin(0x76)) {
        SerialMonitorInterface.println("Could not find a valid BME680 sensor, check wiring!"); // Printed to Serial Monitor
        while (1); // loop forever, because the rest of the program means nothing without the sensor
      }
      // Set up oversampling and filter initialization
      bme.setTemperatureOversampling(BME680_OS_8X);
      bme.setHumidityOversampling(BME680_OS_2X);
      bme.setPressureOversampling(BME680_OS_4X);
      bme.setIIRFilterSize(BME680_FILTER_SIZE_3);
      bme.setGasHeater(320, 150); // 320*C for 150 ms
    
      SerialMonitorInterface.println("-- Default Test --");
      SerialMonitorInterface.println();
    }
    
    // Forever looping the following logic
    void loop() {
      if (! bme.performReading()) {
        SerialMonitorInterface.println("Failed to perform reading :(");
        return;
      }
      printValues(); // Print to serial monitor
      delay(delayTime); // How often values are updated and printed
    }
    
    // This function prints out the values from the sensor to the Serial Monitor
    void printValues() {
      SerialMonitorInterface.print("Temperature = ");
      SerialMonitorInterface.print(bme.readTemperature());
      SerialMonitorInterface.println(" *C");
    
      SerialMonitorInterface.print("Pressure = ");
      SerialMonitorInterface.print(bme.readPressure() / 100.0F);
      SerialMonitorInterface.println(" hPa");
    
      SerialMonitorInterface.print("Approx. Altitude = ");
      SerialMonitorInterface.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
      SerialMonitorInterface.println(" m");
    
      SerialMonitorInterface.print("Humidity = ");
      SerialMonitorInterface.print(bme.readHumidity());
      SerialMonitorInterface.println(" %");
    
      SerialMonitorInterface.print("Gas = ");
      SerialMonitorInterface.print(bme.gas_resistance / 1000.0);
      SerialMonitorInterface.println(" KOhms");
    
      SerialMonitorInterface.println();
    }
    

    After the code is successfully uploaded, open the Serial Monitor to view the sensor data being printed:

    Sensor Data


    Downloads


    Contact Us

    If you have any questions or feedback, feel free to email us or make a post on our forum. Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it.

    Thanks for making with us!