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);
}