Thursday 20 August 2015

Arduino Weather Station

 

Overview


A quick rummage through eBay and you soon realise how many sensors types there are for the humble Arduino so in this project lets get to work with six interesting ones.  A weather station is the perfect scenario to combine data from all of these sensors and turn it into an interesting view of your surroundings.  I've captured the readings to an SD card but there's no reason why the data couldn't be sent via a network card, Wi-Fi to a remote location anywhere on Earth!


Here's a quick radar graph focusing in on the air around the Arduino during a 24 hours period, specifically studying its quality, humidity and temperature.

The five Keyes sensors (from left to right):



  • Ambient light
  • Air Temperature and humidity
  • Air pressure 
  • Air quality
  • Soil moisture

You could keep going with a rain drop sensor for example but after five sensors and an SD card you're going to run out of I/O pins on the Ardunio Nano and Uno, but if you want to keep expanding the Arduino Mega is your way forward.


Be autonomous...


You are going to need power and lots of it with all of those sensors, I've been using the EC Technology® 22400 mAh external battery which I bought from Amazon for £20 in July 2015.




Next you are going to need somewhere to keep it out of the rain, direct sunlight which really messes up you temperature readings, its proper name is a 'louvres' or 'Stevenson Screen'.





With all that information being captured you need to store it safely, I found the most reliable way is an SD card via the Arduino Shield which simply means you can add you prototype board on top, hence the three layers in the photo earlier.  The other reason to go for the shield is the real-time clock which you need to track the date / time when the readings are made.




To conserve power I didn't add an LCD screen but opted for a single LED based set of lights.  The green LED pulses on/off as the Arduino enters the sensor reading loop, if there is a problem (a bit like a try catch) then the red LED illuminates.  This way at a glance you can see if all is well or there is a problem.  To debug an issue such as a failed sensor the best way it to plug it into the computer and enable the serial.println debug command to see what the root cause is.




The Weather Station in action!

The source code ...

Good luck and here is the source code for the Weather Station project which you are free to download and use.

Any problems or a thank you leave a comment!

Friday 10 April 2015


Arduino Uno - Range Finder,  RF transmitter and receiver

The radio frequency in this project is 315 Mhz


Overview


The range finder sends out a sonic (ping) which bounces off a solid object, it then compares the time taken for the (echo) to be received.  All this hard work is taken care of by the HC SR04 ultrasonic module.  The transmitting Arduino reads the sensor every two seconds, then uses the VirtualWire library to encode the centimetre value and RF transmitter to broadcast the data at 315 Mhz.

The RF receiver on the second Aurdino is listening on the 315 Mhz channel and picks up the transmission which it then decodes and displays on the Liquid Crystal Display.

The 'clicking' on the video is RF interference from the transmitter!

Shopping list hardware

  • 2 * Arduino Uno
  • 1 * HC SR04 ultrasonic module (RF Transmitter and RF Receiver)
  • 1 * LCD
  • 2 * 10k ohm resisters


Aurdino software and libraries

  • Arduino Development Environment I'm using v1.6.3
  • VirtualWire to control the HC SR04 ultrasonic module
  • Liquid Crystal (this will already be in your Arduino Library folder)

Receiver circuit

See the official Arduino wiring diagram for the LCD, the only difference is that pin 8 is used instead of pin 11 (as 11 is needed for the receiver).  For more information on the HC SR04 see this very good overview page.

HC SR04 wiring
VCC to 5v
GND to Ground
Data to pin 11


Transmitter circuit




For the transmitter Audrino

#define trigPin 9
#define echoPin 8

#include <VirtualWire.h>

char strDistance[6];

void setup()
{
      // Initialize the IO and ISR
      vw_setup(2000); // Bits per sec
      
      Serial.begin (9600);
      pinMode(trigPin, OUTPUT);
      pinMode(echoPin, INPUT);
      
      send("Meter is ready");
}

void loop()

      long duration, distance;
    
      digitalWrite(trigPin, LOW); 
      delayMicroseconds(2); 
      digitalWrite(trigPin, HIGH);
      delayMicroseconds(10);
      digitalWrite(trigPin, LOW);
      
      duration = pulseIn(echoPin, HIGH);
      distance = (duration/2) / 29.1;
      
      if (distance >= 200 || distance <= 0){
        Serial.println("Out of range");
        send("Out of range");
      } else {
        Serial.print(distance);
        Serial.println(" cm");
        
        sprintf(strDistance, "%i cm", distance);
        send(strDistance);
      }
      delay(2000);
}

void send (char *message)
{
      vw_send((uint8_t *)message, strlen(message));
      vw_wait_tx(); // Wait until the whole message is gone
}



Sunday 5 April 2015

Arduino Uno, Laser, Morse Code, LCD and Humidity / Temperature Sensor


Simple Laser Communication Project


Overview

The temperature and humidity sensor sends its output to the first Ardunio Uno who creates the text which is displayed on the LCD.  The text is converted to Morse Code on the first Arduino and transmitted to the second Arduino using a red laser.

The second Arduino receives the laser light via a photosensitive resistor and decodes the received Morse Code into ASCII which it then sends both the original Morse Code and ASCII to the LCD.


  


Shopping list

Although this project looks complicated it's simply a number of smaller projects coupled together, if you're new to the Arduino take a look at 'Learning the basics'.


Hardware

  • 2 * Ardunio Uno
  • 1 * Laser Diode (Keyes KY008)
  • 1 * Photosensitive Resistor (Keyes KY018)
  • 1 * Temperature and Humidity Sensor (Keyes KY015)
  • 1 * Piezo buzzer (optional)
  • 1 * LCD 
  • 2 * 10K ohm resistors
  • 1 * 50 ohm resistor
  • 1 * 100 ohm resistor




Aurdino software and libraries



Receiver Circuit


Most of this circuit is devoted to wiring up the LCD.


















Transmitter Circuit

As a reminder the Arduino on the left in the video is responsible for reading the temperature sensor, created the text for the LCD, generating the Morse Code and transmitting through the laser.


For the Transmitting Arduino...

// Usage: morse( <pin number>, <speed WPM>, <1=beep, 0=PTT> )
//        sendmsg( "<text-to-send>" )

#include <Morse.h>
#include <dht11.h>
#define DHT11PIN 2

// Use pin 13 (built-in LED of Arduino 2009)
Morse morse(13, 8, 0);
dht11 DHT11;
String strMessage = "";

void setup()
{
    //Serial.begin(9600);
}

void loop()
{
      int chk = DHT11.read(DHT11PIN);

      Serial.print("Read sensor: ");
      switch (chk)
      {
        case 0: Serial.println("OK"); break;
        case -1: Serial.println("Checksum error"); break;
        case -2: Serial.println("Time out error"); break;
        default: Serial.println("Unknown error"); break;
      }

      // Use a . for a space as Morse Code does not have spaced!     
      strMessage = ".HUMIDITY." + String(DHT11.humidity) + ".PERCENT...TEMP.." + String(DHT11.temperature) + ".CELSIUS..";
  
      //Serial.print(strMessage);

      int intLength = strMessage.length() + 1;
      char charMessage[intLength];
      strMessage.toCharArray(charMessage, intLength);

      morse.sendmsg(charMessage);
     
      delay(30000);
}