edit

Grove - Digital Distance Interrupter 0.5 to 5cm(GP2Y0D805Z0F)(P)

Grove - Digital Distance Interrupter 0.5 to 5cm is an infrared distance sensing module based on GP2Y0D805Z0F. Normaly the output of this sensor is 1(High), when the object enters the measurement range of the sensor, it will be triggered and output a 0(LOW).At the same time the on-board LED will light up. As the name suggests, the measurement range is from 0.5cm to 5cm.

There are two types of Grove - Digital Distance Interrupter 0.5 to 5cm: Grove - Digital Distance Interrupter 0.5 to 5cm(GP2Y0D805Z0F) and Grove - Digital Distance Interrupter 0.5 to 5cm(GP2Y0D805Z0F)(P). For the version without letter P, the lens and the grove interface are at the same side; for the version with letter P, the lens and the grove interface are at the different sides.

GP2Y0D805Z0F is a distance measuring sensor unit, composed of an integrated combination of PD(photo diode) , IRED (infrared emitting diode) and signal processing circuit. The variety of the reflectivity of the object, the environmental temperature and the operating duration are not influenced easily to the distance detection because of adopting the triangulation method.

Features

  • Easy to use
  • Integrated indicator LED
  • Digital output

Specification

Item Value
Working voltage 3.3v/5v
Trigger Range 0.5cm - 5cm
Working temperature -10℃ -- 60℃

Applications

  • Touch-less switch (Sanitary equipment, Control of illumination, etc.)
  • Robot cleaner

Platforms Supported

Arduino Raspberry Pi BeagleBone Wio LinkIt ONE

Caution

The platforms mentioned above as supported is/are an indication of the module's hardware or theoritical compatibility. We only provide software library or code examples for Arduino platform in most cases. It is not possible to provide software library / demo code for all possible MCU platforms. Hence, users have to write their own software library.

Getting Started

Note

If this is the first time you work with Arduino, we strongly recommend you to see Getting Started with Arduino before the start.

Play With Arduino

Hardware

Materials required

Seeeduino V4.2 Base Shield Grove - Digital Distance Interrupter 0.5 to 5cm
enter image description here enter image description here enter image description here
Get One Now Get One Now Get One Now

Note

1 Please plug the USB cable gently, otherwise you may damage the port. Please use the USB cable with 4 wires inside, the 2 wires cable can't transfer data. If you are not sure about the wire you have, you can click here to buy

2 Each Grove module comes with a Grove cable when you buy. In case you lose the Grove cable, you can click here to buy.

  • Step 1. Plug Grove - Digital Distance Interrupter 0.5 to 5cm to port D2 of Grove-Base Shield.

  • Step 2. Plug Grove - Base Shield into Seeeduino.

  • Step 3. Connect Seeeduino to PC via a USB cable.

Note

If we don't have Grove Base Shield, We also can directly connect Grove-Mech keycap to Seeeduino as below.

Seeeduino Grove - Digital Distance Interrupter 0.5 to 5cm
5V Red
GND Black
Not Conencted White
D2 Yellow

Software

  • Step 1. Open the Arduino IDE and create a new file, then copy the following code into the new file.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 *  
 * Copyright (c) 2018 Seeed Technology Co., Ltd.
 * Website    : www.seeed.cc
 * Author     : downey
 * Create Time: May 2018
 * Change Log :
 *
 * The MIT License (MIT)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

#define SENSOR  2

void setup()
{
    Serial.begin(115200);
    pinMode(SENSOR,INPUT);
}


void loop()
{
    short val=0;
    val=digitalRead(SENSOR);
    Serial.print("val=");
    Serial.println((int)val);
    if(0==val)
    {
        Serial.println("Sensor is triggered!!");
    }
    delay(1000);
}
  • Step 2. Upload the demo. If you do not know how to upload the code, please check How to upload code.

  • Step 3. Open the Serial Monitor of Arduino IDE by click Tool-> Serial Monitor. Or tap the Ctrl+Shift+M key at the same time. Change the baud rate to 115200. if every thing goes well, you will get the output of this module.

The result should be something like that:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
val=1
val=1
val=1
val=1
val=1
val=1
val=0
Sensor is triggered!!
val=0
Sensor is triggered!!
val=0
Sensor is triggered!!
val=1
val=1
val=1
val=1

Normaly the output of this sensor is 1(High), when the object enters the measurement range of the sensor, it will be triggered and output a 0(LOW)

Resources

Tech Support

Please do not hesitate to contact techsupport@seeed.cc if you have any technical issue. Or submit the issue into our forum.