Electronics

Distance and Gesture ZX Sensor (Sparkfun)

AED 124.95

Low stock
1

Description

The SparkFun ZX Distance and Gesture Sensor SMD is a compact, non-contact sensor that can detect hand gestures and measure distances up to 20cm away. It uses infrared light to detect the position and movement of objects in front of it, and can differentiate between up to 8 different gestures. The sensor is designed to be mounted on a PCB and communicates with a microcontroller via I2C, making it easy to integrate into electronic projects. It also features adjustable sensitivity settings and a built-in ambient light sensor for improved accuracy in various lighting conditions.

Package Includes:

  • 1 xSparkFun ZX Distance and Gesture Sensor SMD

Features:

  • Non-contact distance sensing: The sensor can measure distances up to 20cm away without the need for physical contact.
  • Gesture recognition: The sensor can detect up to 8 different hand gestures, including swipes, taps, and waves.
  • Compact form factor: The sensor is designed to be mounted on a PCB and has a small footprint, making it easy to integrate into electronic projects.
  • Low power consumption: The sensor operates at a low voltage and has a low power consumption, making it suitable for battery-powered applications.
  • Adjustable sensitivity: The sensitivity of the sensor can be adjusted to optimize performance in different lighting conditions.
  • Ambient light sensor: The sensor includes a built-in ambient light sensor that adjusts the gain of the sensor to compensate for changes in ambient light levels.
  • I2C interface: The sensor communicates with a microcontroller via I2C, making it easy to integrate into electronic projects.
  • Open-source firmware: The firmware for the sensor is open-source and can be modified to suit specific application needs.
  • Applications: The sensor can be used in a variety of applications, including touch-free user interfaces, interactive installations, robotics, and more.

Description:

The SparkFun ZX Distance and Gesture Sensor SMD is a versatile sensor that allows users to detect hand gestures and measure distances up to 20cm away without the need for physical contact. This makes it particularly useful for applications where touch-free interaction is required, such as in public spaces or in medical settings where hygiene is crucial. The sensor works by emitting a beam of infrared light and then analyzing the reflected light to determine the position and movement of objects in front of it. It can detect up to 8 different hand gestures, including swipes, taps, and waves, and can differentiate between them with a high degree of accuracy. One of the key advantages of the SparkFun ZX Distance and Gesture Sensor SMD is its small form factor and low power consumption. It can be easily integrated into electronic projects and embedded systems, making it an ideal choice for developers and hobbyists who want to add gesture control or proximity-sensing capabilities to their designs. The sensor also features adjustable sensitivity settings, which can be adjusted to optimize performance in different lighting conditions. Additionally, it includes a built-in ambient light sensor, which further enhances its accuracy by automatically adjusting the sensor's gain to compensate for changes in ambient light levels.

Principle of Work:

The SparkFun ZX Distance and Gesture Sensor SMD use infrared light to detect hand gestures and measure distances up to 20cm away. The sensor emits a beam of infrared light and then analyzes the reflected light to determine the position and movement of objects in front of it. When an object, such as a hand, is placed in front of the sensor, the infrared light bounces off the object and returns to the sensor. The sensor then measures the time it takes for the light to return and calculates the distance between the sensor and the object. To detect hand gestures, the sensor uses a process called time-of-flight (TOF) measurement. By emitting a series of short pulses of infrared light and measuring the time it takes for the light to reflect back, the sensor can determine the position and movement of the hand. The sensor's firmware then analyzes the data to determine the type of gesture that was made. The sensor also includes an ambient light sensor, which detects changes in ambient light levels and adjusts the gain of the sensor to compensate. This helps to ensure accurate distance and gesture sensing in a variety of lighting conditions.

Pinout:

 

  • GRN: Not used. This pin is not connected to any components on the board.
  •  TXO: UART transmits out from the ZX Sensor. This pin is used for debugging purposes and is not needed for normal operation.
  •  RXI: UART receive. Not used at this time. This pin is not connected to any components on the board.
  •  VCC: 3.3 - 5 V power supply. This pin should be connected to a power supply that provides between 3.3V and 5V.
  •  GND: Connect to ground. This pin should be connected to a ground connection on the circuit board.
  •  BLK: Not used, but connected to GND. This pin is not connected to any components on the board but is internally connected to the ground.
  •  DR: Data Ready. This pin goes high when there is data to be read via I2C. This can be used to trigger an interrupt in a microcontroller or to indicate to the user that the sensor is ready for data retrieval.
  •  CL: I2C clock. This pin is used for clocking data in and out of the sensor via the I2C interface.
  •  DA: I2C data. This pin is used for transmitting and receiving data between the sensor and a microcontroller via the I2C interface.

