ADEEPT Ultimate Sensor Kit for Raspberry Pi Manual Download Page 26

 

 

In this experiment, we make the pin 11, 12, and 13 of the Raspberry Pi output PWM 
(pulse-width modulation) signals by programming, to make the RGB LED flash different 
colors. 

Experimental Procedures 

Step 1: Build the circuit 

 

For C language users: 

Step 2: Edit and save the code with vim or nano. 

(code path: /home/Adeept_Sensor_Kit_for_RPi_C_Code/03_rgbLed/rgbLed.c) 

Step 3: Compile 

$ sudo gcc rgbLed.c -o rgbLed -lwiringPi -lpthread

 

2

1

3

4

R

G

B

2

2

0

Ω

R

1

1

2

3

4

P

1

Header

2

2

0

Ω

R

2

2

2

0

Ω

R

3

+

R

G

B

Summary of Contents for Ultimate Sensor Kit for Raspberry Pi

Page 1: ......

Page 2: ...odule 1 3 DHT 11 Temperature and humidity Sensor 1 4 DS18B20 Digital temperature Sensor 1 5 Ultrasonic Distance Sensor Module 1 6 ADC0832 Module 1 7 BMP180 Barometer Sensor 1 8 ADXL345 Accelerometer 1 9 PS2 Joystick Module 1 10 Relay Module 1 11 DC Motor Module 1 ...

Page 3: ... 14 Potentiometer Module 1 15 Slide Potentiometer Module 1 16 Rotary Encoder Module 1 17 PIR Sensor Module 1 18 MQ 2 Gas Sensor Module 1 19 LED Bar Graph Module 1 20 Active Buzzer Module 1 21 Passive Buzzer Module 1 22 MIC Module 1 23 Touch Button Module 1 ...

Page 4: ... Module 1 26 Vibration Sensor Module 1 27 CM Module 1 28 Water Level Sensor Module 1 29 Soil Moisture Sensor Module 1 30 Photoresistor Module 1 31 Analog Temperature Sensor Thermistor Module 1 32 Hall Sensor Module 1 33 Limit Switch Module 1 ...

Page 5: ...Reed Module 1 35 RGB LED Module 1 36 Laser Transmitter Module 1 37 Laser Receiver Module 1 38 Button Module 4 39 LED Module 4 40 GPIO Extension Board 1 41 40P GPIO Cable 1 42 3 Pin Wires 8 43 4 Pin Wires 5 ...

Page 6: ...44 5 Pin Wires 3 45 Hookup Wire Set 1 46 2 Pin Female to Female Wires 1 47 Male to Female Jumper Wires 20 48 Breadboard 1 49 Band Resistor Card 1 ...

Page 7: ...rt and software service for general makers and electronic enthusiasts around the world We aim to create infinite possibilities with sharing No matter what field you are in we can lead you into the electronic world and bring your ideas into reality If you have any problems for learning please contact us at support adeept com or please ask questions in our forum www adeept com We will do our best to...

Page 8: ...tor 49 Lesson 12 Controlling an LED by Limit Switch 52 Lesson 13 Controlling an LED by Vibration Switch 55 Lesson 14 Rotary Encoder 59 Lesson 15 Controlling an LED by Touch Button 63 Lesson 16 Movement Detection Based on PIR 67 Lesson 17 Flame Sensor 71 Lesson 18 Line Finder 74 Lesson 19 Measuring the Temperature via DS18B20 77 Lesson 20 Temperature Humidity Sensor DHT 11 82 Lesson 21 Measuring th...

Page 9: ... Lesson 34 PS2 Joystick 128 Lesson 35 LCD1602 Display 131 Lesson 36 How to Make a Simple Thermometer 1 137 Lesson 37 How to Make a Simple Thermometer 2 139 Lesson 38 Make a Distance Measuring Device 142 Lesson 39 How to Make a Simple Voltmeter 1 145 Lesson 40 How to Make a Simple Voltmeter 2 148 ...

Page 10: ...puter to do from browsing the internet and playing high definition video to making spreadsheets word processing and playing games What s more the Raspberry Pi has the ability to interact with the outside world and has been used in a wide array of digital maker projects from music machines and parent detectors to weather stations and tweeting birdhouses with infra red cameras We want to see the Ras...

Page 11: ...mbering Raspberry Pi s GPIO 1 Numbering according to the physical location of the pins from left to right top to bottom the left is odd and the right is even 2 Numbering according the GPIO registers of BCM2835 2836 2837 SOC 3 Numbering according the GPIO library wiringPi ...

Page 12: ......

Page 13: ...wiringPi The wiringPi is a GPIO access library written in C language for BCM2835 6 7 SOC used in the Raspberry Pi It s released under the GNU LGPLv3 license and usable from C and C and many other languages with suitable wrappers It s designed familiar to people who have practiced the wiring system in the Arduino software For more information about wiringPi please visit http wiringpi com Install wi...

