Ks0083 keyestudio New sensor kit with Uno: Difference between revisions

From Keyestudio Wiki
Jump to navigation Jump to search
Line 467: Line 467:
     }
     }
}
}
</pre>
=== '''Project 11: DHT11 Temperature and Humidity Sensor  '''===
<br>[[File:ks0068 30-1.png|500px|frameless|thumb]]<br>
'''Introduction:'''<br>
This DHT11 Temperature and Humidity Sensor features calibrated digital signal output with the temperature and humidity sensor complex. Its technology ensures high reliability and excellent long-term stability. A high-performance 8-bit microcontroller is connected. This sensor includes a resistive element and a sense of wet NTC temperature measuring devices. It has excellent quality, fast response, anti-interference ability and high cost performance advantages.<br>
Each DHT11 sensor features extremely accurate calibration data of humidity calibration chamber. The calibration coefficients stored in the OTP program memory, internal sensors detect signals in the process, and we should call these calibration coefficients. The single-wire serial interface system is integrated to make it quick and easy. Qualities of small size, low power, and 20-meter signal transmission distance make it a wide applied application and even the most demanding one. Convenient connection, special packages can be provided according to users need.<br>
'''Specification:'''<br>
*Supply Voltage: +5 V
*Temperature range: 0-50 °C error of ± 2 °C
*Humidity: 20-90% RH ± 5% RH error
*Interface: Digital
*Size: 30*20mm
*Weight: 4g
'''Connection Diagram:'''<br>
<br>[[File:ks0068 30-2.png|500px|frameless|thumb]]<br>
'''Sample Code:'''<br>
<pre>
*****************************************************************************
Please download the DHT11Lib firstly.Or,see the website
#include <dht11.h>
dht11 DHT;
#define DHT11_PIN 4
 
void setup(){
  Serial.begin(9600);
  Serial.println("DHT TEST PROGRAM ");
  Serial.print("LIBRARY VERSION: ");
  Serial.println(DHT11LIB_VERSION);
  Serial.println();
  Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
}
 