Note that the GRN, TXO, RXI, and BLK pins are not used in normal operation and can be left unconnected. The DR pin can be used to improve the efficiency of the sensor by triggering data retrieval only when necessary. The CL and DA pins are used for communication with a microcontroller via the I2C interface. The VCC and GND pins are used for powering the sensor and should be connected to a stable power supply and a ground connection, respectively.

Applications: 

  • Gesture recognition systems: The sensor can detect a variety of hand gestures, including swipes, flicks, and taps, making it ideal for use in gesture-controlled devices such as smart home appliances, game consoles, and wearable devices.
  • Proximity sensing: The sensor can detect the presence of objects up to 20cm away, making it useful for proximity sensing applications such as automatic doors, robot navigation, and security systems.
  • Human-machine interfaces (HMIs): The sensor can be used to create touch-free interfaces for controlling machines and devices, improving accessibility for people with disabilities or limited mobility.
  • Interactive art installations: The sensor can be used to create interactive art installations that respond to the movement and presence of people, creating immersive and engaging experiences.
  • Robotics: The sensor can be used in robotics applications for obstacle avoidance, object detection, and human-robot interaction. 

Circuit:

  1. Connect the VCC pin on the ZX Sensor to the 5V pin on the Uno.
  2. Connect the GND pin on the ZX Sensor to the GND pin on the Uno.
  3. Connect the DR pin on the ZX Sensor to digital pin 2 on the Uno. This pin will be used to trigger an interrupt on the Arduino when the sensor has data available to read.
  4. Connect the CL pin on the ZX Sensor to analog pin A5 on the Uno. This pin is used for the I2C clock signal.
  5. Connect the DA pin on the ZX Sensor to analog pin A4 on the Uno. This pin is used for the I2C data signal.

Library:

To install the ZX_Sensor library on Arduino IDE, you can follow these steps:

  1. Download the library from the SparkFun GitHub repository at https://github.com/sparkfun/SparkFun_ZX_Distance_and_Gesture_Sensor_Arduino_Library
  2. Extract the downloaded library archive to a location of your choice on your computer.
  3. Open the Arduino IDE.
  4. From the menu, select Sketch -> Include Library -> Add .ZIP Library.
  5. Navigate to the location where you extracted the library archive and select the "SparkFun_ZX_Distance_and_Gesture_Sensor_Arduino_Library-master.zip" file.
  6. Click "Open" to install the library.

Code:  

This code is an Arduino sketch that demonstrates how to use the SparkFun ZX Distance and Gesture Sensor SMD to read position data over the I2C interface.

 #include "Wire.h"
 #include "ZX_Sensor.h"
 // Constants
 const int ZX_ADDR = 0x10; // ZX Sensor I2C address
 // Global Variables
 ZX_Sensor zx_sensor = ZX_Sensor(ZX_ADDR);
 uint8_t x_pos;
 uint8_t z_pos;
 void setup() {
 uint8_t ver;
 // Initialize Serial port
 Serial.begin(9600);
 Serial.println();
 Serial.println("-----------------------------------");
 Serial.println("SparkFun/GestureSense - I2C ZX Demo");
 Serial.println("-----------------------------------");
 // Initialize ZX Sensor (configure I2C and read model ID)
 if ( zx_sensor.init() ) {
 Serial.println("ZX Sensor initialization complete");
 } else {
 Serial.println("Something went wrong during ZX Sensor init!");
 }
 // Read the model version number and ensure the library will work
 ver = zx_sensor.getModelVersion();
 if ( ver == ZX_ERROR ) {
 Serial.println("Error reading model version number");
 } else {
 Serial.print("Model version: ");
 Serial.println(ver);
 }
 if ( ver != ZX_MODEL_VER ) {
 Serial.print("Model version needs to be ");
 Serial.print(ZX_MODEL_VER);
 Serial.print(" to work with this library. Stopping.");
 while(1);
 }
 // Read the register map version and ensure the library will work
 ver = zx_sensor.getRegMapVersion();
 if ( ver == ZX_ERROR ) {
 Serial.println("Error reading register map version number");
 } else {
 Serial.print("Register Map Version: ");
 Serial.println(ver);
 }
 if ( ver != ZX_REG_MAP_VER ) {
 Serial.print("Register map version needs to be ");
 Serial.print(ZX_REG_MAP_VER);
 Serial.print(" to work with this library. Stopping.");
 while(1);
 }
 }
 void loop() {
 // If there is position data available, read and print it
 if ( zx_sensor.positionAvailable() ) {
 x_pos = zx_sensor.readX();
 if ( x_pos != ZX_ERROR ) {
 Serial.print("X: ");
 Serial.print(x_pos);
 }
 z_pos = zx_sensor.readZ();
 if ( z_pos != ZX_ERROR ) {
 Serial.print(" Z: ");
 Serial.println(z_pos);
 }
 }
 }