Page 14: ...rogram and set up the GPIO pins You can use it to read and write the pins or even control them from shell scripts You can verify whether the wiringPi is installed successfully or not by the following commands sudo gpio v sudo gpio readall If the information above is shown it indicates that the wiringPi has been installed successfully ...

Page 15: ...ow to use the wiringPi C library and RPi GPIO Python module here we take blinking an LED for example Step 1 Build the circuit according to the following schematic diagram For Python users Step 2 Create a file named led py sudo touch led py ...

Page 16: ... sudo vim led py Write the following source code then save and exit Step 4 Run sudo python led py Now you should see the LED blinking Press Ctrl C and the program execution will be terminated For C language users Step 2 Create a file named led c ...

Page 17: ... or nano sudo vim led c Write the following source code then save and exit Step 4 Compile the code sudo gcc led c lwiringPi After the command is executed you ll find a file named a out appear in the current directory It is an executable program Step 5 Run ...

Page 18: ...wiringpi com reference NOTE Before you continue learning please copy the source code provided with the kit to your Raspberry Pi s home directory or download the source code directly from our github repository C Language Source Code git clone https github com adeept Adeept_Sensor_Kit_for_RPi_C_Code Python Source Code git clone https github com adeept Adeept_Sensor_Kit_for_RPi_Python_Code ...

Page 19: ...ion Board 1 40 Pin GPIO Cable 1 Breadboard 1 LED Module 1 3 Pin Wires Experimental Principle The Fritzing images The Physical picture The schematic diagram In this experiment we make the pin 11 of the Raspberry Pi output High Low by programming to control the LED to blink in a certain frequency Experimental Procedures 2 2 0 Ω R 1 D 1 LED_P 1 2 3 P 1 Header N C ...

Page 20: ...t_for_RPi_C_Code 01_LED blinkingLed c Step 3 Compile sudo gcc blinkingLed c o led lwiringPi Step 4 Run sudo led For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 01_LED blinkingLed_1 py Step 3 Run sudo python blinkingLed_1 py Now you can see the LED blinking ...

Page 21: ......

Page 22: ...tch and usually used for device control Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 Button Module 1 LED Module 2 3 Pin Wires Experimental Principle The Fritzing image Pin definition S Output VCC GND The Physical picture The schematic diagram ...

Page 23: ...to pin 11 accordingly Experimental Procedures Step 1 Build the circuit For C language users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 02_btnAndLed btnAndLed_1 c Step 3 Compile 1 0 K R 1 1 2 3 P 1 Header Button S L E D 2 2 0 Ω R 2 G N D V C C V C C G N D V C C G N D ...

Page 24: ...o btnAndLed For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 02_btnAndLed btnAndLed_1 py Step 3 Run sudo python btnAndLed_1 py Press the button and you can see the LED toggle between on and off ...

Page 25: ...ely are packaged together thus by controlling the brightness of three LEDs making the RGB LED flash multiple colors Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 RGB LED Module 1 4 Pin Wires Experimental Principle The Fritzing image The Physical picture Pin definition B Blue Channel G Green Channel R Red Channel VCC The schematic diagram ...

Page 26: ...D flash different colors Experimental Procedures Step 1 Build the circuit For C language users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 03_rgbLed rgbLed c Step 3 Compile sudo gcc rgbLed c o rgbLed lwiringPi lpthread 2 1 3 4 R G B 2 2 0 Ω R 1 1 2 3 4 P 1 Header 2 2 0 Ω R 2 2 2 0 Ω R 3 R G B ...

Page 27: ...d For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 03_rgbLed py Step 3 Run sudo 03_rgbLed py Now you can see the RGB LED flash different colors alternately ...

Page 28: ...timer and so on Active buzzers can make sounds constantly when connected with a 5V DC supply This Active Buzzer module is connected to a digital pin of the Raspberry Pi When the pin outputs High level the buzzer will beep when the pin gives Low it stays dumb Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 Active Buzzer Module 1 3 Pin Wires Experimental Principle...

Page 29: ... alternately so the active buzzer makes sounds accordingly Experimental Procedures Step 1 Build the circuit For C language users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 04_activeBuzzer buzzer c Step 3 Compile Buzzer 1 K R 2 1 2 3 P 1 Header L E D 2 2 0 Ω R 1 S 3 2 1 NPN 8 0 5 0 ...

Page 30: ...n sudo buzzer For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 04_activeBuzzer py Step 3 Run sudo 04_activeBuzzer py Now you can hear the active buzzer beeps like the sound of Di Di ...

Page 31: ...rtain frequency causing magnetic fields alternation and then Mo sheet vibrating and making sounds On the other hand there is no driving circuit in a passive buzzer So the ideal signal for passive buzzer is square wave If DC is given it will not respond since the magnetic field is unchanged the vibration plate cannot vibrate and produce sounds Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 P...

Page 32: ...put square waves of different frequencies alternately thus driving the passive buzzer to play music Experimental Procedures Step 1 Build the circuit For C language users Step 2 Edit and save the code with vim or nano U 1 p a s s i v e b u z z e r 1 K R 2 1 2 3 P 1 H e a d e r L E D 2 2 0 Ω R 1 S 3 2 1 N P N 8 0 5 0 ...

