KS0085 Keyestudio Smart Home Kit for Arduino

From Keyestudio Wiki
Jump to navigation Jump to search



thumb

Instruction:

The smart home kit based on Arduino is newly issued by Keyestudieo company. The concept is to make people enjoy life. You could remotely control your assorted smart systems through your phone or computer when you’re out, like turning on air conditioner and water heater on the way home; the electronic door lock and led light will automatically run when you get home. Additionally, the intelligent lighting system can be used to select preset lighting scenes to create a comfortable and quiet atmosphere, which contributes to make your brain completely relaxed. You just need a remote control to finish all the process. What surprises you is that the smart system can save electricity as well. As Bill Gates puts it, in the future, homes without smart home systems will be as unfashionable as homes without internet access today. Let’s know more about smart home kit!


Kit List


thumb

thumb

thumb

thumb

thumb

thumb


Keyestudio PLUS Control Board

Description


thumb

Keyestudio PLUS control board is fully compatible with Arduino IDE development environment. It contains all the functions of the Arduino UNO board. Moreover, some improvements we made highly strengthen its function. It is the best choice to learn how to build circuit and write code as well. Let’s get started!


thumb


Serial communication interface: D0 is RX, D1 is TX PWM interface (pulse width modulation): D3 D5 D6 D9 D10 D11 External interrupt interface: D2 (interrupt 0) and D3 (interrupt 1) SPI communication interface: D10 is SS, D11 is MOSI, D12 is MISO, D13 is SCK IIC communication port: A4 is SDA, A5 is SCL


Introduction:

When we get control board, we need to download Arduino IDE and driver firstly. You could download Arduino IDE from the official website: https://www.arduino.cc/en/Main/OldSoftwareReleases#1.5.x. There are various versions of the IDE in the official link, here we download a Windows system, version 1.8.10.



thumb


Installing Arduino IDE

Introduction: Install Arduino with the exe. Installation package you have downloaded well.
Get the latest version from the download page. You can choose between the Installer (.exe) and the Zip packages. We suggest you use the first one that installs directly everything you need to use the Arduino Software (IDE), including the drivers. With the Zip package you need to install the drivers manually. The Zip file is also useful if you want to create a portable installation.

Frist,Click “I Agree”.
thumb

When the download finishes, proceed with the installation and please allow the driver installation process when you get a warning from the operating system.

Then, click “Next”
thumb

Next, click “Install”.
thumb

thumb

When the following interface appears, click Install to finish the installation.
thumb

Finally, click “Close” after completing the installation.
thumb

Installing Driver

Finish the download, now, let’s install the driver of keyestudio PLUS control board. Its chip is CP2102 serial chip.

(1)If download the Arduino1.8.x development software, the driver file is included in it.


thumb

thumb

Double click thumb, click to next step,as shown below:


Arduino IDE Setting

Keyestudio Sensor Shield V5.2


thumb

Description

In the experiments, you might often use ARDUINO control board and several sensor modules. If the interfaces of power output is not enough, you may need to add a breadboard and use many connection wires. Is it really troublesome?
But now, with this keyestudio sensor shield, you can easily solve that problem. This shield is fully compatible with keyestudio PLUS Control Board, so you can easily stack it onto PLUS Control Board.
This keyestudio sensor shield has extended the digital and analog ports out as 3PIN interface (G,V, S), which can directly connect 3PIN sensor modules.
It also breaks out some communication pins of 2.54mm pitch, like serial, IIC, and SPI communication.
The shield comes with a reset button and 2 signal indicators as well.
Additionally, you can supply the voltage needed to the sensor modules through blue terminal blocks on the shield. Because some sensor modules is not used with 5V or 3.3V but with special voltage.

Parameter:

  • Extends an Arduino Reset button
  • Comes with 1 electrolytic capacitor and 1 ceramic capacitor
  • Comes with a built-in power indicator and a D13 indicator
  • Breakout all the digital and analog ports of keyestudio PLUS Control Board as 3PIN headers
  • A serial communication interface
  • A I2C communication interface
  • A SPI communication interface
  • Comes with a URF interface
  • Comes with an APC220 interface
  • You can supply the voltage needed for sensor modules via terminal blocks


Pins Description:
thumb

When SE is connected with jumper cap, and input DC 7V to VCC /GND terminal block, so the voltage of V, V1 and + pins are 7V. When SE is connected with jumper cap, and VCC /GND terminal block without voltage input, shield is powered via UNO R3, so the voltage of V, V1 and + pins are 5V. When SE is disconnected, input DC 7V to VCC /GND terminal block, so the voltage of V pin is 7V, the voltage of V1 and + pins are 0V. When SE is disconnected, and VCC /GND terminal block without voltage input, shield is powered via UNO R3, so the voltage of V pin is 0V, the voltage of V1 and + pins are 5V.

Example Use

Stack the Keyestudio Sensor Shield V5 on the Keyestudio PLUS Control Board, and build the circuit on the shield, as shown below.
thumb


Projects

When you get this kit, there are 14 sensors/modules inside like keyestudio PLUS control board, sensor shield and dupont Lines.
We firstly stack Keyestudio Sensor Shield V5.2 on the keyestudio PLUS control board and connect 14 sensors to sensor shield via dupont lines, upload the test code and check the result.


Note: In this course, the interface of each sensor / module marked with (G,-, GND) indicates the negative pole, and G and GND are connected to Arduino board or the sensor shield; V, +, and VCC stands for positive pole, they are linked with V, VCC and 5V of Arduino board or sensor shield.


Project 1: LED Blink

Description:


thumb

In this kit, there are white and yellow LED modules. Their operating method is same. In this lesson, we directly connect the white LED module to the sensor shield with three female-to-female DuPont cables. After wiring, we can upload code on the keyestudio PLUS control board to control white LED to display different colors. After GND and VCC are powered on, the LED lights up when the signal terminal S is HIGH, and the LED turns off when signal end S is LOW.

