Get tutorials Arduino Smart Home Kit V2.0 for Arduino

Experiments

Experiment 1 How to Use Photoresistor Module

Overview:

In this experiment, connect the photoresistor to pin A0 of SunFounder Mega 2560. When the light intensity changes, the resistance of the photoresistor will change and the output voltage of A0 will change accordingly. The resistance of the photoresistor is regulated and converted by the A/D converter inside the SunFounder Mega 2560 into digital values which you can see on Serial Monitor. The stronger the light intensity is, the smaller the value is; the weaker, the larger.


Components:

- 1 * SunFounder Mega 2560

- 1 * Photoresistor Module

- 1 * USB Cable

- 1 * 3-Pin anti-reverse cable


Experimental Procedures

Step1: Build the circuit


 

Step2: Program

Step3: Compile

Step4: Burn the program into the SunFounder Mega 2560 board

Open the serial monitor and you can see the resistance of the photoresistor changing. Cover the photoresistor with your palm and the value displayed on Serial Monitor will increase. Move it away and the value displayed will decrease and finally tend to be stable.

 

 


Experiment 2 How to Use Humiture Sensor DHT11 module

Overview

In this experiment, you will learn how to use Humiture Sensor DHT11 module. After you take all the steps, you will see the temperature & humidity data collected by DHT11 displayed on Serial Monitor.


Components

- 1 * SunFounder Mega 2560

- 1 * Humiture Sensor DHT11 module

- 1 * USB cable

- 1 * 3-Pin anti-reverse cable


Experimental Procedures

Step1: Build the circuit


 


Step2: Program

Step3: Compile

Step4: Burn the program into the SunFounder Mega 2560 board (check the board and port selected)

Now, you can see the ambient temperature and humidity values on Serial Monitor.


 

 


Experiment 3 How to Use MQ-2 Gas Sensor

Overview:

Before starting, you need to adjust the sensitivity of the gas sensor. Power on the sensor, adjust the potentiometer onside, and the D2 LED will light up or dim accordingly. Spin the pot and stop just when the LED gets brighter or dimmer. At this moment, the sensitivity of the gas sensor is the highest. You can confirm it with a lighter.

Connect pin A0 of the gas sensor to pin A0 of the SunFounder Mega 2560, and D0 to pin 7. The higher the smoke concentration is, the lower the resistance of the gas sensor gets. Thus, the voltage of the gas sensor decreases, which means the voltage of pin A0 increases. If the voltage of A0 is greater than the threshold, LM393 will output low level. Thus, the LED will light up and pin D0 will output low level.


Components:

-1 * SunFounder Mega 2560

-1 * MQ-2 Gas Sensor Module

-1 * USB Cable

- 1 * 3-Pin anti-reverse cable


Experimental Procedures

Step1: Build the circuit


 


Step2: Program

Step3: Compile

Step4: Burn the program into the SunFounder Mega 2560 board (check board and port selected)

Now, ignite a lighter. Then the sensor detects the gas emitted. Thus, the LED on the gas sensor and that attached to pin 13 on the SunFounder Uno board will light up. Also you can see the value at A0 and D0 printed on Serial Monitor.

Note: It is normal that the gas sensor generates heat. Actually, the higher the temperature is, the more sensitive the sensor is.


 

 


Experiment 4 How to Use PIR

Overview:

In this experiment, you will use an LED to indicate the state value of PIR. When people pass by, the LED will light up; or elso it stays out.


Components:

-1 * SunFounder Mega 2560

-1 * PIR

-1 * USB Cable

-1 * LED (Red)

-1 * Resistor (220ohm)

- Several jumper wires

-1 * Breadboard

 

Experimental Procedures

Step1: Build the circuit


 


Step2: Program

Step3: Compile

Step4: Burn the program into the SunFounder Mega 2560 board (Pay attention to select the correct board and port)


 

 


Experiment 5 How to Use Gas Pressure Sensor BMP180

Overview:

In this experiment, you will learn how to use a gas pressure sensor. The SunFounder Mega 2560 is used as the master board to read the values from BMP180 and display them on Serial Monitor.


Components:

- 1 * SunFounder Mega 2560

- 1 * BMP180

- 1 * USB Cable

- 1 * 4-Pin anti-reverse cable


Experimental Procedures

Step1: Build the circuit


 


Step2: Program

Step3: Compile

Step4: Burn the program into the SunFounder Mega 2560 board


 

 