Page 33: ...gcc passiveBuzzer c o passiveBuzzer lwiringPi lpthread Step 4 Run sudo passiveBuzzer For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 05_passiveBuzzer py Step 3 Run sudo 05_passiveBuzzer py Now you can hear the passive buzzer play music ...

Page 34: ...aches to its print surface the switch outputs Low when the N pole moves away the switch outputs High Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 Hall Sensor Module 1 LED Module 2 3 Pin Wires Experimental Principle The Fritzing image The Physical picture Pin definition S Output VCC GND ...

Page 35: ...oggle the LED based on the output signal of the hall sensor Experimental Procedures Step 1 Build the circuit For C language users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 06_hall hall c Step 3 Compile sudo gcc hall c o hall lwiringPi Step 4 Run sudo hall For Python users ...

Page 36: ... or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 06_hall py Step 3 Run sudo 06_hall py When you place the N pole of a magnet close to or move it away from the Hall Sensor the state of the LED will be toggled between ON and OFF ...

Page 37: ... the contact of the reed will sense it and become the opposite pole Due to the principle that different poles attract each other when the magnetic force is larger than resistance of the reed the open contacts sheets are closed when the magnetic force decreases to a certain degree the resistance takes charge again and the reed will back to the original state Components 1 Raspberry Pi 1 GPIO Extensi...

Page 38: ...hen toggle the LED based on the output signal of the reed switch Experimental Procedures Step 1 Build the circuit For C language users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 07_Reed reed c Step 3 Compile sudo gcc reed c o reed lwiringPi Step 4 Run ...

Page 39: ...save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 07_reed py Step 3 Run sudo 07_reed py Place the magnet near or away from the Reed Module and you will see the state of the LED will be toggled between ON and OFF ...

Page 40: ... large current or high volume devices like solenoid valve lamp and motor cannot be connected directly to digital I Os of the Raspberry Pi At this moment a relay can save your project Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 Relay Module 1 3 Pin Wires Experimental Principle The Fritzing image The Physical picture Experimental Procedures Step 1 Build the ci...

Page 41: ...de 08_relay relay c Step 3 Compile sudo gcc relay c o relay lwiringPi Step 4 Run sudo relay For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 08_relay py Step 3 Run sudo 08_relay py Now you can hear tick tocks which are the sounds of relay toggling ...

Page 42: ......

Page 43: ...tion ranging ladar ignition and blasting and testing instruments Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 Laser Transmitter Module 1 3 Pin Wires Experimental Principle The Fritzing image The Physical picture Pin definition S Input VCC GND The schematic diagram ...

Page 44: ...into the laser Experimental Procedures Step 1 Build the circuit For C language users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 09_Laser laser c Step 3 Compile sudo gcc laser c o laser lwiringPi 1 2 3 P 1 Header S 2 2 0 Ω R 1 Res L E D V C C G N D V C C 8 0 5 0 NPN 1 K R 2 G N D V C C G N D 1 2 U 1 Laser Emit ...

Page 45: ...ve the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 09_laser py Step 3 Run sudo 09_laser py Now you can see the Laser Transmitter Module emit laser and the emission lasts for 1 seconds and then it stops After 1s the cycle repeats ...

Page 46: ...he light intensity which then output electrical signal after running through the amplifier Then use an I O port of the Raspberry Pi to detect the output terminal of the Laser Receiver module and thus we can tell whether there are rays shone on the module Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 Laser Transmitter Module 1 Laser Receiver Module 2 3 Pin Wire...

Page 47: ...res Step 1 Build the circuit For C language users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 10_LaserRecv laserRecv c Step 3 Compile sudo gcc laserRecv c o laserRecv lwiringPi Step 4 Run sudo laserRecv For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 10_laserRecv py ...

Page 48: ...0_laserRecv py Make the Laser Transmitter module to shoot laser ray onto the Laser Receiver module Then Laser received will be displayed on the terminal Remove the transmitter module and Laser not received will be shown ...

Page 49: ...rical energy into mechanical energy Due to the ease of control it is usually used in fan electronic toy shaver etc Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 DC Motor Module 1 4 Pin Wires Experimental Principle The Fritzing image The Physical picture ...

Page 50: ... via the Raspberry Pi The statuses include forward stop and reverse Experimental Procedures Step 1 Build the circuit For C language users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 11_motor motor c Step 3 Compile sudo gcc motor c o motor lwiringPi ...

Page 51: ... motor For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 11_motor py Step 3 Run sudo 11_motor py Now you can see the fan rotates forward stop reverse ...

Page 52: ...ects like car and door When the moving object approaches the stationary one the switch is closed when the moving one moves away from the static one the switch is open Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 Limit Switch Module 1 LED Module 2 3 Pin Wires Experimental Principle The Fritzing image The Physical picture Pin definition S Output VCC GND ...