void loop(){
  int chk;
  Serial.print("DHT11, \t");
  chk = DHT.read(DHT11_PIN);    // READ DATA
  switch (chk){
    case DHTLIB_OK: 
                Serial.print("OK,\t");
                break;
    case DHTLIB_ERROR_CHECKSUM:
                Serial.print("Checksum error,\t");
                break;
    case DHTLIB_ERROR_TIMEOUT:
                Serial.print("Time out error,\t");
                break;
    default:
                Serial.print("Unknown error,\t");
                break;
  }
// DISPLAT DATA
  Serial.print(DHT.humidity,1);
  Serial.print(",\t");
  Serial.println(DHT.temperature,1);
 
  delay(1000);
}
*******************************************************************************
</pre>
=== '''Project 12: Analog Sound Sensor '''===
<br>[[File:ks0068 7-1.png|500px|frameless|thumb]]<br>
'''Introduction:'''<br>
Analog Sound Sensor is typically used in detecting the loudness in ambient environment. The Arduino can collect its output signal by imitating the input interface. You can use it to make some interesting interactive works such as a voice operated switch.<br>
'''Specification:'''<br>
*Supply Voltage: 3.3V to 5V
*Detecting sound intensity
*Interface: Analog
*Size: 30*20mm
*Weight: 4g
'''Connection Diagram:'''<br>
<br>[[File:ks0068 7-2.png|500px|frameless|thumb]]<br>
'''Sample Code:'''<br>
<pre>
*****************************************************************************
void setup()
{
  Serial.begin(9600); // open serial port, set the baud rate to 9600 bps
}
void loop()
{
      int val;
      val=analogRead(0);  //connect mic sensor to Analog 0
      Serial.println(val,DEC);//print the sound value to serial       
      delay(100);
}
*******************************************************************************
</pre>
=== '''Project 13: Flame Sensor '''===
<br>[[File:ks0068 20-1.png|500px|frameless|thumb]]<br>
'''Introduction:'''<br>
This flame sensor can be used to detect fire or other lights whose wavelength stands at 760 nm ~ 1100 nm. In the fire-fighting robot game, the flame plays an important role in the probe, which can be used as the robot's eyes to find fire source. <br>
'''Specification:'''<br>
*Supply Voltage: 3.3V to 5V
*Detection range: 20cm (4.8V) ~ 100cm (1V)
*Rang of Spectral Bandwidth: 760nm to 1100nm
*Operating temperature: -25℃to 85℃
*Interface: digital
*Size: 44*16.7mm
*Weight: 4g
'''Connection Diagram:'''<br>
<br>[[File:ks0068 20-2.png|500px|frameless|thumb]]<br>
'''Sample Code:'''<br>
<pre>
*****************************************************************************
const int flamePin = 2;    // the number of the flame pin
const int ledPin =  13;      // the number of the LED pin
// variables will change:
int State = 0;        // variable for reading status
void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);     
  // initialize the pushbutton pin as an input:
  pinMode(flamePin, INPUT);   
}
void loop(){
  // read the state of the value:
State = digitalRead(flamePin);
  if (State == HIGH) {   
    // turn LED on:   
    digitalWrite(ledPin, HIGH); 
  }
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
}
*******************************************************************************
</pre>
=== '''Project 14: DS3231 Clock Module '''===
<br>[[File:ks0068 35-1.png|500px|frameless|thumb]]<br>
'''Introduction:'''<br>
DS3231 is equipped with integrated TCXO and crystal, which makes it a cost-effective I2C real time clock with high precision. The device carries a battery input, so if you disconnect the main power supply, it can still maintain accurate timing. The integrated oscillator ensures the long-term accuracy of the device and reduces the number of components. DS3231 provides both commercial and industrial temperature range and supports 16 pins small-outline package (300mil). The module itself can adapt to the system of 3.3V and 5V without level switch, which is quite convenient! <br>
'''Specification:'''<br>
*Temperature range: -40 to +85; Timing accuracy : ± 5ppm (±0.432 seconds / day)
*Provide battery backup for continuous timing
*Low power consumption
*Device package and function compatible with DS3231
*Complete clock calendar function contains seconds and minutes, hour, week, date, month, and year timing and provides leap year compensation until 2100.
*Two calendar clock
*Output: 1Hz and 32.768kHz
*Reset output and Input Debounce of Pushbutton
*High speed  (400kHz), I2C serial bus
*Supply voltage: +3.3V to +5.5V
*Digital temperature sensor with a precision of±3℃
*Working temperature: -40 ~ C to +85 ~ C
*16 pins Small Outline Package (300mil)
*Certified by American Association of Underwriters Laboratories (UL)
*Size: 30*20mm
*Weight: 4g
'''Connection Diagram:'''<br>
This module adopts the IIC test method, so we only need to connect ‘SDA’ to Arduino A4, ‘SCL’ to A5, ‘+’ to VCC and ‘-’ to GND as follows:<br>
<br>[[File:ks0068 35-2.png|500px|frameless|thumb]]<br>
'''Sample Code:'''<br>
<pre>
*****************************************************************************
#include <Wire.h>
#include "DS3231.h"
DS3231 RTC; //Create the DS3231 object
char weekDay[][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
//year, month, date, hour, min, sec and week-day(starts from 0 and goes to 6)
//writing any non-existent time-data may interfere with normal operation of the RTC.
//Take care of week-day also.
DateTime dt(2011, 11, 10, 15, 18, 0, 5);//open the series port and you can check time here or make a change to the time as needed.
void setup ()
{  Serial.begin(57600);//set baud rate to 57600
    Wire.begin();
    RTC.begin();
    RTC.adjust(dt); //Adjust date-time as defined 'dt' above
}
void loop ()
DateTime now = RTC.now(); //get the current date-time
    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.date(), DEC);
    Serial.print(' ');
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();
    Serial.print(weekDay[now.dayOfWeek()]);
    Serial.println();
    delay(1000);
}
*******************************************************************************
</pre>
'''results:'''<br>
Before compiling the code, you’d better put  DS3231 library  under file into Arduino catalogue,. When the above steps are done, you can upload the code to arduino and open the series monitor and get following results: <br>
<br>[[File:ks0068 35-3.png|500px|frameless|thumb]]<br>
=== '''Project 15: Analog Gas Sensor '''===
<br>[[File:ks0068 22-1.png|500px|frameless|thumb]]<br>
'''Introduction:'''<br>
This analog gas sensor - MQ2 is used in gas leakage detecting equipment in consumer electronics and industrial markets. This sensor is suitable for detecting LPG, I-butane, propane, methane, alcohol, Hydrogen and smoke. It has high sensitivity and quick response. In addition, the sensitivity can be adjusted by the potentiometer.  <br>
'''Specification:'''<br>
*Power supply: 5V
*Interface type: Analog
*Wide detecting scope
*Quick response and High sensitivity
*Simple drive circuit
*Stable and long lifespan
*Size: 49.7*20mm
*Weight: 8g
'''Connection Diagram:'''<br>
<br>[[File:ks0068 22-2.png|500px|frameless|thumb]]<br>
'''Sample Code:'''<br>
<pre>
*****************************************************************************
///Arduino Sample Code
void setup()
{
  Serial.begin(9600); //Set serial baud rate to 9600 bps
}
void loop()
{
int val;
val=analogRead(0);//Read Gas value from analog 0
Serial.println(val,DEC);//Print the value to serial port
delay(100);
}
*******************************************************************************
</pre>
=== '''Project 16: Analog Alcohol Sensor '''===
<br>[[File:ks0068 23-1.png|500px|frameless|thumb]]<br>
'''Introduction:'''<br>
This analog gas sensor - MQ3 is suitable for detecting alcohol. It can be used in a Breath analyzer. Also it has high sensitivity to alcohol and low sensitivity to Benzine. The sensitivity can be adjusted by the potentiometer.  <br>
'''Specification:'''<br>
*Power supply: 5V
*Interface type: Analog
*Quick response and High sensitivity
Simple drive circuit
*Stable and long service life
*Size: 49.7*20mm
*Weight: 6g
'''Connection Diagram:'''<br>
<br>[[File:ks0068 23-2.png|500px|frameless|thumb]]<br>
'''Sample Code:'''<br>
<pre>
*****************************************************************************
///Arduino Sample Code
void setup()
{
  Serial.begin(9600); //Set serial baud rate to 9600 bps
}
void loop()
{
int val;
val=analogRead(0);//Read Gas value from analog 0
Serial.println(val,DEC);//Print the value to serial port
delay(100);
}
*******************************************************************************
</pre>
</pre>

