Advertisement

Quick Links

Welcome!
Thank you for purchasing our AZ-Delivery KY-035 Linear Magnetic Sensor
Module. On the following pages, you will be introduced to how to use and set
up this handy device.
Have fun!

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the KY-035 and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for AZ-Delivery KY-035

  • Page 1 Welcome! Thank you for purchasing our AZ-Delivery KY-035 Linear Magnetic Sensor 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.
  • Page 4: Table Of Contents

    Table of Contents Introduction......................3 Specifications....................4 The pinout......................5 How to set-up Arduino IDE................6 How to set-up the Raspberry Pi and Python..........10 Connecting the module with Atmega328p............11 Sketch example..................12 Connecting the module with Raspberry Pi.............14 Python script....................25 - 2 -...
  • Page 5: Introduction

    The most popular uses are in proximity sensing, detecting speeds of spinning objects or as door sensors. Due to the nature of the sensing, the contactless sensing, the KY-035 module is very durable and there is no wearing associated with the use.
  • Page 6: Specifications

    Specifications » Operating voltage range: from 2.3V to 6.5V DC » Power consumption: 4mA at 5 V DC » Sensitivity: 1.4 ~ 3.0mV/GS on 25℃ » Output: linear analog voltage » Temperature range: from -40°C to 100°C [-40°F to 212°F] »...
  • Page 7: The Pinout

    The pinout The KY-035 linear magnetic sensor module has three pins. The pinout diagram is shown on the following image: - 5 -...
  • Page 8: How To Set-Up Arduino Ide

    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. - 6 -...
  • Page 9 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 10 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 11 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. - 9 -...
  • Page 12: How To Set-Up The Raspberry Pi And Python

    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.
  • Page 13: Connecting The Module With Atmega328P

    Connecting the module with Atmega328p Connect the KY-035 module with the Atmega328p as shown on the following connection diagram: KY-035 pin > Mc pin > Blue wire - (GND) > Black wire Middle pin (VCC) > Red wire - 11 -...
  • Page 14: Sketch Example

    Sketch example #define ANALOG_PIN A0 void setup() { Serial.begin(9600); void loop() { Serial.println(analogRead(ANALOG_PIN)); delay(1000); - 12 -...
  • Page 15 Upload the sketch to the Atmega328p and open Serial Monitor (Tools > Serial Monitor). The result should look like the outpu on the following image: - 13 -...
  • Page 16: Connecting The Module With Raspberry Pi

    Connecting the module with Raspberry Pi Because the Raspberry Pi does not have Analog to Digital Converter (ADC), but for purpose of using the KY-035 module with the Raspberry Pi, the Raspberry Pi has to be able to read analog voltages. The Atmega328p can be used for the purpose.
  • Page 17 To download and install the Arduino IDE, go on the site and download the tar.xz file of Arduino IDE for as shown on the Linux ARM 32 bits following image: Then, the tar.xz file has to be extracted. Open the File explorer in directory where the tar.xz file is downloaded, right click on it, and run the option Extract Here.
  • Page 18 Open terminal in extracted folder and run the following command: sh arduino-linux-setup.sh pi where pi is the name of the superuser in Raspbian. After this, to install the Arduino IDE, run the following command: sudo sh install.sh - 16 -...
  • Page 19 The Arduino IDE is now installed. To run Arduino IDE, open the app: Applications Menu > Programming > Arduino IDE Before next steps, first the pip3 and git apps have to be installed; run the following command: sudo apt install python3-pip git -y The library for Python is called nanpy.
  • Page 20 After installing the nanpy library, download an Atmega328p firmware by running the following command: git clone https://github.com/nanpy/nanpy-firmware.git Change directory to nanpy-firmware by running the following command: cd nanpy-firmware And run the following command: sh configure.sh Next, copy the nanpy-firmware directory into Arduino/libraries directory.
  • Page 21 Connect the Atmega328p via the USB cable to the Raspberry Pi and then open the Arduino IDE in the Raspbian operating system. Check if the Arduino IDE can detect the USB port to which the Atmega328p is connected: Tools > Port > dev/ttyUSB0 Then go to: Tools >...
  • Page 22 Upload the sketch to the Atmega328p. To test if eveyrhing works properly, the simple Blink script has to be created, where the on-board LED of the Atmega328p is blinked. Open terminal, create the Scripts directory and the Blink.py script. To do so, run the following commands, one by one: - create to the Scripts directory mkdir Scrpits...
  • Page 23 In the Blink.py script write the following lines of code: from nanpy import (ArduinoApi, SerialManager) from time import sleep ledPin try: connection1 SerialManager() ArduinoApi(connection=connection1) except: print('Failed to connect to the Arduino') print('[Press CTRL + C to end the script!]') a.pinMode(ledPin, a.OUTPUT) # Setup Arduino try: while...
  • Page 24 Save the script. To run the script, open terminal in the directory where the script is saved and run the following command: python3 Blink.py The result should look like the output on the following image: To stop the script press CTRL + C on the keyboard. The LED connected to the digital pin 13 of the Atmega328p should start blinking every second.
  • Page 25 The script starts with importing two libraries, the nanpy library functions, and the time. Then, the variable called ledPin is created and initialized with number 13. The number 13 represents the number of the digital pin on which LED is connected (on-board LED of the Atmega328p).
  • Page 26 In the indefinite loop block, the LED is first turned ON for a second, and then turned OFF for a second. This is called blinking the LED. The time interval of a single blink can be changed in the following line of code: sleep(1) Where the number 1 represents the number of seconds for the duration of the time interval.
  • Page 27: Python Script

    Python script for KY-035 module Connect the KY-035 module with the Atmega328p as shown on the connection diagram from the chapter Connecting the module, and then connect the Atmega328p with the Raspberry Pi via USB cable. Next, upload nanpy firmware to the Atmega328p, and use the following code to read the...
  • Page 28 Save the script by name linMagnetic.py. To run the script open the terminal in the directory where the script is saved and run the following command: python3 linMagnetic.py The result should look like the output on the following image: To stop the script press CTRL + C on the keyboard. - 26 -...
  • Page 29 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.

Table of Contents