Page 53: ...oggle the LED based on the output signal of the limit switch Experimental Procedures Step 1 Build the circuit For C language users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 12_limitSwitch limitSwitch c C 1 N O 2 N C 3 S 1 Crash LED_P 2 2 0 Ω R 1 1 2 3 P 1 Header V C C G N D G N D V C C V C C LED_D 1 K R 2 G N D S ...

Page 54: ...limitSwitch For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 12_limitSwitch py Step 3 Run sudo 12_limitSwitch py Press the Limit Switch and you can see that the state of the LED will be toggled between ON and OFF ...

Page 55: ...e the distorted spring contacts and connects the electrode in the middle thus connecting the two pins and turning the sensor on When the force disappears the circuit is back to off This sensor module is suitable for small current vibration detection circuits and has been widely used in products such as toys light shoes burglar alarms electronic scales flash dance shoes hot wheels flash balls etc C...

Page 56: ...ment is to make the LED that connected to the pin 11 of Raspberry Pi flicker with the actions of the Vibration Sensor module Experimental Procedures Step 1 Build the circuit 1 2 S 1 SW_540 2 2 0 Ω R 1 L E D G N D V C C 5 1 0 K R 2 1 2 3 P 1 V C C V C C G N D G N D S ...

Page 57: ...c Step 3 Compile sudo gcc vibration c o vibration lwiringPi Step 4 Run sudo vibration For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 13_vibration py Step 3 Run sudo 13_vibration py Knock or tap the Vibration Sensor module and you ll see the status of LED will be toggled ...

Page 58: ......

Page 59: ...ollaboration with a microcontroller For example in daily life you can see page turning of the mouse menu selection volume adjustment of speakers temperature adjustment of toaster frequency adjustment of medical equipment etc Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 Rotary Encoder Module 1 5 Pin Wires Experimental Principle The Fritzing image The Physical ...

Page 60: ... clockwise the value on the terminal will increase when we turn the knob counterclockwise the value will decrease When we press down the switch the value will be zeroed out Experimental Procedures Step 1 Build the circuit 1 2 3 4 5 P 1 A 1 B 2 C 3 SW 4 SW 5 E 1 Rotary Encoder 1 0 K R 1 1 0 K R 2 2 2 0 Ω R 3 D 1 L E D A B S V C C V C C V C C V C C V C C 1 0 K R 4 G N D G N D G N D G N D ...

Page 61: ...Pi_C_Code 14_RotaryEncoder rotaryEncoder c Step 3 Compile sudo gcc rotaryEncoder c o rotaryEncoder lwiringPi Step 4 Run sudo rotaryEncoder For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 14_rotaryEncoder py Step 3 Run sudo rotaryEncoder py ...

Page 62: ... rotary encoder and the value printed on the screen will change Rotate the rotary encoder clockwise the value will increase Rotate it counterclockwise the value will decrease Press the rotary encoder the value will be reset to 0 ...

Page 63: ...ouch with certain materials like plastic and glass between The sensitivity in these cases depends on the touched area and thickness of the material between the touch pad and human or metal The module can be conveniently used to replace physical buttons Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 Touch Button Module 1 LED Module 2 3 Pin Wires Experimental Pri...

Page 64: ...h Button Module by pin 12 of the Raspberry Pi so as to tell whether fingers touched the touch button or not Experimental Procedures Step 1 Build the circuit O U T 1 G N D 2 I N 3 A H L B 4 V C C 5 T O G 6 U 1 TTP223 L E D 2 2 p F Cup 1 K R 1 2 2 0 Ω R 2 1 B 1 touch button 1 2 3 P 1 Header G N D G N D G N D G N D G N D V C C V C C Data Data S ...

Page 65: ...tn c Step 3 Compile sudo gcc touchBtn c o touchBtn lwiringPi Step 4 Run sudo touchBtn For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 15_touchBtn py Step 3 Run sudo python 15_touchBtn py Touch the Touch Button Module and you can see the LED toggle between on and off ...

Page 66: ......

Page 67: ...r is a large one with complicated circuits and comparatively less credible But this Infrared pyroelectric motion sensor adopts the digital integration of the probe so it boasts high credibility low power consumption and simple outside circuit with a small size It can be applied to any cases in detecting moving human or animals Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 ...

Page 68: ...ent is to use the PIR Sensor Module to detect whether there is any human activity Experimental Procedures Step 1 Build the circuit 1 2 3 P 1 3 3V G N D 3 3 V 1 K R 1 Res D 1 3 3V G N D V D D 1 R E L 2 VSS 3 U 1 PIR AS312 G N D 3 3V G N D D 2 2 2 0 Ω R 2 Res S ...

Page 69: ...pir c Step 3 Compile sudo gcc pir c o pir lwiringPi Step 4 Run sudo pir For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 16_PIR py Step 3 Run sudo python 16_PIR py When the PIR module detects human movement Someone invasion will be displayed on the terminal ...

Page 70: ......

