For this project, you will of course need the Arduino Yun board. You will also need a DHT11 (or DHT22) sensor, along with a 4.7K resistor, for humidity measurements. For pressure & temperature measurements, I used a BMP085 sensor on a simple breakout board, but you can also use the newer Adafruit BMP180 sensor board, which works with the same library. For light levels measurements, I used a photocell with a 10K Ohm resistor. Finally, I used a breadboard and some male-male jumper wires.
On the software side, you will need the Arduino IDE in the latest version (in Beta when this article was written). You will also need the DHT library, the BMP085 or BMP180 library, and the unified sensor library. To install a library, simply put the folder in your /libraries/ folder of you main Arduino folder. This tutorial also assumes that your Arduino Yun is already connected to your WiFi network. If you need help with that, please follow the dedicated tutorials on the Arduino website.
You will also need a Google account for the rest of the project. If you don’t have one yet, please create one, for example by going on the Google Drive page.
The hardware connections for this project are actually quite simple: we have to connect the DHT11 sensor, and then the part responsible for the light level measurement with the photocell. First, connect the Arduino Yun +5V pin to the red rail on the breadboard, and the ground pin to the blue rail.
Then, connect pin number 1 of the DHT11 sensor to the red rail on the breadboard, and pin number 4 the blue rail. Also connect pin number 2 to pin number 8 of the Arduino Yun. To finish up with the DHT11 sensor, connect the 4.7k Ohm between pin number 1 and 2 of the sensor.
For the photocell, first place the cell in series with the 10k Ohm resistor on the breadboard. Then, connect the other end of the photocell to the red rail on the breadboard, and the other end of the resistor to the ground. Finally, connect the common pin to the Arduino Yun analog pin A0.
For the BMP085 or BMP180 sensor, connect the VIN pin to the +5V, GND to Ground, SCL to Arduino Yun pin number 3, and SDA pin to Arduino Yun pin number 2. The following picture summarises the hardware connection:
#include "DHT.h" #include <Wire.h> #include <Adafruit_Sensor.h> #include <Adafruit_BMP085_U.h>
#define DHTPIN 8 #define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE); Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085);
In the setup() function, we can initialise the BMP sensor:
bmp.begin()
// 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;
If that works, it means all your hardware connections are correct, and you can move to the next part of the project.
Text editor powered by tinymce.