Hardware Reference
In-Depth Information
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP085_U.h>
We need to define the pin & type of the DHT sensor:
#define DHTPIN 8
#define DHTTYPE DHT11
And create the instances for the DHT sensor & BMP sensor:
DHT dht (DHTPIN, DHTTYPE);
Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified( 10085 );
In the setup() function, we can initialize the BMP sensor:
bmp.begin()
In the loop() part of the sketch, we make the different measurements:
// Measure the humidity
float humidity = dht.readHumidity();
// Measure light level
int lightLevel = analogRead(A0);
// Measure pressure & temperature from BMP sensor
sensors_event_t event;
bmp.getEvent( & event);
float pressure = event.pressure;
These measurements will then be printed on the Serial monitor.
Note that all the code is available inside the GitHub repository of the topic:
https://github.com/openhomeautomation/iot-book
Search WWH ::




Custom Search