Page 71: ...sensor can be used to detect light intensity It can detect a light source with a wavelength of 760 1100nm Pin A outputs the analog data collected by the sensor You can adjust the potentiometer on the module to set the alarm threshold of the sensor So when the value reaches the threshold pin S will switch between High and Low Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Br...

Page 72: ...hether a flame has been encountered Experimental Procedures Step 1 Build the circuit For C language users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 17_flame flame c Step 3 Compile sudo gcc flame c o flame lwiringPi Step 4 Run sudo flame ...

Page 73: ...m or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 17_flame py Step 3 Run sudo python 17_flame py Then you ll see the data detected by the Flame Sensor module on the terminal The data includes two parts Fire detected or not and Flame intensity ...

Page 74: ...ays are received by the receiver on the module On the other hand when they come across a black one the receiver cannot get any infrared Thus the processor can tell whether it is a white or black detected surface by receiving the reflected infrared rays or not Based on this the module is usually used in line finding on a smart car Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable...

Page 75: ...ite and another of black paper via the Line Finder Module Experimental Procedures Step 1 Build the circuit For C language users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 18_tracking tracking c Step 3 Compile ...

Page 76: ...vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 18_ tracking py Step 3 Run sudo python 18_tracking py Place the sensor module over a piece of white paper and another of black and you will see the data detected on the terminal You can adjust the blue potentiometer on the module to change the sensitivity ...

Page 77: ...oint network and multi point temperature measurement the measured result is sent to the controller via serial port in the format of a 9 12 bit number This digital sensor can be applied to various microcontrollers It s simpler on Raspberry Pi Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 DS18B20 Module 1 3 Pin Wires Experimental Principle The Fritzing image The...

Page 78: ...alue collected by the DS18B20 module through pin 7 of the Raspberry Pi and display it on the terminal Experimental Procedures Step 1 Build the circuit G N D 1 D Q 2 V C C 3 D 3 D S 1 8 B 2 0 1 2 3 P 1 H e a d e r S 2 2 0 Ω R 1 D 1 L E D V C C G N D 1 0 K R 3 1 K Ω R 2 D 2 L E D V C C V C C V C C G N D V C C G N D ...

Page 79: ...dify the configuration files sudo vim boot config txt Then scroll to the bottom and type dtoverlay w1 gpio Then reboot Raspberry Pi sudo reboot Mount the device drivers and confirm whether the device is effective or not sudo modprobe w1 gpio sudo modprobe w1 therm cd sys bus w1 devices ls ...

Page 80: ... w1_slave 28 00000495db35 cat w1_slave a3 01 4b 46 7f ff 0d 10 ce crc ce YES a3 01 4b 46 7f ff 0d 10 ce t 28154 The second line t 28154 is current temperature value If you want to convert it to degree Celsius you can divide by 1000 that is the current temperature is 28154 1000 28 154 For C language users Step 5 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code...

Page 81: ...Now you can see the current temperature is printed on the terminal ...

Page 82: ...dity analog values into digital values via corresponding sensitive components and built in circuits which can be directly read by computer or other data collecting devices Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 DHT 11 Sensor Module 1 3 Pin Wires Experimental Principle The Fritzing image The Physical picture Pin definition S Digital output VCC GND ...

Page 83: ...dule by pin 11 of the Raspberry Pi and display it on the terminal Experimental Procedures Step 1 Build the circuit For C language users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 20_dht11 dht11 c Step 3 Compile sudo gcc dht11 c o dht11 lwiringPi Step 4 Run sudo dht11 ...

Page 84: ...dit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 20_dht11 py Step 3 Run sudo python 20_dht11 py Now you will see the data of current temperature and humidity displayed on the terminal ...

Page 85: ... so please first connect the GND and then other pins otherwise the module may not work 2 During the ranging the area of the targeted object should be no less than 0 5cm and the surface facing the module should be as flat as possible otherwise the result may be inaccurate Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 Ultrasonic Sensor Module 4 Jumper Wires Expe...

Page 86: ...nd show the data sensed on the terminal Experimental Procedures Step 1 Build the circuit For C language users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 21_ultrasonicSensor distance c Step 3 Compile sudo gcc distance c o distance lwiringPi Step 4 Run sudo distance For Python users ...

Page 87: ...im or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 21_distance py Step 3 Run sudo python 21_distance py Now you will see the distance to the obstacle at front of the Ultrasonic Distance Sensor module displayed on the terminal ...

Page 88: ...l as dynamic acceleration resulting from motion or shock Its high resolution 3 9 mg LSB enables measurement of inclination changes less than 1 0 Low power modes enable intelligent motion based power management with threshold sensing and active acceleration measurement at extremely low power dissipation Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 ADXL345 Acce...

Page 89: ...code with vim or nano Code path home Adeept_Sensor_Kit_for_RPi_C_Code 22_ADXL345 adxl345 c Step 3 Compile gcc adxl345 c o adxl345 lwiringPi Step 4 Run sudo adxl345 For Python users Step 2 Edit and save the code with vim or nano Code path home Adeept_Sensor_Kit_for_RPi_Python_Code 22_ADXL345 py Step 3 Run sudo python 22_ADXL345 py Now you should see the acceleration data displayed on the terminal ...