Revision as of 12:02, 7 October 2016

keyestudio New sensor kit with Uno


thumb
Sensor kit for Arduino
Based on open-source hardware
30 various sensors in one box
For you to make interesting projects

Summary

This is an Arduino sensor learning kit developed by Keyes. We bring together 30 basic sensors and modules, aiming for the convenience of its learning for starters. Inside this box, there are digital and analog sensors and also some special modules such as buzzer, ultrasonic, acceleration modules etc. For each module, there is clear connection diagram and sample code. So even if you are totally new at this, you can get started easily.
The sample codes for this sensor kit are based on ARDUINO because it's open source and easy. And if you are good at this, you can also apply this kit to other MCU development platform, such as 51, STM32, Raspberries Pi. The working principle is pretty much the same.
Now, let us embrace this fascinating world of ARDUINO and learn together!


Kit list

1. Piranha LED Module
2. Digital white LED module
3. Passive Buzzer module
4. Hall Magnetic Sensor
5. LM35 Temperature Sensor
6. 18B20 Temperature Sensor
7. Digital Tilt Sensor
8. Photocell sensor
9. Digital Push Button
10. Capacitive Touch Sensor
11. DHT11 Temperature and Humidity Sensor
12. Analog Sound Sensor
13. Flame Sensor
14. 3231 Clock Module
15. MQ-2 Analog Gas Sensor
16. MQ-3 Analog Alcohol Sensor
17. Water sensor
18. Soil humidity sensor
19. Infrared Obstacle Avoidance Sensor
20. PIR Motion Sensor
21. Joystick Module
22. photo interrupter module
23. 5V Relay Module
24. ADXL345 Three Axis Acceleration Module
25. Rotary Encoder module
26. Analog Rotation Sensor
27. HC-SR04 Ultrasonic Sensor
28. Pulse Rate Monitor
29. Reed Switch Module
30. TEMT6000 ambient light sensor


Project details

Project 1: Piranha LED Module


thumb