The first part of the code includes the necessary libraries for communicating over I2C and working with the ZX Sensor. It also defines the I2C address of the sensor and two global variables to hold the X and Z position data.

In the setup() function, the code initializes the serial port and prints a message to the serial monitor to indicate that the program has started. It then initializes the ZX Sensor by calling the init() function on the zx_sensor object. If the initialization is successful, it prints a message to the serial monitor. It also reads the model version and registers map version numbers from the sensor and checks that they match the expected values for the library. If they do not match, the program stops with an error message. In the loop() function, the code checks if there is position data available by calling the positionAvailable() function on the zx_sensor object. If there is, it reads the X and Z position data from the sensor by calling the readX() and readZ() functions, respectively. If the data is valid (not equal to the ZX_ERROR constant), it prints the position data to the serial monitor.

Technical Details:

  • Operating Voltage: 3.3 - 5V DC
  • Detection Range: 4 - 8 inches (10 - 20 cm)
  • Gesture Recognition: 9 different gestures
  • Gesture Detection Rate: up to 200 Hz
  • I2C Address: 0x10
  • Communication: I2C and UART
  • UART Baud Rate: 9600 bps
  • Dimensions: 1.2 x 0.6 x 0.4 inches (30.5 x 15.2 x 10.2 mm)
  • Weight: 0.03 oz (0.9 g)

Resources:

Comparisons:

Comparison between the SparkFun ZX Distance and Gesture Sensor SMD, the APDS-9960, and the CJMCU-7620:

SparkFun ZX Distance and Gesture Sensor SMD:

  • Detection Range: 4-8 inches (10-20 cm)
  • Gesture Recognition: 9 different gestures
  • Communication: I2C and UART
  • Operating Voltage: 3.3-5V DC
  • Detection Rate: up to 200 Hz
  • Dimensions: 1.2 x 0.6 x 0.4 inches (30.5 x 15.2 x 10.2 mm)

APDS-9960:

  • Detection Range: 4-8 inches (10-20 cm)
  • Gesture Recognition: 6 different gestures
  • Communication: I2C
  • Operating Voltage: 3.3-5V DC
  • Detection Rate: up to 120 Hz
  • Dimensions: 0.6 x 0.6 inches (15 x 15 mm)

CJMCU-7620:

  • Detection Range: 5-10 cm
  • Gesture Recognition: 9 different gestures
  • Communication: I2C
  • Operating Voltage: 3.3-5V DC
  • Detection Rate: up to 240 Hz
  • Dimensions: 0.8 x 0.7 inches (20.3 x 18 mm)

All three sensors are capable of detecting hand gestures, but they differ in terms of their range, communication protocols, detection rate, and dimensions. The SparkFun ZX and the APDS-9960 have a similar detection range of 4-8 inches, while the CJMCU-7620 has a shorter detection range of 5-10 cm. The SparkFun ZX and the CJMCU-7620 are capable of detecting 9 different gestures, while the APDS-9960 can detect 6. The SparkFun ZX and the CJMCU-7620 support both I2C and UART communication, while the APDS-9960 only supports I2C. The CJMCU-7620 has the highest detection rate of up to 240 Hz, followed by the SparkFun ZX at 200 Hz and the APDS-9960 at 120 Hz. Finally, the sensors differ in size, with the SparkFun ZX being the largest at 1.2 x 0.6 x 0.4 inches, followed by the CJMCU-7620 at 0.8 x 0.7 inches, and the APDS-9960 being the smallest at 0.6 x 0.6 inches.