Specifications:

  • Control interface: digital port
  • Working voltage: DC 3.3-5V
  • Pin pitch: 2.54mm
  • LED display color: white
  • Size: 30 * 20mm
  • Weight: 3g

Equipment:

  • White LED module * 1
  • Keyestudio PLUS Control Board * 1
  • Sensor shield * 1
  • 3pin female to female Dupont lines
  • USB cable * 1


Connection Diagram:
thumb
Note: The G, V, and S ports of the white LED module are separately connected to G, V, and 13, then power on.


Test Code:

void setup()
{
  pinMode(13, OUTPUT);//set digital 13 to output}

void loop()
{
  digitalWrite(13,HIGH);//set digital 13 to HIGH level,LED lights up
  delay(1000);	//delay in 1000ms
  digitalWrite(13,LOW);//set digital13 to LOW level,LED lights off
  delay(1000);         //delay in 1000ms
}

Test Result:

Upload the test code successfully. After power on, the white LED starts blinking, light up for 1,000ms, turn off for 1000ms,and alternately.

Project 2: LED Breathe

Description


thumb

In this project, we will control the red LED brightness via PWM.
In the previous course, we introduced how to control the yellow LED on and off by code. Similarly, you can change the step length and delay in the code to set the red LED to achieve different breathing effects.

PWM is a means of controlling the analog output via digital means. Digital control is used to generate square waves with different duty cycles (a signal that constantly switches between high and low levels) to control the analog output.In general, the input voltage of port are 0V and 5V. What if the 3V is required? Or what if switch among 1V,3V and 3.5V? We can’t change resistor constantly. For this situation, we need to control by PWM.
For the Arduino digital port voltage output, there are only LOW and HIGH, which correspond to the voltage output of 0V and 5V. You can define LOW as 0 and HIGH as 1, and let the Arduino output 500 0 or 1 signals within 1 second.

The output port is 2.5V, which is like showing movie. The movie we watch are not completely continuous. It actually outputs 25 pictures per second. In this case, the human can’t tell it. So does PWM. If want different voltage, need to control the ratio of 0 and 1. The more 0,1 signals output per unit time, the more accurate the control.

In the following figure, the green line represents a period, and its value is the reciprocal of the PWM frequency. In other words, if the frequency of the Arduino PWM is 500 Hz, then the period between the two green lines is 2 ms. The range that can be manipulated in the analogWrite () command is 0-255, analogWrite (255) means 100% duty cycle (normally open), and analogWrite (127) duty cycle is about 50% (half the time).


thumb


Specifications:

  • Control interface: digital port
  • Working voltage: DC 3.3-5V
  • Pin pitch: 2.54mm
  • LED display color: yellow
  • Size: 30 * 20mm
  • Weight: 3g


Equipment:

  • Yellow LED module * 1
  • Keyestudio PLUS Control Board * 1
  • Sensor shield * 1
  • 3pin female to female DuPont lines
  • USB cable * 1


Connection Diagram:


thumb

Note: The G, V, and S ports of the yellow LED module are separately connected to G, V, and 13, then power on.

On the sensor expansion board, the G, V, and S pins of the yellow LED module are connected to G, V, and 5 respectively, and the power supply is connected.


Test Code:

 void setup(){
  analogWrite(5,0);//set the PWM value of digital5 to 0
}

void loop(){
  for (int i = 0; i <= 255; i = i + (51)) 
// variable i increases from 0 to 255, add 51 each time
{
    analogWrite(5,i);//set variable i to the PWM value of digital5 
    delay(500);//delay in 500ms
  }
  for (int i = 255; i >= 0; i = i + (-51))
//variable i reduces from 255 to 0,plus -51 each time
 {
    analogWrite(5,i);//set variable i to the PWM value of digital5 
    delay(500);//delay in 500ms
  }} 


Test Result:

Upload test code successfully and power on, yellow LED gradually become brighter and darker to simulate the human breath.

Project 3: Passive Buzzer

Description


thumb

There are many interactive works that can be completed with Arduino. The most common element is buzzer and speaker. Buzzer is easy to use. And buzzer concludes in active buzzer and passive buzzer. In this project, we use passive buzzer. In this experiment, we make the buzzer sound and play music by test code.


Specifications:

  • Control Port: digital
  • Working Voltage: DC 3.3-5V


Equipment

  • Keyestudio PLUS Control Board * 1
  • Sensor shield * 1
  • Passive buzzer module * 1
  • USB cable * 1
  • 3pin female to female Dupont cable * 1

Connection Diagram:


thumb

Note: The G, V, and S port of the passive buzzer module are separately connected to G, V, and 3 on the shield, power up.

Test Code:

 void setup(){
  pinMode(3, OUTPUT);//set digital3 to output
}

void loop(){
  tone(3,262);//digital3 outputs the sound of 262Hz
  delay(250);//delay in 250ms
  tone(3,294);;//digital3 outputs the sound of 294HZ
  delay(250);//delay in 250ms
  tone(3,330);
  delay(250);
  tone(3,349);
  delay(250);
  tone(3,392);
  delay(250);
  tone(3,440);
  delay(250);
  tone(3,494);
  delay(250);
  tone(3,532);
  delay(250);
  noTone(3);//digital3 turns off sound output
  delay(1000);
}

Test Result:

Upload test code on keyestudio PLUS Control Board, wire according to connection diagram, passive buzzer sounds “do re mi fa so la si do”.

Project 4:Controlling LED By Button Module

Description:


thumb

In this project, we will control LED to light on and off via button module. When the button is pressed, the signal end outputs low level (0); when released, the signal end of sensor keeps high level(1).


Specifications: Working voltage: DC 3.3-5V Control signal: digital signal Size: 34 * 22 * 15mm Weight: 3.8g


Equipment Keyestudio REV4 development board * 1 Sensor shield * 1 Yellow LED module * 1 Button module * 1 USB cable * 1 3pin female to female DuPont Lines *2

Connection Diagram:


thumb

Note: The G, V, and S pins of button sensor module are separately connected to G, V, and 4 on the shield, and the G, V, and S pins of the yellow LED module are connected to G, V, and 5 on the shield.

Test Code:

void setup(){
  Serial.begin(9600);//set baud rate to 9600
  pinMode(4, INPUT);//set digital4 to input
  pinMode(5, OUTPUT);//set digital5 to output
}

void loop(){
  Serial.println(digitalRead(4));//wrap word and read the value of digital4
  delay(500);//delay in 500ms
  if (digitalRead(4) == 0)
//when read the value of digital4 to 0
 {
    digitalWrite(5,HIGH);//set digital5 to HIGH level, LED lights up
  } 
else
//otherwise(when the value of digital4 is 1)
 {
    digitalWrite(5,LOW);//set digital5 to LOW level, LED lights off
}}


Test Result:

Upload test code, wire according to connection diagram, when the button is pressed, serial monitor displays 0 (low level ), yellow LED is on; when released, serial monitor displays 1 (high level), yellow LED is off.

Project 5:1-channel Relay Module

Description


thumb

This module is an arduino dedicated module, and compatible with arduino sensor expansion board. It has a control system (also called an input loop) and a controlled system (also called an output loop). Commonly used in automatic control circuits, it is an "automatic switch" for high voltage which control a larger current and a lower voltage with a smaller current and a lower voltage.

Therefore, it plays the role of automatic adjustment, safety protection and conversion circuit in the circuit. It allows Arduino to drive loads below 3A, such as LED light strips, DC motors, miniature water pumps, solenoid valve pluggable interface.


thumb

The main internal components of the electromagnetic relay are electromagnet A, armature B, spring C, moving contact D, static contact (normally open contact) E, and static contact (normally closed contact) F, (as shown in the figure ).

As long as a certain voltage is applied to both ends of the coil, a certain current will flow through the coil to generate electromagnetic effects, and the armature will attract the iron core against the pulling force of the return spring under the action of electromagnetic force attraction, thereby driving the moving contact and the static contact (normally open contact) to attract. When the coil is disconnected, the electromagnetic suction will also disappear, and the armature will return to the original position under the reaction force of the spring, releasing the moving contact and the original static contact (normally closed contact). This pulls in and releases, thus achieving the purpose of turning on and off in the circuit. The "normally open, normally closed" contacts of the relay can be distinguished in this way: the static contacts on off state when the relay coil is not energized are called "normally open contacts"; the static contacts on state are called "normally closed contact". The module comes with 2 positioning holes for you to fix the module to other equipment.


Specifications: Working voltage: 5V (DC) Interface: G, V, S interface Input signal: digital signal (high level 1, low level 0) Contacts: static contacts (normally open contacts, normally closed contacts) and moving contacts Rated current: 10A (NO) 5A (NC)  Maximum switching voltage: 150 V (AC) 24 V (DC)  Electric shock current: less than 3A  Weight: 15g  Contact action time: 10ms


Equipment: keyestudio PLUS Control Board*1 Sensor expansion board * 1 1-channel relay module * 1 White LED * 1 female to female Dupont line * 2 Male to female Dupont line * 2 3pin female to female Dupont cable * 1 USB cable * 1


Connection Diagram:


thumb

Note: On the shield, the G, V, and S pins of 1-channel relay module are connected to G, V, and 12 respectively. The NO is connected to V; the G, V, and S pins of white LED are respectively connected to G, V, and the NO of relay module.


Test Code:

void setup(){
  pinMode(12, OUTPUT);//set digital12 to output}

void loop(){
  digitalWrite(12,HIGH);//set digital12 to HIGH level, COM and NO are connected,LED is on
  delay(500);//delay in 500ms
  digitalWrite(12,LOW);//set digital12 to LOW level, COM and NO are disconnected,LED is off
  delay(500);//delay in 500ms
}


Test Result:

Wire, power up and upload the code. The relay is connected(“NO” is on , NC is off) for 0.5s, then disconnected for 0.5s (NC is on, NO is off), and alternately. When the relay is connected, the white LED is on, otherwise, the white LED is off.

Project 6:Photocell Sensor

Description


thumb

The photocell sensor (photoresistor) is a resistor made by the photoelectric effect of a semiconductor. It is very sensitive to ambient light, thus its resistance value vary with different light intensity. We use its features to design a circuit and generate a photoresistor sensor module. The signal end of the module is connected to the analog port of the microcontroller. When the light intensity increases, the resistance decreases, and the voltage of the analog port rises, that is, the analog value of the microcontroller also goes up. Otherwise, when the light intensity decreases, the resistance increases, and the voltage of the analog port declines. That is, the analog value of the microcontroller becomes smaller. Therefore, we can use the photoresistor sensor module to read the corresponding analog value and sense the light intensity in the environment. It is commonly applied to light measurement, control and conversion, light control circuit as well.


Specifications: Working voltage: 3.3V-5V (DC) Interface: 3PIN interface Output signal: analog signal Weight: 2.3g


Equipment: keyestudio PLUS Control Board*1 Sensor expansion board * 1 Photocell sensor module * 1 Passive buzzer module * 1 Yellow LED module * 1 3pin female to female Dupont cable * 3 USB cable * 1


Connection Diagram:


thumb


Note: On the expansion board, the G, V, and S pins of the photocell sensor module are connected to G, V, and A1; the G, V, and S pins of the passive buzzer module are linked with G, V, and 3 respectively; the G, V, and S pins of the yellow LED module are connected to G, V, and 5 separately.


Test Code:

void setup(){
  Serial.begin(9600);//set baud rate to 9600
  pinMode(A1, INPUT);//set A1 to input
  pinMode(3, OUTPUT);//set digital3 to output
  pinMode(5, OUTPUT);//set digital5 to output

}

void loop(){
  Serial.println(analogRead(A1));//wrap word and read the analog value of A1  delay(500);//delay in 500ms
  if (analogRead(A1) <= 600)
//if the analog value of A1 is less than or equal to 600
 {
    tone(3,262);//digital3 outputs the sound of 262Hz
    delay(250);//delay in 250ms
    digitalWrite(5,HIGH);//set digital5 to HIGH level,LED is on
    delay(500);//delay in 500ms
    tone(3,294);//digital3 outputs the sound of 294Hz
    delay(250);//delay in 250ms
digitalWrite(5,LOW);//set digital5 to low level,LED is off
delay(500);//delay in 500ms
    tone(3,330);
    delay(250);
    digitalWrite(5,HIGH);
    delay(500);
    tone(3,349);
    delay(250);
    digitalWrite(5,LOW);
    delay(500);
    tone(3,392);
    delay(250);
    digitalWrite(5,HIGH);
    delay(500);
    tone(3,440);
    delay(250);
    digitalWrite(5,LOW);
    delay(500);

  } 
else
//otherwise(if the analog value of A1 is greater than 600)
 {
digitalWrite(5,LOW);//set digital5 to low level,LED is off
    noTone(3);//digital3 stops sounding
 }}


Test Result:

Wire according to connection diagram, burn the code, and set the baud rate to 9600 after powering on with USB cable. When the value displayed on serial monitor is less than or equal to 600, the yellow LED flashes and the passive buzzer sensor plays music; otherwise, the yellow LED is off, and the passive buzzer sensor stops playing.



thumb

Project 7:Adjusting Motor Servo Angle

Description


thumb


When we make this kit, we often control doors and windows with servos. In this course, we’ll introduce its principle and how to use servo motors. Servo motor is a position control rotary actuator. It mainly consists of housing, circuit board, core-less motor, gear and position sensor. Its working principle is that the servo receives the signal sent by MCU or receiver and produces a reference signal with a period of 20ms and width of 1.5ms, then compares the acquired DC bias voltage to the voltage of the potentiometer and outputs a voltage difference.

Servo motor comes with many specifications. But all of them have three connection wires, distinguished by brown, red, orange colors (different brand may have different color). Brown one is for GND, red one for power positive, orange one for signal line.

The rotation angle of servo motor is controlled by regulating the duty cycle of PWM (Pulse-Width Modulation) signal. The standard cycle of PWM signal is 20ms (50Hz). Theoretically, the width is distributed between 1ms-2ms, but in fact, it's between 0.5ms-2.5ms. The width corresponds the rotation angle from 0° to 180°. But note that for different brand motor, the same signal may have different rotation angle. 


thumb

There are two ways to control a servomotor with Arduino. One is to use a common digital sensor port of Arduino to produce square wave with different duty cycle to simulate PWM signal and use that signal to control the positioning of the motor. Another way is to directly use the Servo function of the Arduino to control the motor. In this way, the program will be easier but it can only control two-contact motor because for the servo function, only digital pin 9 and 10 can be used. The Arduino drive capacity is limited. So if you need to control more than one motor, you will need external power.


Specifications: Working voltage: DC 4.8V ~ 6V Operating angle range: about 180 ° (at 500 → 2500 μsec) Pulse width range: 500 → 2500 μsec No-load speed: 0.12 ± 0.01 sec / 60 (DC 4.8V) 0.1 ± 0.01 sec / 60 (DC 6V) No-load current: 200 ± 20mA (DC 4.8V) 220 ± 20mA (DC 6V) Stopping torque: 1.3 ± 0.01kg · cm (DC 4.8V) 1.5 ± 0.1kg · cm (DC 6V) Stop current: ≦ 850mA (DC 4.8V) ≦ 1000mA (DC 6V) Standby current: 3 ± 1mA (DC 4.8V) 4 ± 1mA (DC 6V) Lead length: 250 ± 5 mm Appearance size: 22.9 * 12.2 * 30mm Weight: 9 ± 1 g (without servo horn) Storage temperature: -20 ℃ ~ 60 ℃ Operating temperature: -10 ℃ ~ 50 ℃

Connection Diagram:


thumb

Note: The servo is connected to G (GND), V (VCC), 9. The brown wire of the servo is connected to Gnd (G), the red wire is connected to 5v (V), and the orange wire is connected to digital pin 9.


Test Code:

volatile int pulsewidth;//set variable pulsewidth
//Set a subroutine to control the servo angle
void procedure(int servopin, int myangle) {
  for (int i = 0; i <= 50; i = i + (1)) {
    pulsewidth = myangle * 11 + 500;
pinMode(servopin, OUTPUT);
//varaible servopin(means signal end of servo,set to output)
    digitalWrite(servopin,HIGH);
delayMicroseconds(pulsewidth);//delay time is ms, the value is variable pulsewidth 
    pinMode(servopin, OUTPUT);
    digitalWrite(servopin,LOW);
    delay((20 - pulsewidth / 1000));
  }
}

void setup(){
  pulsewidth = 0;//set variable pulsewidth to 0
}
void loop(){
  procedure(9, 90);//set signal end of servo to digital9,the angle of servo is set to 90°
}

Test Result:

Upload code, wire according to connection diagram, and power on. The DIP switch is dialed to right side, the servo rotates to 90°.

Project 8:Fan Module

Description


thumb

The L9110 motor control chip is applied on Keyestudio L9110 motor control module. It can control the rotation direction and speed of the motor so as to control the fan. The module is compatible with servo motor control. This module is efficient with good fan, commonly applied to fire robot.


Specifications: Fan diameter: 75mm Working voltage: 5V


Equipment: keyestudio PLUS Control Board*1 Sensor shield* 1 Small fan module * 1 USB cable * 1 Female to female DuPont Lines


Connection Diagram:


thumb

Note: On the shield, the GND, VCC, INA, and INB pins of the fan module are respectively connected to G, V, 7, 6.


Test Code:

void setup(){
  pinMode(7, OUTPUT);//set digital7 to output
  pinMode(6, OUTPUT);//set digital6 to output
}

void loop(){
//set fan to rotate counterclockwise for 3000ms
  digitalWrite(7,LOW);
  digitalWrite(6,HIGH);
  delay(3000);
//set fan to stop rotating for 1000ms
  digitalWrite(7,LOW);
  digitalWrite(6,LOW);
  delay(1000);
//set fan to rotate clockwise for 3000ms
  digitalWrite(7,HIGH);
  digitalWrite(6,LOW);
  delay(3000);
}


Test Result:

Upload test code, wire according to connection diagram, the DIP switch is dialed to right side and power on. The fan rotates counterclockwise for 3000ms, stops for 1000ms, then rotates clockwise for 3000ms.

Project 9:Steam Sensor

Description


thumb

This is a commonly used steam sensor. Its principle is to detect the amount of water by bare printed parallel lines on the circuit board. The more the water is, the more wires will be connected. As the conductive contact area increases, the output voltage will gradually rise. It can detect water vapor in the air as well. The steam sensor can be used as a rain water detector and level switch. When the humidity on the sensor surface surges, the output voltage will increase.

The sensor is compatible with various microcontroller control boards, such as Arduino series microcontrollers. When using it, we provide the instruction to operate steam sensor and Arduino control board. Connect the signal end of the sensor to the analog port of the microcontroller, sense the change of the analog value, and display the corresponding analog value on the serial monitor.

It comes with the 3pin with 2.54mm pitch. Connect it to control board with dupont lines. We particularly design the shield compatible with this sensor and keyestudio PLUS control board. You just need to stack shield to keyestudio PLUS control board and connect them together with 3pin dupont lines. Note: the connect part is not waterproof, don’t immerse it in the water please.

Specifications:

Working voltage: DC 3.3-5V Working current: <20mA Operating temperature range: -10 ℃ ~ + 70 ℃; Control signal: analog signal output Interface: 2.54mm 3pin pin interface Size: 35 * 20 * 8mm Weight: 2.2g S: signal output V (+): Power supply (VCC) G (-): Ground (GND)


Equipment: keyestudio PLUS Control Board*1 Sensor shield * 1 Water vapor sensor * 1 Photocell sensor module * 1 Servo * 1 Yellow LED * 1 3pin female to female DuPont Lines USB cable * 1


Connection Diagram:


thumb

Note: On the sensor shield, the pins G,V and S of steam sensor are connected to G, V and A3; the pins G, V and S of photocell sensor are connected to G, V and A1; the pins G, V and S of yellow LED are linked with G, V and 5; the brown line is linked with G, red wire to V, orange wire to 9.

Test Code:

#include <Servo.h>//use the library of Servo.h

Servo servo_9;

void setup(){
  Serial.begin(9600);//set baud rate to 9600
  pinMode(A1, INPUT);//set A1 to input
  pinMode(A3, INPUT);//set A3 to input
  pinMode(5, OUTPUT);;//set digital5 to input
  servo_9.attach(9);//set signal end of servo to digital9
}

void loop(){
  Serial.print("illumination");
  Serial.print(analogRead(A1));//serial port outputs the analog value of A1  Serial.print("       ");
  Serial.print("humidity");
  Serial.println(analogRead(A3));//wrap word and output the analog value of  A3
delay(500);//delay in 500ms
  if (analogRead(A3) >= 500 && analogRead(A1) <= 450) 
//if the analog value of A3≥500 and the analog value of ≤ 450
{
digitalWrite(5,HIGH);//set digital5 to HIGH level,LED is off
servo_9.write(0);//set servo angle to 0°
    delay(200);//delay in 200ms
  } 
else
//otherwise
 {
if (analogRead(A3) < 500 && analogRead(A1) > 450) 
//if the analog value of A3 is less than 500 and the analog value of A3 is greater than 450
{
      digitalWrite(5,LOW);//set digital5 to low level,LED is off
      servo_9.write(180);//set servo angle to 180°
      delay(200);//delay in 200ms
 }}}


Test Result:

Upload test code successfully, wire according to connection diagram. When put a drop of water on steam sensor and cover the photocell sensor, the analog value of steam sensor will increase on serial monitor, the analog value of photocell sensor will gradually go down, the yellow LED will light on, servo will rotate to 0°. However, when wipe off the water drop and the photocell sensor is under strong light, the analog value on the serial monitor will gradually decline, the analog value of photocell sensor will gradually increase, yellow LED will be off, and servo will rotate to 180°

Project 10: PIR Motion Sensor

Description


thumb

The Pyroelectric infrared motion sensor can detect infrared signals from a moving person or moving animal, and output switching signals. It can be applied to a variety of occasions to detect the movement of human body. Conventional pyroelectric infrared sensors are much more bigger, with complex circuit and lower reliability. Now we launch this new pyroelectric infrared motion sensor, specially designed for Arduino. This sensor integrates an integrated digital pyroelectric infrared sensor, and the connection pins. It features higher reliability, lower power consumption and simpler peripheral circuit.


Specifications: Input voltage: DC 3.3V ~ 18V Working current: 15uA Working temperature: -20 ~ 85 degrees Celsius Output voltage: high 3 V, low 0 V Output delay time (high level): about 2.3 to 3 seconds Detection angle: about 100 ° Detection distance: 3-4 meters Output indicator LED (high-level light) Pin limit current: 100mA


Special note: 1. The maximum distance is 3-4 meters during testing. 2. When testing, first open the white lens, you can see the rectangular sensing part. When the long line of the rectangular sensing part is parallel to the ground, the distance is the best. 3. When testing, the sensor needs to be covered with white lens, otherwise it will affect the distance. 4. The distance is best at 25℃, and the detection distance is shortened when it exceeds 30℃. 5. Done powering up and uploading the code, you need to wait 5-10 seconds then start testing, otherwise it is not sensitive.

Equipment:

  • keyestudio PLUS Control Board*1
  • Sensor expansion board * 1
  • PIR Motion sensor * 1
  • Small fan module * 1
  • White LED module * 1
  • 3pin female to female Dupont cable * 2
  • Mother to mother Dupont line * 4
  • USB cable * 1

Connection Diagram:


thumb

Note: On the shield, the G, V and S of PIR motion sensor are connected to G, V and 2; the GND, VCC, INA and INB of fan module are separately connected to G,V,7,6. The pin G, V and S of LED module are linked with G, V and 13.


Test Code:

void setup(){
  Serial.begin(9600);//set baud rate to 9600
  pinMode(2, INPUT);//set digital2 to input
  pinMode(13, OUTPUT);//set digital13 input
  pinMode(7, OUTPUT);//set digital7 input
  pinMode(6, OUTPUT);//set digital6 input}
void loop(){
  Serial.println(digitalRead(2));//wrap word and output the value of digital2
  delay(500);//delay in 500ms
  if (digitalRead(2) == 1)
//when there is person around,the value of digital2 is 1
 {
digitalWrite(13,HIGH);//set digital13 to high level,LED lights up
//set fan to rotate
digitalWrite(7,HIGH);//set digital7 to high level
analogWrite(6,150);//set the PWM value of digital6,the higher the value,the slower the fan rotates
  } else
//otherwise(when nobody is around, the value of digital2 is 0)
 {
digitalWrite(13,LOW);//set digital13 to low level,LED lights on
//fan stops rotating
    digitalWrite(7,LOW);
    analogWrite(6,0);
  }}


Test Result:

Upload test code, open serial monitor, and set baud rate to 9600. If PIR motion sensor detects the people around, the serial monitor displays “1”, the D13 and white LED light on at same time, fan rotates. If there is no person around, the serial monitor shows “0”, the D13 indicator and white LED stops rotating.


thumb

Project 11: Analog(MQ-2)Sensor

Description


thumb

This gas sensor is used for household gas leak alarms, industrial combustible gas alarms and portable gas detection instruments. And it is suitable for the detection of liquefied gas, benzene, alkane, alcohol, hydrogen, etc., and widely used in various fire alarm systems. The MQ-2 smoke sensor can be accurately a multi-gas detector, and has the advantages of high sensitivity, fast response, good stability, long life, and simple drive circuit. It can detect the concentration of flammable gas and smoke in the range of 300~10000ppm.Meanwhile, it has high sensitivity to natural gas, liquefied petroleum gas and other smoke, especially to alkanes smoke. It must be heated for a period of time before using the smoke sensor, otherwise the output resistance and voltage are not accurate. However, the heating voltage should not be too high, otherwise it will cause my internal signal line to blow.

It is belongs to the tin dioxide semiconductor gas-sensitive material, and belongs to the surface ion type N-type semiconductor. At a certain temperature, tin dioxide adsorbs oxygen in the air and forms negative ion adsorption of oxygen, reducing the electron density in the semiconductor, thereby increasing its resistance value. When in contact with flammable gas in the air and smog, if the potential barrier at the grain boundary is adjusted by the smog, it will cause the surface conductivity to change. With this, information about the presence of smoke or flammable gas can be obtained. The greater the concentration of smoke or flammable gas in the air, the greater the conductivity, and the lower the output resistance, the larger the analog signal output. The sensor comes with a positioning hole, which is convenient for you to fix the sensor to other devices. In addition, the sensitivity can be adjusted by rotating the potentiometer.


Specifications: Working voltage: 3.3-5V (DC) Interface: 4 pins (VCC, GND, D0, A0) Output signal: digital signal and analog signal Weight: 7.5g

Equipment: keyestudio PLUS Control Board*1 Sensor shield* 1 MQ-2 gas sensor * 1 Passive sensor*1 fan module * 1 Yellow LED module * 1 3pin female to female DuPont Lines USB cable * 1

Connection Diagram:



thumb

Note: On the shield, the pin GND, VCC, D0 and A0 of gas sensor are linked with pin GND, VCC, D0 and A0. Pin GND, VCC, INA and INB of fan module are connected to G,V, 7 and 6. The pin G,V and S of passive buzzer are connected to G,V and 3; the pin G, V and S of yellow LED are connected to G,V and 5.



Test Code:


void setup(){
  Serial.begin(9600);//set baud rate to 9600
  pinMode(11, INPUT);//set digital11 to input
  pinMode(A0, INPUT);//set A0 to input
  pinMode(3, OUTPUT);//set digital3 to output
  pinMode(7, OUTPUT);//set digital7 to output
  pinMode(6, OUTPUT);//set digital6 to output
  pinMode(5, OUTPUT);//set digital5 to output
}

void loop(){
  Serial.println(digitalRead(11));//wrap word and read the analog value of digital11
  Serial.println(analogRead(A0));//wrap word and read the analog value of A0
  delay(500);//delay in 500ms
  if (analogRead(A0) > 45 && digitalRead(11) == 0) {
//if the analog value of A0 is greater than 45 and the digital value of digital11 is 0 
    tone(3,131);//digital3 outputs the sound of 131HZ
delay(125);//delay in 125ms
//set fan to rotate
    digitalWrite(7,LOW);
analogWrite(6,200);//set the PWM value of digital6 to 200, the bigger the the value of PWM is,the faster the fan rotates
    digitalWrite(5,HIGH);//set digital5 to high level,LED lights up
    delay(200);//delay in 200ms
digitalWrite(5,LOW);//set digital5 to low level,LED is off
    delay(200);//delay in 200ms
  } else
//otherwise
 {
    noTone(3);//digital3 stops sounding
digitalWrite(5,LOW);//set digital5 to low level,LED is off
//fan stops rotating
    digitalWrite(7,LOW);
    analogWrite(6,0);
  }}


Test Result:

Upload test code, wire according to connection diagram and power on. When gas sensor detects the flammable gas, passive buzzer will sound, fan will rotate and yellow LED will be on; when there is no flammable gas, the passive buzzer won’t sound, the fan won’t rotate and yellow LED will be off.

Project 12: 1602 LCD Display

Description


thumb

keyestudio 1602 I2C module is a 16 character by 2 line LCD display with Blue background and White backlight. The original 1602 LCD needs 7 IO ports to be up and running, but ours is built with Arduino IIC/I2C interface, saving you 5 IO ports. This LCD is ready-to-use because it is compatible with the Arduino Liquid Crystal Library. LCDs are great for printing data and showing values. Adding an LCD to your project will make it super portable and allow you to integrate up to 32 characters (16x2) of information. On the back of LCD display there is a blue potentiometer. You can turn the potentiometer to adjust the contrast. Notice that the screen will get brighter or darker and that the characters become more visible or less visible.


Specifications:

  • I2C address: 0x27
  • Backlight (blue, white)
  • Power supply voltage: 5V
  • Adjustable contrast
  • GND: A pin that connects to ground
  • VCC: A pin that connects to a +5V power supply
  • SDA: A pin that connects to analog port A4 for IIC communication
  • SCL: A pin that connects to analog port A5 for IIC communication


Equipment:

  • keyestudio PLUS Control Board*1
  • Sensor expansion board * 1
  • 1602 LCD module * 1
  • 4pin female to female DuPont line * 1
  • USB cable * 1


Connection Diagram:


thumb

Note: there are pin GND, VCC, SDA and SCL on 1602LCD module. GND is linked with GND(-)of IIC communication, VCC is connected to 5V(+), SDA to SDA, SCL to SCL.


Test Code:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
//use relevant library file
LiquidCrystal_I2C mylcd(0x27,16,2);
//set the communication address of I2C to 0x27,set to 1602 for display(16 characters per row, 2 rows in total
)
void setup(){
  mylcd.init();
  mylcd.backlight();
  mylcd.clear();//clear up the pattern displayed
}

void loop(){
//the first character of first row starts to show "Hello World!"
  mylcd.setCursor(0, 0);
  mylcd.print("Hello World!");
//the character isn’t shown at second row
  mylcd.setCursor(0, 1);
  mylcd.print("");
  mylcd.scrollDisplayLeft();//the shown character rolls to the left 
  delay(300);//delay in 300ms
}


Test Result:

Upload the test code, wire according to connection diagram and power on. 1602 LCD shows “Hello World!” at first line and rolls to the left. Note: Wire according to connection diagram, upload the code, and after power-on, when the display doesn’t show characters, you can adjust the potentiometer behind the 1602LCD and backlight to make the 1602LCD display the corresponding character string.

Project 13: Soil Humidity Sensor

Description


thumb

This is a simple soil humidity sensor aims to detect the soil humidity. If the soil is in lack of water, the analog value output by the sensor will decrease; otherwise, it will increase. If you use this sensor to make an automatic watering device, it can detect whether your botany is thirsty to prevent it from withering when you go out. Using the sensor with Arduino controller makes your plant more comfortable and your garden smarter. The soil humidity sensor module is not as complicated as you might think, and if you need to detect the soil in your project, it will be your best choice. The sensor is set with two probes inserted into the soil, then with the current go through the soil, the sensor will get resistance value by reading the current changes between the two probes and convert such resistance value into moisture content. The higher moisture (less resistance), the higher conductivity the soil has. Insert it into the soil and then use the AD converter to read it. With the help of this sensor, the plant can remind of you: I need water.  


Specification

  • Power Supply Voltage: 3.3V or 5V
  • Working Current: ≤ 20mA
  • Output Voltage: 0-2.3V (When the sensor is totally immersed in water, the voltage will be 2.3V) the higher humidity, the higher the output voltage
  • Sensor type: Analog output
  • Interface definition: S- signal, G- GND, V - VCC
  • Packaging : Electrostatic bag sealing
  • Size: 63 * 20 * 8mm
  • Weight: 2.5g


Equipment

  • keyestudio PLUS Control Board * 1
  • Sensor expansion board * 1
  • Soil humidity sensor module * 1
  • 1602 LCD * 1
  • 3pin female to female DuPont line * 1
  • 4pin female to female DuPont line * 1
  • USB cable * 1


Connection Diagram


thumb

Note: On the shield, the pin G, V and S of soil humidity sensor are connected to G, V and A2; GND of 1602LCD is linked with GND of ICC communication, VCC is connected to 5V(+), SDA to SDA, SCL to SCL.


Test Code:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
//Use relevant library functions
volatile int value;//set variable “value”
LiquidCrystal_I2C mylcd(0x27,16,2);
//Set the I2C communication address to 0x27 and the display to 1602 (16 characters per line, 2 lines total)
void setup(){
  Serial.begin(9600);//set baud rate to 9600
  value = 0;//set value to 0
  mylcd.init();
  mylcd.backlight();
  mylcd.clear();//clear up the displayed information on LCD
  pinMode(A2, INPUT);//set A2 to input
}

void loop(){
  Serial.print("Soil moisture value:");
  Serial.print("     ");
  Serial.println(value);//wrap word and output the value of variable value  delay(500);//delay in 500ms
  value = analogRead(A2);//assign the analog value of A2 to variable value
  if (value < 300) {
//if the variable value is less than 300
mylcd.clear();//clear up the displayed information on LCD
// Display the "value" character from the first character in the first line
    mylcd.setCursor(1-1, 1-1);
mylcd.print("value:");
//Display the value of variable value from the seventh character at the first line
    mylcd.setCursor(7-1, 1-1);
mylcd.print(value);
//Display the "dry soil" character from the first character in the second line
    mylcd.setCursor(1-1, 2-1);
    mylcd.print("dry soil");
delay(300);//delay in 300ms
  } 
else if (value >= 300 && value <= 700) 
//else if the variable value is greater than or equal to 300 and less than or equal to 700
{
mylcd.clear();//clear up the displayed information on the LCD
//Display the "value" character from the first character in the first line
    mylcd.setCursor(1-1, 1-1);
mylcd.print("value:");
//Display the value of variable value from the seventh character of the first line
    mylcd.setCursor(7-1, 1-1);
mylcd.print(value);
//Display the "humid soil" character from the first character on the second line
    mylcd.setCursor(1-1, 2-1);
    mylcd.print("humid soil");
    delay(300);//delay in 300ms
  } 
else if (value > 700)
//else if variable value is greater than 700
 {
mylcd.clear();//clear up the displayed information on the LCD
//Display the "value" character from the first character in the first line
    mylcd.setCursor(1-1, 1-1);
mylcd.print("value:");
//Display the value of variable value from the seventh character of the first line
    mylcd.setCursor(7-1, 1-1);
mylcd.print(value);
//Display the "in water" character from the first character in the second line
    mylcd.setCursor(1-1, 2-1);
    mylcd.print("in water");
    delay(300);//delay in 300ms
  }
}


Test Result:

Connect according to wiring diagram, and burn the program. After powering on, open the serial monitor and insert the soil sensor into the soil. The greater the humidity is, the bigger the number, in the range of 0-1023. The soil sensor is inserted into the soil and water with different humidity, and the 1602LCD displays the corresponding value.

Project 14: Bluetooth Test

In 20th century, technology has changed our life. People can work at home with wireless device like mouse, earphone, printer and speaker, which highly enhances our life standard. Bluetooth can make work at home easily, as well as the entertainment. Users can control wirelessly the audio file from PC or Apple iPod within 30 inches. Bluetooth technology can also be used in adapters, allowing people to share their daily life with friends from internet and social media.


Bluetooth Remote Control


thumb

Bluetooth technology is a wireless standard technology that enables short-distance data exchange between fixed devices, mobile devices, and building personal area networks (using UHF radio waves in the ISM band of 2.4 to 2.485 GHz). This kit is equipped with the HM-10 Bluetooth module, which is a master-slave machine. When use as the Host, it can send commands to the slave actively; when use as the Slave, it can only receive commands from the host. The HM-10 Bluetooth module supports the Bluetooth 4.0 protocol, which not only supports Android mobile, but also supports iOS system. In the experiment, we default use the HM-10 Bluetooth module as a Slave and the cellphone as a Host. We install the Bluetooth APP on the mobile phone, connecting the Bluetooth module; finally use the Bluetooth APP to control the parts of smart home kit. We also provide you with 2 types of mobile APP, for Android and iOS system.


Parameters of HM-10 Bluetooth Module:
Ks0085=.png


  • Bluetooth protocol: Bluetooth Specification V4.0 BLE
  • No byte limit in serial port Transceiving
  • In open environment, realize 100m ultra-distance communication with iphone4s
  • USB protocol: USB V2.0
  • Working frequency: 2.4GHz ISM band
  • Modulation method: GFSK(Gaussian Frequency Shift Keying)
  • Transmission power: -23dbm, -6dbm, 0dbm, 6dbm, can be modified by AT command.
  • Sensitivity: ≤-84dBm at 0.1% BER
  • Transmission rate: Asynchronous: 6K bytes ; Synchronous: 6k Bytes
  • Security feature: Authentication and encryption
  • Supporting service: Central & Peripheral UUID FFE0, FFE1
  • Power consumption: Auto sleep mode, stand by current 400uA~800uA, 8.5mA during transmission.
  • Power supply: 5V DC
  • Working temperature: –5 to +65 Centigrade

Using Bluetooth APP

Description:

In the previous lesson, we’ve introduced the basic parameter principle of HM-10 Bluetooth module. In this project, let's show you how to use the HM-10 Bluetooth module. In order to efficiently control this kit by HM-10 Bluetooth module, we specially designed an APP, as shown below.



thumb


There are 16 control buttons in the app. When we connect the HM-10 Bluetooth module and app, only press control button of APP, and the Bluetooth of cellphone sends a control character. The Bluetooth module will receive a corresponding control character. When programming, we set the corresponding function of each sensor or module according to the corresponding key control character. Next, let’s test 16 buttons on app.


APP for Android mobile(overseas):

Enter google play,search “keyes IoT”,if you can’t search it on app store, please download app in the following link:
https://play.google.com/store/apps/details?id=com.keyestudio.iot_keyes

APP for Android mobile(domestic):

Download Link:https://pan.baidu.com/s/1xE1kGjG3CroPNH3-HgF6pQ

(3)After installing and open the app thumb ,the interface pops up as below:


thumb

Upload code and power on, Led of Bluetooth module blinks. Start Bluetooth and open App to click “CONNECT” to connect.


thumb

Click to “Connect”, Bluetooth is connected successfully. As shown below, the LED of Bluetooth module is normally on.


thumb


For IOS system:

(1) Open App Store thumb

(2) Search “IoT keyes”on APP Store,then click “downlaod”.


thumb

(3)After installing successfully and open thumb,the interface is shown below:
thumb

(4)Upload the test code successfully, insert the Bluetooth module and power on. LED of Bluetooth module is flashing. Start Bluetooth on cellphone, then click “connect” on the left to search Bluetooth and pair. After paring successfully, the LED of Bluetooth module is on. Note: Remove the Bluetooth module please, when uploading the test code. Otherwise, the program will fail to upload. Connect the Bluetooth and Bluetooth module to pair after uploading the test code.

4.Connection Diagram


thumb

Note: On the sensor expansion board, the RXD, TXD, GND, and VCC of the Bluetooth module are respectively connected to TXD, RXD, GND, and 5V, and the STATE and BRK pins of the Bluetooth module do not need to be connected. Connect the power supply.

Test Code:

char val;//set a variable val
void setup(){
  Serial.begin(9600);//set baud rate to 9600
}

void loop(){
  if (Serial.available()>0)//read the data on serial port
  {
val = Serial.read();//assign the character read by serial port to val
    Serial.print(val);//serial port outputs val
  }}


Key function on app:


thumb

thumb

thumb

thumb

6.Assembled Guide

Check the board A~I and parts firstly
thumb