Introduction:
This is a special LED module. When you connect it to ARDUINO development board, after program, it can emit beautiful light. Of course, you can also control it using PWM. It will be like fireflies at night. Isn’t cool? We can also combine it with other sensors to do various interesting interactive experiments.

Specifications:
Module type: digital
Working voltage: 5v
Distance between pins: 2.54mm
Size: 30*20mm
Weight: 3g

Connection Diagram:

thumb

Sample Code:

int led = 3; 
void setup()
{
  pinMode(led, OUTPUT);     //Set Pin3 as output
}
void loop()
{      digitalWrite(led, HIGH);   //Turn off led
          delay(2000);
          digitalWrite(led, LOW);    //Turn on led
          delay(2000);
}


Project 2: Digital white LED module


thumb

Introduction:
This LED light module has a shiny color, ideal for Arduino starters. It can be easily connected to IO/Sensor shield.

Specification:
Type: Digital
PH2.54 socket
White LED light module
Enables interaction with light-related works
Size: 30*20mm
Weight: 3g

Connection Diagram:

thumb

Sample Code:

int led = 3;
void setup()
{
 pinMode(led, OUTPUT);     //Set Pin3 as output
}
void loop()
{
         digitalWrite(led, HIGH);   //Turn on led
         delay(2000);
         digitalWrite(led, LOW);    //Turn off led
         delay(2000);
}


Project 3: Passive Buzzer module


thumb

Introduction:
We can use Arduino to make many interactive works of which the most commonly seen is acoustic-optic display. All the previous experiment has something to do with LED. However, the circuit in this experiment can produce sound. Normally, the experiment is done with a buzzer or a speaker while buzzer is simpler and easier to use. The buzzer we introduced here is a passive buzzer. It cannot be actuated by itself, but by external pulse frequencies. Different frequencies produce different sounds. We can use Arduino to code the melody of a song, which is actually quite fun and simple.

Specification:
Working voltage: 3.3-5v
Interface type: digital
Size: 30*20mm
Weight: 4g

Connection Diagram:

thumb

Sample Code:

int buzzer=8;//set digital IO pin of the buzzer
void setup() 
{ 
pinMode(buzzer,OUTPUT);// set digital IO pin pattern, OUTPUT to be output 
} 
void loop() 
{ unsigned char i,j;//define variable
while(1) 
{ for(i=0;i<80;i++)// output a frequency sound
{ digitalWrite(buzzer,HIGH);// sound
delay(1);//delay1ms 
digitalWrite(buzzer,LOW);//not sound
delay(1);//ms delay 
} 
for(i=0;i<100;i++)// output a frequency sound
{ 
digitalWrite(buzzer,HIGH);// sound
digitalWrite(buzzer,LOW);//not sound
delay(2);//2ms delay 
} } } 

After downloading the program, buzzer experiment will been finished.


Project 4: Hall Magnetic Sensor


thumb

Introduction:
This is a Magnetic Induction Sensor. It senses the magnetic materials within a detection range up to 3cm. The detection range and the strength of the magnetic field are proportional. The output is digital on/off. This sensor uses the SFE Reed Switch - Magnetic Field Sensor.

Specification:
Sensing magnetic materials
Detection range: up to 3cm
Output: digital on/off
Detection range and magnetic field strength are proportional
Size: 30*20mm
Weight: 3g

Connection Diagram:

thumb

Sample Code:

int ledPin = 13;                // choose the pin for the LED
int inputPin = 3;               // Connect sensor to input pin 3 
int val = 0;                    // variable for reading the pin status
 
void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare pushbutton as input
}
 
void loop(){
  val = digitalRead(inputPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, LOW);  // turn LED OFF
  } else {
    digitalWrite(ledPin, HIGH); // turn LED ON
  }
}


Project 5: LM35 Linear Temperature Sensor


thumb

