A Particle library for the Silicon Labs Si7021 Temperature and Humidity sensor
Wire the sensor to your Particle Photon:
Add the Si7021 library to your project and follow this simple example:
#include "Si7021.h"
Si7021 si7021;
float temperature, humidity;
void setup() {
if (si7021.begin()) {
Serial.println("Sensor initialized successfully");
}
}
void loop() {
humidity = si7021.readHumidity();
temperature = si7021.readLastTemperature();
Serial.printlnf("temperature: %.2fC\thumidity: %.2f%%", temperature, humidity);
delay(5000);
}
See the examples folder for more details.
In case you do not require all features, some modules can be disabled
and thus be removed from compilation. The most radical approach would be
to #define SI7021_TINY
as seen in examples/tiny .
Defining this before the library is included, will remove support for
reading device info and for using the sensor internal heater.
If this is too much, you can also go with SI7021_CUSTOM
, which, when
used standalone, equals the use of TINY. But with CUSTOM, you can
activate additional features with #defines.
// this will enable the deviceInfo() functionality
#define SI7021_FEATURE_DEVICEINFO
// this will enable the heater() functionality
#define SI7021_FEATURE_HEATER
// this will enable CRC checks
#define SI7021_FEATURE_CRC
Copyright 2018 Stefan Linke
Licensed under the MIT license