Page 90: ......

Page 91: ...low power consumption down to 3uA makes the BMP180 the leader in power saving for your mobile devices BMP180 is also distinguished by its very stable behavior performance with regard to the independency of the supply voltage Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 BMP180 Module 1 4 Pin Wires Experimental Principle The Fritzing image The Physical picture ...

Page 92: ...ano Code path home Adeept_Sensor_Kit_for_RPi_C_Code 23_bmp180 bmp180dev3 c Step 3 Compile gcc bmp180dev3 c o bmp180 lm Step 4 Run sudo bmp180 For Python users Step 2 Edit and save the code with vim or nano Code path home Adeept_Sensor_Kit_for_RPi_Python_Code 23_bmp180 examples simpletest py Step 3 Run sudo python simpletest py Now you should see the atmospheric pressure and altitude data displayed...

Page 93: ......

Page 94: ...PI Serial Peripheral Interface It only occupies three I Os of the Raspberry Pi and save precious ones for connecting other devices Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 8 8 LED Matrix Module 1 5 Pin Wires Experimental Principle The Fritzing image The Physical picture Pin definition DS Input SH_CP Input ST_CP Input VCC GND ...

Page 95: ...res Step 1 Build the circuit For C language users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 24_ledMatrix ledMatrix c Step 3 Compile sudo gcc ledMatrix c o ledMatrix lwiringPi Step 4 Run sudo ledMatrix For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 24_LedMatrix py ...

Page 96: ...Step 3 Run sudo python 24_LedMatrix py Now you can see on the dot matrix module Adeept is displayed in the way of scrolling ...

Page 97: ...O Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 LED Bar Module 1 4 Pin Wires Experimental Principle The Fritzing image The Physical picture Pin definition DI Data In DCLK Clock VCC GND The experiment is to control the number of LEDs brightened on the LED bar graph by programming the Raspberry Pi Experimental Procedures Step 1 Build the circuit ...

Page 98: ... Step 3 Compile sudo gcc ledBar c o ledBar lwiringPi lm Step 4 Run sudo ledBar For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 25_ledBar py Step 3 Run sudo python 25_ledBar py Now you can see the LEDs on the LED Bar Graph module light up and dim one by one repeatedly ...

Page 99: ......

Page 100: ...8 It communicates with the Raspberry Pi via three wires and can show numbers and simple characters Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 Segment Display Module 1 5 Pin Wires Experimental Principle The Fritzing image The Physical picture Pin definition STB Chip Select CLK Clock DIO Data VCC GND ...

Page 101: ...users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 26_segmentDisplay segment c Step 3 Compile sudo gcc segment c o segment lwiringPi Step 4 Run sudo segment For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 26_segment py ...

Page 102: ...Step 3 Run sudo python 26_segment py Now you can see the number 0 9999 shown repeatedly on the digital display ...

Page 103: ...d the moving contact or wiper slides along the resistor Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 ADC0832 Module 1 Potentiometer Module 1 Slide Potentiometer Module 2 3 Pin Wires 1 5 Pin Wires Experimental Principle The Fritzing image The Physical picture Pin definition A Analog Output VCC GND ...

Page 104: ...t the analog values output by the Potentiometer module through pin CH0 of the ADC0832 convert it to digital values and display them on the terminal Experimental Procedures Step 1 Build the circuit 1 2 3 P 1 Header V C C G N D A 1 0 K R 1 RPot V C C G N D 2 2 0 Ω R 2 L E D V C C G N D ...

Page 105: ......

Page 106: ...udo gcc potentiometer c o potentiometer lwiringPi Step 4 Run sudo potentiometer For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 27_potentiometer py Step 3 Run sudo python 27_potentiometer py Turn the knob on the Potentiometer module you will find that the value displayed on the terminal is changed ...

Page 107: ......

Page 108: ...of the photoresistor we use decreases with stronger incident light and increases with weaker light In experiments and daily light photoresistors are usually used for detecting light intensity Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 ADC0832 Module 1 Photoresistor Module 2 3 Pin Wires 1 5 Pin Wires Experimental Principle The Fritzing image The Physical pic...

Page 109: ...esistor module and then display it on the terminal Experimental Procedures Step 1 Build the circuit For C language users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 28_photoresistor photoresistor c R 2 Photoresistor 1 2 3 P 1 Header 1 0 K R 1 A ...

Page 110: ...with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 28_photoresistor py Step 3 Run sudo python 28_photoresistor py Now when you try to cover to the photoresistor you will find that the value displayed on the screen decreasing On the contrary when you shine the photoresistor with strong light the value displayed will increase ...

