Page 1
Welcome! Thank you for purchasing our AZ-Delivery KY-032 Obstacle Detector Module. On the following pages, you will be introduced to how to use and set up this handy device. Have fun!
Page 2
Areas of application Education and teaching: Use in schools, universities and training institutions to teach the basics of electronics, programming and embedded systems. Research and development: Use in research and development projects to create prototypes and experiments in the fields of electronics and computer science. Prototype development: Use in the development and testing of new electronic circuits and devices.
Page 3
consult a doctor. Caution: Keep the product out of the reach of children and pets to avoid accidental contact and swallowing of small parts. Note: Store the product in a safe, closed container when not in use. Attention: Avoid contact of the product with food and drinks.
Table of Contents Introduction......................3 Specifications....................4 The pinout......................6 The schematic....................7 How to set-up Arduino IDE................9 How to set-up the Raspberry Pi and Python..........13 Connecting the module with Atmega328p.............14 Sketch example..................15 Connecting the module with Raspberry Pi.............18 Python script....................19 - 2 -...
Introduction At the heart of the KY-032 module is a NE555 timer oscillator chip configured to generate a 38kHz square wave. The 38kHz signal is used to turn ON an infrared LED at that frequency. Light sent by infrared LED gets reflected from the obstacle and then detected by an HS0038B infrared receiver module.
Specifications » Operating voltage range: from 3.3V to 5V DC » Working current: ~20mA » Detection distance: from 20mm to 400mm » Detection angle: 60° » Dimensions: 27 x 45mm [1.1 x 1.8in] » Output: LOW - obstacle detected HIGH - obstacle is not detected The potentiometer near the NE555 chip (R6 on the schematic diagram) is used to fine tune the signal to exactly 38kHz.
Page 7
When the jumper is installed on the board, the infrared LED is turned ON continuously at a frequency of 38kHz. If the Enable function is not used, the jumper must be installed. When the jumper is removed, pin 4 of the NE555 chip is held LOW (RESET state) by a 22kΩ...
How to set-up Arduino IDE If the Arduino IDE is not installed, follow the link and download the installation file for the operating system of choice. For Windows users, double click on the downloaded .exe file and follow the instructions in the installation window. - 8 -...
Page 11
For Linux users, download a file with the extension .tar.xz, which has to be extracted. When it is extracted, go to the extracted directory and open the terminal in that directory. Two .sh scripts have to be executed, the first called arduino-linux-setup.sh and the second called install.sh.
Page 12
Almost all operating systems come with a text editor preinstalled (for example, Windows comes with Notepad, Linux Ubuntu comes with Gedit, Linux Raspbian comes with Leafpad, etc.). All of these text editors are perfectly fine for the purpose of the eBook. Next thing is to check if your PC can detect an Atmega328p board.
Page 13
If the Arduino IDE is used on Windows, port names are as follows: For Linux users, for example port name is /dev/ttyUSBx, where x represents integer number between 0 and 9. - 11 -...
How to set-up the Raspberry Pi and Python For the Raspberry Pi, first the operating system has to be installed, then everything has to be set-up so that it can be used in the Headless mode. The Headless mode enables remote connection to the Raspberry Pi, without the need for a PC screen Monitor, mouse or keyboard.
Connecting the module with Atmega328p Connect the KY-032 module with the Atmega328p as shown on the following connection diagram: KY-032 pin > Mc pin > Black wire > Red wire > Blue wire NOTE: Do not remove the jumper from the KY-032 module, because the ENABLE mode is not used in the sketch.
Page 17
Upload the sketch to the Atmega328p and open Serial Monitor (Tools > Serial Monitor). The result should look like the output on the following image: - 15 -...
Page 18
Sketch starts by defining and initializing one macro called SIGNAL_PIN. This macro represents the digital pin of Atmega328p on which signal pin of the module is connected. Next, one boolean variable called object_detect is defined and initialized with value false. The value stored in this variable is used to signalize the object detection in front of the module.
Connecting the module with Raspberry Pi Connect the KY-032 module with the Raspberry Pi as shown on the following connection diagram: KY-032 pin > Raspberry Pi pin > [pin 9] Black wire > GPIO22 [pin 15] Blue wire > [pin 17]...
Python script import RPi.GPIO GPIO from time import strftime, localtime, sleep GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) Signal_PIN GPIO.setup(Signal_PIN, GPIO.IN) object_detect false print('[Press CTRL + C to end the script!]') try: # Main program loop while True: GPIO.input(Signal_PIN): object_detect false else: sleep(0.0005) # wait for 500 microseconds GPIO.input(Signal_PIN): object_detect false...
Page 21
Save the script by the name obstacle.py. To run the script open terminal in the directory where the script is saved and run the following command: python3 obstacle.py The result should look like the output on the following image: To end the script press CTRL + C on the keyboard. This script does the same thing as the sketch from the Sketch example chapter.
Page 22
If you are looking for the high quality microelectronics and accessories, AZ-Delivery Vertriebs GmbH is the right company to get them from. You will be provided with numerous application examples, full installation guides, eBooks, libraries and assistance from our technical experts.
Need help?
Do you have a question about the KY-032 and is the answer not in the manual?
Questions and answers