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:

Before connecting the project to the cloud, we'll test every sensors individually with a test sketch that simply uses the conventional Arduino part of the Yun. The first step in the code is to import the correct libraries:
#include "DHT.h"
#include <Wire.h>
#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:
Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085);

In the setup() function, we can initialise the BMP sensor:

In the loop() part of the sketch, we make the different measurements, for example humidity, temperature & light level:
// Measure the humidity
float humidity = dht.readHumidity();

// Measure light level
int lightLevel = analogRead(A0);

// Measure pressure & temperature from BMP sensor
sensors_event_t event;
float pressure = event.pressure;
These different measurements will then be printed on the Serial monitor. Of course, you can find the complete sketch on our GitHub repository for this project. You can now upload the sketch to the board & open the Serial monitor. This is what you should see:

If that works, it means all your hardware connections are correct, and you can move to the next part of the project.

This guide was first published on Mar 11, 2014. It was last updated on Mar 11, 2014.

This page (Connections) was last updated on Jun 16, 2021.

Text editor powered by tinymce.