Page 111: ...s resistance varies with ambient temperature changes For PTC thermistor when the temperature gets high its resistance increases for NTC thermistor the case is the opposite The thermistor we use is an NTC one Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 ADC0832 Module 1 Thermistor Module 2 3 Pin Wires 1 5 Pin Wires Experimental Principle The Fritzing image The...

Page 112: ...ollect the analog values output by the Thermistor module through CH0 of the ADC0832 change it to digital values and display them on terminal Experimental Procedures Step 1 Build the circuit 1 2 3 P 1 Header 1 0 K R 1 A L E D 2 2 0 Ω R 2 G N D V C C V C C G N D V C C G N D R T Thermistor ...

Page 113: ...ompile sudo gcc thermistor c o thermistor lwiringPi Step 4 Run sudo thermistor For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 29_thermistor py Step 3 Run sudo python 29_thermistor py Now touch the thermistor and you can see the value displayed on the screen which changes accordingly ...

Page 114: ......

Page 115: ...increase The surface of the sensor is gilded to prolong its life Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 Water Level Module 1 LM393 CM Comparator Module 1 ADC0832 Module 1 2 Pin Wires 1 3 Pin Wires 1 4 Pin Wires 1 5 Pin Wires Experimental Principle The Fritzing images The Physical picture This experiment collects the data of water level by the Water Leve...

Page 116: ...ep 4 Run sudo waterLevel For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 30_waterLevel py Step 3 Run sudo python 30_waterLevel py Take a bottle with some water Place the Water Level Sensor module in the water at end and add water into the bottle You will see the value of water level displayed on the terminal and changes as you ad...

Page 117: ......

Page 118: ... circuits When using the module you can set a threshold via the blue potentiometer beforehand When the input analog value reaches the threshold the digital pin S will output a Low level Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 Soil Moisture Sensor Module 1 LM393 CM Module 1 ADC0832 Module 1 2 Pin Wires 1 3 Pin Wires 1 4 Pin Wires 1 5 Pin Wires Experimenta...

Page 119: ...cc soilMoisture c o soilMoisture lwiringPi Step 4 Run sudo soilMoisture For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 31_soilMoisture py Step 3 Run sudo python 31_soilMoisture py Plug the sensor into the soil you will see the value of soil moisture collected by the module displayed on the terminal ...

Page 120: ......

Page 121: ...ust fan With the features it boasts a perfect sensor for indoor air regulation that meets the environmental standards Notes 1 This sensor is equipped with an adjustment potentiometer for the alarm threshold Spin the knob of the pot clockwise and the threshold will be increased spin it counterclockwise the threshold will be reduced 2 The sensor may not output a steady and accurate data immediately ...

Page 122: ...l Output A Analog Output VCC GND In this experiment by programming the Raspberry Pi we read the analog values collected by the MQ 2 Gas Sensor and display them on the terminal Experimental Procedures Step 1 Build the circuit ...

Page 123: ...code path home Adeept_Sensor_Kit_for_RPi_C_Code 32_MQ 2 mq 2 c Step 3 Compile sudo gcc mq 2 c o mq 2 lwiringPi Step 4 Run sudo mq 2 For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 32_mq 2 py Step 3 Run ...

Page 124: ...ython 32_mq 2 py Release some methane near the module and you will see the corresponding message on the terminal indicating flammable gases Also the value output by the analog pin of the module will be printed ...

Page 125: ...old of the comparator can be adjusted by the blue potentiometer on the module This module can be applied in sound alarm system Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 MIC Module 1 ADC0832 Module 1 3 Pin Wires 1 4 Pin Wires 1 5 Pin Wires Experimental Principle The Fritzing image The Physical picture Pin definition S Digital Output A Analog Output VCC GND ...

Page 126: ...he circuit For C language users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 33_mic mic c Step 3 Compile sudo gcc mic c o mic lwiringPi Step 4 Run sudo mic For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 33_mic py ...

Page 127: ...c py Blow at the MIC Module or make some other sounds near it and you can see the value on the terminal indicating the sound intensity The higher the sound volume the larger value on the terminal the lower volume the smaller value ...

Page 128: ...one channel digital output which indicates whether the user has pressed the button at z axis or not The Joystick Module can be used to easily control the object to move in a three dimensional space For example it can be applied to control crane truck electronic games robots etc Components 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 PS2 Joystick Module 1 ADC0832 Module ...

Page 129: ...ircuit For C language users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 34_PS2Joystick joystick c Step 3 Compile sudo gcc joystick c o joystick lwiringPi Step 4 Run sudo joystick For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 34_PS2Joystick py ...

Page 130: ...Step 3 Run sudo python 34_PS2Joystick py Press or pull the knob and you will see the value of current status displayed on the terminal ...

Page 131: ... each PCF8574 based I2C Interface Module Since there are limited I O ports on the Raspberry Pi if you use them to drive the LCD1602 it needs many of the ports and there may be insufficient to connect other devices To solve this problem an IIC or I2C Interface Module based on PCF8574 is designed to extend the I O ports of the Raspberry Pi You only need two wires SDA and SCL to control the LCD1602 a...

