1.5K
This was an interesting little 3 in 1 sensor module which has the following sensors fitted
The HTU21D is a low-cost, easy to use, highly accurate, digital humidity and temperature sensor.
The BMP180 is the new digital barometric pressure sensor of Bosch Sensortec.
BH1750FVI is an digital Ambient Light Sensor IC for I2C bus interface.
Lets look at some code examples
Code
HTU21D example
[codesyntax lang=”cpp”]
#include <Wire.h> #include <SHT2x.h> void setup() { Wire.begin(); Serial.begin(9600); } void loop() { Serial.print("Humidity(%RH): "); Serial.print(SHT2x.GetHumidity()); Serial.print(" Temperature(C): "); Serial.println(SHT2x.GetTemperature()); delay(1000); }
[/codesyntax]
BH1750FVI example
[codesyntax lang=”cpp”]
#include <Wire.h> #include <BH1750.h> BH1750 lightMeter; void setup(){ Serial.begin(9600); lightMeter.begin(); Serial.println("Running..."); } void loop() { uint16_t lux = lightMeter.readLightLevel(); Serial.print("Light: "); Serial.print(lux); Serial.println(" lx"); delay(1000); }
[/codesyntax]
BMP180 example
[codesyntax lang=”cpp”]
#include <Wire.h> #include <Adafruit_BMP085.h> Adafruit_BMP085 bmp; void setup() { Serial.begin(9600); if (!bmp.begin()) { Serial.println("Could not find a valid BMP085 sensor, check wiring!"); while (1) {} } } void loop() { Serial.print("Temperature = "); Serial.print(bmp.readTemperature()); Serial.println(" *C"); Serial.print("Pressure = "); Serial.print(bmp.readPressure()); Serial.println(" Pa"); Serial.print("Altitude = "); Serial.print(bmp.readAltitude()); Serial.println(" meters"); Serial.print("Pressure at sealevel (calculated) = "); Serial.print(bmp.readSealevelPressure()); Serial.println(" Pa"); Serial.print("Real altitude = "); Serial.print(bmp.readAltitude(101500)); Serial.println(" meters"); Serial.println(); delay(500); }
[/codesyntax]
Links
HTU21D+BMP180+BH1750FVI temperature and humidity pressure light sensor three in one