Introduction:
LM35 Linear Temperature Sensor is based on semiconductor LM35 temperature sensor. It can be used to detect ambient air temperature. This sensor offers a functional range among 0 degree Celsius to 100 degree Celsius. Sensitivity is 10mV per degree Celsius. The output voltage is proportional to the temperature.
This sensor is commonly used as a temperature measurement sensor. It includes thermocouples, platinum resistance, and thermal resistance and temperature semiconductor chips. The chip is commonly used in high temperature measurement thermocouples. Platinum resistance temperature sensor is used in the measurement of 800 degrees Celsius, while the thermal resistance and semiconductor temperature sensor is suitable for measuring the temperature of 100-200 degrees or below, in which the application of a simple semiconductor temperature sensor is good in linearity and high in sensitivity. The LM35 linear temperature sensor and sensor-specific Arduino shield can be easily combined.

Specification:
Based on the semiconductor LM35 temperature sensor
Can be used to detect ambient air temperature
Sensitivity: 10mV per degree Celcius
Functional range: 0 degree Celsius to 100 degree Celsius
Size: 30*20mm
Weight: 3g

Connection Diagram:

thumb

Sample Code:

void setup()
{
    Serial.begin(9600);//Set Baud Rate to 9600 bps
}
 void loop()
{ 
    int val;
    int dat;
    val=analogRead(0);//Connect LM35 on Analog 0
    dat=(500 * val) /1024;;
    Serial.print("Temp:"); //Display the temperature on Serial monitor
    Serial.print(dat);
    Serial.println("C");
    delay(500);
}


Project 6: 18B20 Temperature Sensor


thumb

Introduction:
DS18B20 is a digital temperature sensor from DALLAS U.S. It can be used to quantify environmental temperature testing.
The temperature range is -55 ~ +125 ℃, inherent temperature resolution 0.5 ℃. It also support multi-point mesh networking. Three DS18B20 can be deployed on three lines to achieve multi-point temperature measurement. It has a 9-12 bit serial output.

Specification:
Supply Voltage: 3.3V to 5V
Temperature range: -55 °C ~ +125 °C
Interface: Digital
Size: 30*20mm
Weight: 3g

Connection Diagram:

thumb

Sample Code:
http://www.pjrc.com/teensy/arduino_libraries/OneWire.zip

#include <OneWire.h>
 int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2
 //Temperature chip i/o
OneWire ds(DS18S20_Pin);  // on digital pin 2
 void setup(void) {
  Serial.begin(9600);
}
 void loop(void) {
  float temperature = getTemp();
  Serial.println(temperature);
   
  delay(100); //just here to slow down the output so it is easier to read
   
}
 
float getTemp(){
  //returns the temperature from one DS18S20 in DEG Celsius
 
  byte data[12];
  byte addr[8];
 
  if ( !ds.search(addr)) {
      //no more sensors on chain, reset search
      ds.reset_search();
      return -1000;
  }
 
  if ( OneWire::crc8( addr, 7) != addr[7]) {
      Serial.println("CRC is not valid!");
      return -1000;
  }
 
  if ( addr[0] != 0x10 && addr[0] != 0x28) {
      Serial.print("Device is not recognized");
      return -1000;
  }
 
  ds.reset();
  ds.select(addr);
  ds.write(0x44,1); // start conversion, with parasite power on at the end
 
  byte present = ds.reset();
  ds.select(addr);    
  ds.write(0xBE); // Read Scratchpad
 
   
  for (int i = 0; i < 9; i++) { // we need 9 bytes
    data[i] = ds.read();
  }
  ds.reset_search();
   
  byte MSB = data[1];
  byte LSB = data[0];
 
  float tempRead = ((MSB << 8) | LSB); //using two's compliment
  float TemperatureSum = tempRead / 16;
   
  return TemperatureSum;
   
}


Project 7: Digital Tilt Sensor


thumb

Introduction:
Tilt Sensor is a digital tilt switch. It can be used as a simple tilt sensor. Simplly plug it to our IO/Sensor shield; you can make amazing interactive projects. With dedicated sensor shield and Arduino, you can achieve interesting and interactive work.

Specification:
Supply Voltage: 3.3V to 5V
Interface: Digital
Size: 30*20mm
Weight: 3g

Connection Diagram:

thumb

Sample Code:

int ledPin = 13;                // Connect LED to pin 13
int switcher = 3;                 // Connect Tilt sensor to Pin3
 
