Pressure & Humidity Wireling Tutorial

This Wireling lets you measure Humidity, Pressure, Temperature, and the approximate Altitude all from the small BME280 sensor.
Technical Details
Bosch BME280 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 % rel. humidity, 300…1100 hPa
- Humidity sensor and pressure sensor can be independently enabled/ disabled
- Register and performance compatible with Bosch Sensortec BMP280 digital pressure sensor
- RoHS compliant, halogen-free, MSL1
- Pressure Sensor
- RMS Noise 0.2 Pa, Equiv. to 1.7 cm
- Offset temperature coefficient ±1.5 Pa/K, Equiv. to ±12.6 cm at 1 °C temperature change
- Humidity Sensor:
- Response time 1 s
- Accuracy tolerance ±3 % relative humidity
- Hysteresis ±1% relative humidity
TinyDuino Power Requirements
- Voltage: 3.0V - 5.5V
- Current:
- 1.8 µA @ 1 Hz humidity and temperature
- 2.8 µA @ 1 Hz pressure and temperature
- 3.6 µA @ 1 Hz humidity, pressure, and temperature
- 0.1 µA in sleep mode
Pins Used
- A5/SCL - I²C Serial Clock line
- A4/SDA - I²C Serial Data line
Dimensions
- 10mm x 10mm (.394 inches x .394 inches)
- Max Height (from the lower bottom of Wireling to upper top Wireling Connector): 3.70mm (0.15 inches)
- Weight: 1 gram (.04 ounces)
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 Pressure & Humidity Sensor Wireling and the included example Arduino sketch.
Wireling | Code | |
---|---|---|
Port 0 | Pressure & Humidity | 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 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 Pressure and Humidity 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
After you upload the program, you should see the values read from the sensor (Temperature, Pressure, Humidity, and Approximate Altitude)
Code
/*************************************************************************
* Pressure & Humidity Wireling Tutorial:
* This program prints the temperature(C), altitude, pressure(hPa), and
* humidity(%) readings from the BME280 sensor. Results will be printed
* to the Serial Monitor.
*
* Hardware by: TinyCircuits
* BME280 Library by: Adafruit
* Code by: Laveréna Wienclaw for TinyCircuits
*
* NOTE: Adafruit Sensor Library Modified: change device address from 0x77
* to 0x76 to work with TinyCircuits hardware
*
* Initiated: 11/29/2017
* Updated: 01/10/2020
************************************************************************/
// This library is used for communication with I2C devices, such as the BME280 board
#include <Wire.h>
#include <Wireling.h>
// These libraries are used to interface with the BME280 Sensor
#include "Adafruit_Sensor.h"
#include "Adafruit_BME280.h"
// Global Sensor Variables
#define SEALEVELPRESSURE_HPA (1013.25) // used to find approximate altitude
Adafruit_BME280 bme; // I2C
// Used to control how often sensor values are updated in the main loop()
unsigned long delayTime = 1000;
// 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() {
Wire.begin();
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("BME280 test"));
// Enable and Power Wirelings
Wireling.begin();
Wireling.selectPort(0);
// 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()) {
SerialMonitorInterface.println("Could not find a valid BME280 sensor, check wiring!"); // Printed to Serial Monitor
while (1); // loop forever, because the rest of the program means nothing without the sensor
}
}
// Forever looping the following logic
void loop() {
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.println();
}

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!