Experiment 6 How to Use RFID Module

Overview:

In this experiment, you will learn how to use the RFID module and RFID1 library, and simulate SPI with software to communicate between the SunFounder Mega 2560 board and the RFID module. Before starting, you need to know the ID of the RFID key tag and write the ID to the rfidTest file.

After you have finished the following steps, if you place the RFID key tag in the induction zone of the RFID module, the characters ”Collect!” will be displayed on Serial Monitor.


Components:

-1 * SunFounder Mega 2560

-1 * RFID Module

-1 * RFID key tag

-1 * USB Cable

- Several jumper wires

-1 * Breadboard

-1* Capacitor Ceramic 100nF

 

Experimental Procedures

Step1: Build the circuit

The wiring between RFID and SunFounder Mega 2560 is as follows:


RFID

SunFounder Mega 2560

VCC

3.3V

RST

2

GND

GND

MISO

3

MOSI

4

SCK

5

NSS

6

IRQ

7

 













 

Note: To realize more stable output, you need to connect a 0.1uF capacitor between 3.3V and GND for filtering.


 


Step 2: Open the getId file with Arduino IDE (Please refer to the example code in LEARN -> Get Tutorial on our website). Compile the code

Step 3: Upload the sketch to the SunFounder Mega 2560 board

Then place the RFID key tag in the induction zone of the RFID module. You will see the following values printed on Serial Monitor:


 


Step 4: Now, you may know the ID of your RFID key tag (e.g. the RFID key tag in our experiment is 84A168B8, as shown in the figure above).

Open the rfidTest file and replace the ID in the sketch with your own (divide the ID into four numbers equally, just as shown in the example below):


 

 

Step 5: Burn the sketch into the SunFounder Mega 2560 board


 

 

 

After burning rfidTest, you will see the following values printed on Serial Monitor:


 


Experiment 7 How to Use NRF24L01

Overview:

This routine is divided into sending and receiving parts. The sending terminal consists of the SunFounder Mega 2560, five buttons, and NRF24L01 module. The receiving terminal consists of SunFounder Nano, 4-channel relay module, and NRF24L01 module. The five keys on the sending terminal are defined as sw1, sw2, sw3, sw4, and sw5. The first four keys are corresponding to the four channels on the relay module of the receiving terminal. The sw5 key is a close key. When any keys are pressed on the sending terminal, the corresponding relay channel on the receiving terminal will be energized. When sw5 is pressed, all the relays will be disconnected.


Components:

-1 * SunFounder Mega 2560

-1 * SunFounder Nano

-2 * NRF24L01

-1 * 4-channel relay module

-1 * Breadboard

-1 * USB Cable for Mega 2560

-1 * USB Cable for Nano

-Several jumper wires

-5 * Buttons

 

Experimental Procedures

Step1: Build the circuit

 

Sending Terminal

 1)The wiring between the five buttons and SunFounder Mega 2560 is as follows:


Buttons

SunFounder Mega 2560

Sw1

2

Sw2

3

Sw3

4

Sw4

5

Sw5

6

GND

GND

 

2)The wiring between NRF24L01 and SunFounder Mega 2560 is as follows:

 

NRF24L01

SunFounder Mega 2560

CE

22

CSN

24

SCK

26

MOSI

28

MISO

30

IRQ

32

GND

GND

VCC

5V

 

 

 

 

 

Receiving Terminal

1)    The wiring between NRF24L01 and SunFounder Nano is as follows:


NRF24L01

SunFounder Nano

CE

8

CSN

9

SCK

10

MOSI

11

MISO

12

IRQ

13

GND

GND

VCC

5V


2)The wiring between 4-Channel Relay Module and SunFounder Nano is as follows:


4-Channel Relay Module

SunFounder Nano

IN1

6

IN2

5

IN3

4

IN4

3

VCC

3.3V

GND

GND

 

 

Step2: Program

Step3: Compile

Step4: Burn nrfTest_send into SunFounder Mega2560 and nrfTest_receive into SunFounder Nano

 

 


Summary

When you press button 1 on the sending board, relay 1 of the 4-channel relay module on the receiving board will be energized and IN1 will light up. When you press button 2, relay 2 will closed and IN2 will light up. The same as for button 3, button 4 and button 5.


Previous chapter: Hardware Description

Next chapter: DeviceBit Platform and Control Board Joint Test

SunFounder
Apr 12 2017 at 03:32 am



© Developed by CommerceLab