void setup()
{
  pinMode(ledPin, OUTPUT);      // Set digital pin 13 to output mode
  pinMode(switcher, INPUT);       // Set digital pin 3 to input mode
}
void loop()
{
     
   if(digitalRead(switcher)==HIGH) //Read sensor value
     { 
        digitalWrite(ledPin, HIGH);   // Turn on LED when the sensor is tilted
     }
   else
     {
        digitalWrite(ledPin, LOW);    // Turn off LED when the sensor is not triggered
     }
}

Project 8: Photocell sensor


thumb

Introduction:
Photocell is commonly seen in our daily life and is mainly used in intelligent switch, also in common electronic design. To make it easier and more effective, we supply corresponding modules.
Photocell is a semiconductor. It has features of high sensitivity, quick response, spectral characteristic, and R-value consistence, maintaining high stability and reliability in environment extremes such as high temperature, high humidity. It’s widely used in automatic control switch fields like cameras, garden solar lights, lawn lamps, money detectors, quartz clocks, music cups, gift boxes, mini night lights, sound and light control switches, etc.

Specification:
Interface type: analog
Working voltage: 5V
Size: 30*20mm
Weight: 3g

Connection Diagram:

thumb

Sample Code:

int sensorPin =A0 ; 
int value = 0; 
void setup() 
{
 Serial.begin(9600); } 

void loop() 
{
 value = analogRead(sensorPin); 
Serial.println(value, DEC); 

delay(50); }


Project 9: Digital Push Button


thumb

Introduction:
This is a basic application module. You can simply plug it into an IO shield to have your first taste of Arduino.
Advantages:
Wide voltage range from 3.3V to 5V
Standard assembling structure (two 3mm diameter holes with multiple of 5mm as distance from center)
Easily recognizable interfaces of sensors ("A" for analog and "D" for digital)
Icons illustrate sensor function clearly
High quality connector
Immersion gold surface

Specification:
Supply Voltage: 3.3V to 5V
Easy to 'plug and operate'
Large button keypad and high-quality first-class cap
Achieve interesting and interactive work
Interface: Digital
Size: 30*20mm
Weight: 4g

Connection Diagram:

thumb

Sample Code:

/* # When you push the digital button, the Led 13 on the board will turn on. Otherwise,the led turns off.
*/
int ledPin = 13;                // choose the pin for the LED
int inputPin = 3;               // Connect sensor to input pin 3 
void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare pushbutton as input
}
void loop(){
  int val = digitalRead(inputPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, LOW);  // turn LED OFF
  } else {
    digitalWrite(ledPin, HIGH); // turn LED ON
  }
}


Project 10: Capacitive Touch Sensor


thumb

Introduction:
Are you tired of clicking mechanic button? Well, try our capacitive touch sensor. We can find touch sensors mostly on electronic device. So upgrade your Arduino project with our new version touch sensor and make it cool!!
This little sensor can "feel" people and metal touch and feedback a high/low voltage level. Even isolated by some cloth and paper, it can still feel the touch. Its sensetivity decrease as isolation layer gets thicker. For detail of usage, please check our wiki. To perfect user’s experience of our sensor module, we made following improvements.

Specification:
Supply Voltage: 3.3V to 5V
Interface: Digital
Size: 30*20mm
Weight: 3g

Connection Diagram:

thumb

Sample Code:

int ledPin = 13;                // Connect LED on pin 13, or use the onboard one
int KEY = 2;                 // Connect Touch sensor on Digital Pin 2
 
void setup(){
  pinMode(ledPin, OUTPUT);      // Set ledPin to output mode
  pinMode(KEY, INPUT);       //Set touch sensor pin to input mode
}
 
void loop(){
   if(digitalRead(KEY)==HIGH) {      //Read Touch sensor signal
        digitalWrite(ledPin, HIGH);   // if Touch sensor is HIGH, then turn on
     }
   else{
        digitalWrite(ledPin, LOW);    // if Touch sensor is LOW, then turn off the led
     }
}


Project 11: DHT11 Temperature and Humidity Sensor


thumb

