Monday 12 August 2013

Arduino: DHT11 humidity sensor, HC-SR04 ultrasonic distance sensor


In this project two new sensors (DHT11 and HC-SR04) are used with arduino. In the Arduino programming loop following code is used:


//DHT11
float DHT11_humidity = 0.0;
float DHT11_temperature = 0.0;

int chk = DHT11.read(DHT11PIN);


if(chk == 0)//if chk is zero it works properly
{
     DHT11_humidity = (float)DHT11.humidity;
     DHT11_temperature = (float)DHT11.temperature;
}


lcd.setCursor(0, 0);
lcd.print("H%:");
lcd.print(DHT11_humidity);
lcd.print(" TC:");
lcd.print(DHT11_temperature);


//HC-SR04
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 >= 400 || distance <= 2)
{
   lcd.print(" Dcm: NA");
   lcd.print(" ");

else
{
   lcd.print(" Dcm: ");
  lcd.print(distance);
  lcd.print(" ");
}


DHT11 Humidity & Temperature Sensor

The DHT11 is a basic, digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal on the data pin (no analog input pins needed). DHT11 specifications are:
  • Power supply: 3.0 to 5.5V DC
  • Output signal: digital signal via single-bus
  • Operating range: humidity 20 to 90%RH, temperature 0 to 50℃
  • Interchangeability: fully interchangeable
  • Range of meauring humidity: 20 to 90%RH(050temperature compensation
  • Range of meauring temperature: 0 to +50℃
  • Accuracy of measuring humidity: ±5.0%RH
  • Accuracy of measuring temperature: ±2.0℃
  • Response time: <5s 


HC-SR04 Ultrasonic Distance Sensor
Ultrasonic ranging module HC-SR04 provides 2cm - 400cm non-contact measurement function, the ranging accuracy can reach to 3mm. The modules includes ultrasonic transmitters, receiver and control circuit. The basic principle of work:

(1) Using IO trigger for at least 10us high level signal,
(2) The Module automatically sends eight 40 kHz and detect whether there is a pulse signal back.
(3) IF the signal back, through high level , time of high output IO duration is the time from sending ultrasonic to returning.

16x2 LCD displays DHT11 measured humidity as % and temperature in degrees centigrade. Light value is mapped to between 0 and 255. Distance in cm measured by HC-SR04.

The arduino pins are as follows:
//Arduino pins used for LCD
LiquidCrystal lcd(12, 11, 7, 6, 5, 4);

//Arduino pin for DHT11
#define DHT11PIN 13

//Arduino pins for HC-SR04
#define trigPin 9
#define echoPin 2

//Arduino pin for photocell
int photocellPin = A0;

//Arduino pins used for LED RGB
const int red = 3;
const int green = 8;
const int blue = 10;

I also suggest you to read Professional Android Sensor Programming.

Wednesday 31 July 2013

Arduino: Photocell, thermistor, RGB LED, DC Motor

In this post, I will describe an arduino project to light an RGB LED using a photocell and to turn on a DC motor using a thermistor. Here's the picture of setup:


Equipments are:
 - Arduino UNO R3
 - 16x2 LCD
 - 10k potentiometer
 - Photocell
 - Thermistor
 - RGB LED
 - DC Motor
 - L293D H-bridge
 - 220 resistor x 3, 1k resistor x 2, 10k resistor
 - Switch
 - Breadboard
 - Jumper wires

Below picture is the Fritzing Diagram:


In the diagram there's no switch, it's optional to turn on/off the backlight of LCD.

The main idea is to use sensor values for controling other devices. For instance in this project, when the photocell value is between 0 and 60, RGB LED gives RED light, and green and blue for other lightlevels of photocell. Besides, when the temperature reading of thermistor is above 25 degrees C, dc motor begins to turn. Also this limit value of temperature can be sent by serial communication to arduino.


Arduino pin connections are as follows:

// Arduino pins used for LCD
LiquidCrystal lcd(12, 11, 7, 6, 5, 4);

int photocellPin = A0;
int thermistorPin = A1;

// Arduino pins used for LED RGB
const int red = 3;
const int green = 8;
const int blue = 10;

// Arduino pins used for H-bridge
const int motor1Pin = 9;    // H-bridge leg 1 (pin 2, 1A)
const int motor2Pin = 2;    // H-bridge leg 2 (pin 7, 2A)
const int enablePin = 13;    // H-bridge enable pin



Friday 26 July 2013

Android-Sensors-Arduino

I've collected various projects about Android and Arduino using together.
I also suggest you to read Professional Android Sensor Programming, a very well organized book on Android Sensors.

Android Arduino Communication through Modbus and RS485

A project on that consists of connecting an Android development board to one (or more) Arduino slave(s) using modbus protocol and rs485.


RS485 is a well known standard that has been widely used in the indus­trial con­text and in building automa­tion appli­ca­tions. It is a half-duplex, 2-wires, low noise bus that allows high speeds and remote devices connection (up to 1200 meters).
Furthermore, modbus is a serial communication protocol, developed for industrial applications, open and easy to deploy and maintain. 

Use your android phone sensors on the arduino 

In modern smartphones, there are a lot of useful sensors for an ingenious arduino project. I have a motorola DEFY, for example and it has (at least) 6 sensors :
- light sensor
- proximity sensor
- aGPS (assisted gps)
- compass/magnetometer
- accelerometer
- orientation sensor
This instructable's purpose is to get you started using these sensors from your arduino.

DIY Air Quality Sensing from HabitatMap and Sonoma Tech



AirCasting is a platform for recording, mapping, and sharing health and environmental data using Arduino and Android. It combines an Arduino with a set of sensors for air quality measurement; temperature, humidity, and carbon monoxide, nitrogen dioxide, and particulate matter. The system combines the sensors using an Arduino Uno and then sends the data to an Android app using Bluetooth.

SensorGraph using android, amarino and arduino

This tutorial is for novices who have never made any Android application or worked with Amarino. If you have never done any experiment with Android and Arduino, start with the this experiment.



Need the following components/equipments for SensorGraph experiment:
a. Android Smart Phone
b. Arduino Duemilanova ATmega 328
c. Eclipse IDE for Java EE Developers
d. Androidsdk
e. Amarino Toolkit
f. Bluetooth Modem
g. Potentiometer, Temperature Sensor, Light dependent resistor any other kinds of variable resistor.


Wednesday 24 July 2013

$9 ARDUINO Compatible STARTER KIT - Anyone can learn Electronics

I'm helping to make it happen for $9 ARDUINO Compatible STARTER KIT - Anyone can learn Electronics on indiegogo, so you do:


"Electronics can be great fun. Electronics are also a part of our every day life. Knowledge about electronics is vital for the future and is very important to learn and teach it starting from a young age as I did. We want to make the basic tools for learning electronics affordable to anyone, anywhere, by removing all the useless costs and profits." by Harold Timmis writer of following books:



I love Arduino Adventures: Escape from Gemini Station
It's a great book to learn and enjoy making arduino projects.

Tuesday 23 July 2013

Fantastic Arduino Projects Collection

I'm following this very well organized instructables site on Arduino Projects.
Visit and Enjoy: Arduino Projects






"The Arduino micrcontroller has a nearly limitless array of innovative applications for everything from robotics and lighting to games and gardening! It's a fun way to automate everything, enabling you to control simple devices or manage complex Halloween displays. The Instructables editors have chosen some of our best do-it-yourself Arduino technology projects to educate and inspire you to make great things with easily-available tools." by zazenery