Hardware Reference
In-Depth Information
3.3
Testing The Sensors
Before connecting the project to the cloud, we will test every sensors individually. To do so,
we will write a simple test sketch. This is the complete code for this part:
// Include required libraries
#include "DHT.h"
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP085_U.h>
// Variables
int
lightLevel;
float
humidity;
float
temperature;
unsigned long
time;
// DHT11 sensor pins
#define DHTPIN 8
#define DHTTYPE DHT11
// DHT & BMP instances
DHT
dht
(DHTPIN, DHTTYPE);
Adafruit_BMP085_Unified bmp
=
Adafruit_BMP085_Unified(
10085
);
void
setup
(
void
)
{
// Initialize DHT sensor
dht.begin();
// Init serial
Serial.begin(
115200
);
// Initialise the sensor
if
(
!
bmp.begin())
{
Serial.print(
"Ooops, no BMP085 detected ... Check your wiring or I2C
ADDR!"
);
while
(
1
);
}
}