Introduction:
This DHT11 Temperature and Humidity Sensor features calibrated digital signal output with the temperature and humidity sensor complex. Its technology ensures high reliability and excellent long-term stability. A high-performance 8-bit microcontroller is connected. This sensor includes a resistive element and a sense of wet NTC temperature measuring devices. It has excellent quality, fast response, anti-interference ability and high cost performance advantages.
Each DHT11 sensor features extremely accurate calibration data of humidity calibration chamber. The calibration coefficients stored in the OTP program memory, internal sensors detect signals in the process, and we should call these calibration coefficients. The single-wire serial interface system is integrated to make it quick and easy. Qualities of small size, low power, and 20-meter signal transmission distance make it a wide applied application and even the most demanding one. Convenient connection, special packages can be provided according to users need.


Specification:

  • Supply Voltage: +5 V
  • Temperature range: 0-50 °C error of ± 2 °C
  • Humidity: 20-90% RH ± 5% RH error
  • Interface: Digital
  • Size: 30*20mm
  • Weight: 4g


Connection Diagram:

thumb

Sample Code:

*****************************************************************************
Please download the DHT11Lib firstly.Or,see the website
#include <dht11.h>
dht11 DHT;
#define DHT11_PIN 4
  
void setup(){
  Serial.begin(9600);
  Serial.println("DHT TEST PROGRAM ");
  Serial.print("LIBRARY VERSION: ");
  Serial.println(DHT11LIB_VERSION);
  Serial.println();
  Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
}
  
void loop(){
  int chk;
  Serial.print("DHT11, \t");
  chk = DHT.read(DHT11_PIN);    // READ DATA
  switch (chk){
    case DHTLIB_OK:  
                Serial.print("OK,\t"); 
                break;
    case DHTLIB_ERROR_CHECKSUM: 
                Serial.print("Checksum error,\t"); 
                break;
    case DHTLIB_ERROR_TIMEOUT: 
                Serial.print("Time out error,\t"); 
                break;
    default: 
                Serial.print("Unknown error,\t"); 
                break;
  }
 // DISPLAT DATA
  Serial.print(DHT.humidity,1);
  Serial.print(",\t");
  Serial.println(DHT.temperature,1);
  
  delay(1000);
}
*******************************************************************************


Project 12: Analog Sound Sensor


thumb

Introduction:
Analog Sound Sensor is typically used in detecting the loudness in ambient environment. The Arduino can collect its output signal by imitating the input interface. You can use it to make some interesting interactive works such as a voice operated switch.

Specification:

  • Supply Voltage: 3.3V to 5V
  • Detecting sound intensity
  • Interface: Analog
  • Size: 30*20mm
  • Weight: 4g


Connection Diagram:

thumb

Sample Code:

*****************************************************************************
void setup()
{
  Serial.begin(9600); // open serial port, set the baud rate to 9600 bps
}
void loop()
{
      int val;
      val=analogRead(0);   //connect mic sensor to Analog 0
      Serial.println(val,DEC);//print the sound value to serial        
      delay(100);
}

*******************************************************************************


Project 13: Flame Sensor


thumb

Introduction:
This flame sensor can be used to detect fire or other lights whose wavelength stands at 760 nm ~ 1100 nm. In the fire-fighting robot game, the flame plays an important role in the probe, which can be used as the robot's eyes to find fire source.


Specification:

  • Supply Voltage: 3.3V to 5V
  • Detection range: 20cm (4.8V) ~ 100cm (1V)
  • Rang of Spectral Bandwidth: 760nm to 1100nm
  • Operating temperature: -25℃to 85℃
  • Interface: digital
  • Size: 44*16.7mm
  • Weight: 4g


Connection Diagram:

thumb

Sample Code:

*****************************************************************************
const int flamePin = 2;     // the number of the flame pin
const int ledPin =  13;      // the number of the LED pin
// variables will change:
int State = 0;         // variable for reading status
void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  // initialize the pushbutton pin as an input:
  pinMode(flamePin, INPUT);     
}
void loop(){
  // read the state of the value:
State = digitalRead(flamePin);
  if (State == HIGH) {     

    // turn LED on:    
    digitalWrite(ledPin, HIGH);  
  } 
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW); 
  }
}
*******************************************************************************


Project 14: DS3231 Clock Module


thumb

Introduction:
DS3231 is equipped with integrated TCXO and crystal, which makes it a cost-effective I2C real time clock with high precision. The device carries a battery input, so if you disconnect the main power supply, it can still maintain accurate timing. The integrated oscillator ensures the long-term accuracy of the device and reduces the number of components. DS3231 provides both commercial and industrial temperature range and supports 16 pins small-outline package (300mil). The module itself can adapt to the system of 3.3V and 5V without level switch, which is quite convenient!


Specification:

  • Temperature range: -40 to +85; Timing accuracy : ± 5ppm (±0.432 seconds / day)
  • Provide battery backup for continuous timing
  • Low power consumption
  • Device package and function compatible with DS3231
  • Complete clock calendar function contains seconds and minutes, hour, week, date, month, and year timing and provides leap year compensation until 2100.
  • Two calendar clock
  • Output: 1Hz and 32.768kHz
  • Reset output and Input Debounce of Pushbutton
  • High speed (400kHz), I2C serial bus
  • Supply voltage: +3.3V to +5.5V
  • Digital temperature sensor with a precision of±3℃
  • Working temperature: -40 ~ C to +85 ~ C
  • 16 pins Small Outline Package (300mil)
  • Certified by American Association of Underwriters Laboratories (UL)
  • Size: 30*20mm
  • Weight: 4g


Connection Diagram:
This module adopts the IIC test method, so we only need to connect ‘SDA’ to Arduino A4, ‘SCL’ to A5, ‘+’ to VCC and ‘-’ to GND as follows:

thumb

Sample Code:

*****************************************************************************
#include <Wire.h>
#include "DS3231.h"
DS3231 RTC; //Create the DS3231 object
char weekDay[][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
//year, month, date, hour, min, sec and week-day(starts from 0 and goes to 6)
//writing any non-existent time-data may interfere with normal operation of the RTC.
//Take care of week-day also.
DateTime dt(2011, 11, 10, 15, 18, 0, 5);//open the series port and you can check time here or make a change to the time as needed.
void setup () 
{   Serial.begin(57600);//set baud rate to 57600
    Wire.begin();
    RTC.begin();
    RTC.adjust(dt); //Adjust date-time as defined 'dt' above 
}
void loop () 
{  
 DateTime now = RTC.now(); //get the current date-time
    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.date(), DEC);
    Serial.print(' ');
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();
    Serial.print(weekDay[now.dayOfWeek()]);
    Serial.println();
    delay(1000);
}
*******************************************************************************

results:
Before compiling the code, you’d better put DS3231 library  under file into Arduino catalogue,. When the above steps are done, you can upload the code to arduino and open the series monitor and get following results:

thumb


Project 15: Analog Gas Sensor


thumb

Introduction:
This analog gas sensor - MQ2 is used in gas leakage detecting equipment in consumer electronics and industrial markets. This sensor is suitable for detecting LPG, I-butane, propane, methane, alcohol, Hydrogen and smoke. It has high sensitivity and quick response. In addition, the sensitivity can be adjusted by the potentiometer.


Specification:

  • Power supply: 5V
  • Interface type: Analog
  • Wide detecting scope
  • Quick response and High sensitivity
  • Simple drive circuit
  • Stable and long lifespan
  • Size: 49.7*20mm
  • Weight: 8g


Connection Diagram:

thumb

Sample Code:

*****************************************************************************
///Arduino Sample Code
void setup()
{
  Serial.begin(9600); //Set serial baud rate to 9600 bps
}
void loop()
{
int val;
val=analogRead(0);//Read Gas value from analog 0
Serial.println(val,DEC);//Print the value to serial port
delay(100);
}
*******************************************************************************


Project 16: Analog Alcohol Sensor


thumb

Introduction:
This analog gas sensor - MQ3 is suitable for detecting alcohol. It can be used in a Breath analyzer. Also it has high sensitivity to alcohol and low sensitivity to Benzine. The sensitivity can be adjusted by the potentiometer.


Specification:

  • Power supply: 5V
  • Interface type: Analog
  • Quick response and High sensitivity

Simple drive circuit

  • Stable and long service life
  • Size: 49.7*20mm
  • Weight: 6g


Connection Diagram:

thumb

Sample Code:

*****************************************************************************
///Arduino Sample Code
void setup()
{
  Serial.begin(9600); //Set serial baud rate to 9600 bps
}
void loop()
{
int val;
val=analogRead(0);//Read Gas value from analog 0
Serial.println(val,DEC);//Print the value to serial port
delay(100);
}
*******************************************************************************