Page 132: ...the second experiment is controlling via PCF8574 based IIC module Experiment 1 Procedures Step 1 Build the circuit For C language users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 35_LCD1602 lcd1602 c Step 3 Compile sudo gcc lcd1602 c o lcd1602 lwiringPi lwiringPiDev ...

Page 133: ...2 For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 35_LCD1602 lcd1602 py Step 3 Run sudo python lcd1602 py Experiment 2 Procedures Step 1 Build the circuit ...

Page 134: ...Step 2 The I2C of the Raspberry Pi is not turned on by default we can use raspi config to enable it sudo raspi config Use the down arrow to select 5 Interfacing Options ...

Page 135: ... The system will reboot when it comes back up log in and enter the following command ls dev i2c The Pi should respond with dev i2c 1 Which represents the user mode I2C interface For C language users Step 3 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 35_LCD1602 i2c_lcd1602 c Step 4 Compile sudo gcc i2c_lcd1602 c o i2c_lcd1602 lwiringPi lwiringPiDev Step 5...

Page 136: ...r_RPi_Python_Code 35_LCD1602 i2c_lcd1602 py Step 4 Run sudo python i2c_lcd1602 py NOTE If characters are not displayed on the LCD try to turn the potentiometer a blue knob for contrast adjustment on the I2C Interface Module Or you can toggle the switch on the module to see whether the backlight is on ...

Page 137: ...omponents 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 DS18b20 Module 1 Segment Display Module 1 5 Pin Wires 1 3 Pin Wires Experimental Principle In this experiment we program the Raspberry Pi to read DS18b20 temperature sensor and then display the temperature on the segment display module Experimental Procedures Step 1 Build the circuit ...

Page 138: ...r_RPi_C_Code 36_thermometer_1 Step 3 Compile sudo build sh Step 4 Run sudo main For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 36_thermometer_1 Step 3 Run sudo python main py Now you can see the temperature shown on the segment display ...

Page 139: ...nents 1 Raspberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 DS18b20 Module 1 I2C Interface Module 1 LCD1602 1 4 Pin Wires 1 3 Pin Wires Experimental Principle In this experiment we program the Raspberry Pi to read DS18b20 temperature sensor and then display the temperature on the LCD1602 Experimental Procedures Step 1 Build the circuit ...

Page 140: ...nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 37_thermometer_2 Step 3 Compile sudo build sh Step 4 Run sudo main For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 37_thermometer_2 Step 3 Run ...

Page 141: ... sudo python main py Now you can see the temperature shown on the LCD1602 ...

Page 142: ...spberry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 LCD1602 1 I2C Interface Module 1 Ultrasonic Sensor Module 1 4 Pin Wires 4 Jumper Wires Experimental Principle In this experiment we program the Raspberry Pi to detect the distance between the obstacle and ultrasonic module and then display the data on the LCD1602 Experimental Procedures Step 1 Build the circuit ...

Page 143: ...Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 38_measureDis Step 3 Compile sudo build sh Step 4 Run sudo main For Python users Step 2 Edit and save the code with vim or nano ...

Page 144: ...h home Adeept_Sensor_Kit_for_RPi_Python_Code 38_measureDis Step 3 Run sudo python main py Now you will see the distance to the obstacle at front of the Ultrasonic Distance Sensor module displayed on the LCD1602 ...

Page 145: ...rry Pi 1 GPIO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 ADC0832 Module 1 Segment Display Module 1 Slide Potentiometer Module 2 5 Pin Wires 2 3 Pin Wires Experimental Principle In this experiment we program the Raspberry Pi to read voltage DC 0 5V via ADC0832 and then display the voltage value on the segment display module Experimental Procedures Step 1 Build the circuit ...

Page 146: ...e path home Adeept_Sensor_Kit_for_RPi_C_Code 39_voltmeter_1 Step 3 Compile sudo build sh Step 4 Run sudo main For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 39_voltmeter_1 Step 3 Run sudo python main py ...

Page 147: ...Now you can see the voltage value shown on the segment display ...

Page 148: ...IO Extension Board 1 40 Pin GPIO Cable 1 Breadboard 1 ADC0832 Module 1 I2C Interface Module 1 Slide Potentiometer Module 1 LCD1602 2 3 Pin Wires 1 4 Pin Wires 1 5 Pin Wires Experimental Principle In this experiment we program the Raspberry Pi to read voltage DC0 5V via ADC0832 and then display the voltage value on the LCD1602 Experimental Procedures Step 1 Build the circuit ...

Page 149: ... vim or nano code path home Adeept_Sensor_Kit_for_RPi_C_Code 40_voltmeter_2 Step 3 Compile sudo build sh Step 4 Run sudo main For Python users Step 2 Edit and save the code with vim or nano code path home Adeept_Sensor_Kit_for_RPi_Python_Code 40_voltmeter_2 ...

Page 150: ...Step 3 Run sudo python main py Now you can see the voltage value shown on the LCD1602 ...

Page 151: ......

Reviews: