Arduino project notes | faucet based on PAJ7620U2 gesture sensor

1, Project background

In many large public places, the flow of people is large, and the sanitation of public facilities is generally poor; The traditional contact faucet has serious sanitary hidden dangers.

When washing dishes and hands in household kitchens, hands stained with oil stains or hand sanitizer are inconvenient to touch the faucet.
Bacteria and viruses are easy to breed in hospitals, and there are higher requirements for the cleaning of faucets.

Although infrared induction faucet can achieve non-contact effect, it is easy to be disturbed by other light or foreign matters, resulting in problems such as non-stop water flow or no water outlet.

2, Problem description

Advantages and disadvantages of infrared induction faucet( link)

  • 1. Power drive is required, so the internal power supply system shall be replaced regularly.

  • 2. We can't take care of both receiving water and washing hands. If we have to receive a basin of water to wash our face, it's impossible to keep our hands from sensing. In this regard, it's not suitable for home use at present. If there is improvement in the later stage, it can be considered.

  • 3. The cost is relatively high. At present, the price of induction faucets in the market needs to be between 400 yuan and 1000 yuan, and some are even more expensive.

  • 4. Due to the particularity of the induction faucet, its production cost is high, so the price of the induction faucet in the decoration material market is more expensive, generally between 400 yuan and 1000 yuan. Some induction faucets may be even more expensive because of other excellent performance.

  • 5. Because the induction faucet is driven by power supply, we should regularly repair and replace the internal power supply system components of the induction faucet during the use of the product. For more details, please check Baidu.

3, PAJ7620U2 module introduction

Gesture sensing is widely used in the field of electronic devices such as smart home, smart wearable devices and VR.

This scheme adopts the gesture recognition module of PAJ7620U2, which can directly recognize 9 basic gestures, supports I2C interface and is compatible with 3.3V/5V level.

Compared with APDS-9960 and other schemes, it has the advantages of faster recognition speed, higher accuracy, more recognizable gestures, and stronger anti-interference. It is suitable for low-power application scenarios such as smart home and robot interaction.

  • 1. Gesture sensor ¥ 79.00( link)
  • 2. Gesture sensor ¥ 48.00( link)

Its features include:

  • 1. Based on PAJ7620U2 sensor, it can directly recognize 9 basic gestures and support gesture interrupt output
  • 2. Built in infrared LED and optical lens, which can work in low light and dark environment
  • 3. It supports I2C interface communication and can be controlled by only two signal pins
  • 4. On board level conversion circuit, compatible with 3.3V/5V logic level

PAJ7620U2 sensor parameters:

  • Working voltage: 3.3V/5V
  • Communication interface: I2C
  • Identification distance: 5CM ~ 15CM
  • Gesture recognition: up, down, left, right, front, back, clockwise, counterclockwise, swing
  • Recognition speed: 240HZ
  • Identification angle: 60 ° (diagonal)
  • Ambient light immunity: < 100k Lux
  • Product size: 20mm × 20MM
  • Via diameter: 2.0MM

PAJ7620U2 sensor module description

Pin functiondescribe
VCCPositive power supply (3.3V/5V)
GNDPower ground
SDAI2C data line
SCLI2C clock line
INTExternal interrupt

4, Required devices

Hardware

  • UNO x1
  • IO sensor expansion board x1
  • PAJ7620U2 gesture recognition sensor x1( DFrobot technical documentation)
  • Digital relay module + 3V water pump
  • 3.7V lithium battery

Software

  • Arduino IDE

Leading knowledge

Digital relay module Using tutorials

  • Control signal: TTL level, high level on.
  • Contact mode: 1H,1Z
  • Rated load: 10A 250VAC/10A 24VDC
  • Maximum switching voltage: 250VAC/30VDC
  • Maximum switching power: 250VA/210W
  • Maximum switching current: 1H 15A/1Z 10A
  • Contact action time: less than 10ms
  • Contact status: always open when not energized

Meaning of terminal characters of relay module:

  • NC means normally closed;

  • NO means normally open;

  • N/A indicates empty foot;

  • COM represents the common end;

5, Circuit erection


6, Programming

Key code display:

#include <DFRobot_PAJ7620U2.h>

DFRobot_PAJ7620U2 paj;

#Define switch 3 / / relay switch

void setup()
{
  pinMode(Switch,OUTPUT);//Output mode
  digitalWrite(Switch,LOW);//Initialize to LOW
  
  Serial.begin(115200);
  delay(300);
  Serial.println("Gesture recognition system base on PAJ7620U2");
  while(paj.begin() != 0){
    Serial.println("initial PAJ7620U2 failure! Please check if all the connections are fine, or if the wire sequence is correct?");
    delay(500);
  }
  Serial.println("PAJ7620U2 init completed, start to test the gesture recognition function");
  
  /*Set fast detection mode 
   *If the parameter is set to false, the module enters slow detection mode, and it detects one gesture every 2s. We have integrated
   *some gestures inside the module to make it convenient for beginners.
   *The slow mode can recognize 9  basic gestures and 4 expanded gestures: move left, right, up, down, forward, backward, clockwise, 
   *counter-clockwise, wave, slowly move left and right, slowly move up and down, slowly move forward and backward, 
   *wave slowly and randomly.
   *
   *
   *
   *If the parameter is set to true, the module enters fast detection mode. 
   *The fast mode can recognize 9 gestures: move left, right, up, down, forward, backward, clockwise, counter-clockwise, wave
   *To detect the combination of these gestures, like wave left, right and left quickly, users needs to design their own algorithms logic.
   *Since users only use limited gestures in this mode, we are not going to integrate too much expanded gestures in the library. 
   *If necessary, you can complete the algorithm logic in the ino file by yourself.
   */
  paj.setGestureHighRate(true);

}

void loop()
{
  /* Read gesture number(return eGesture_t enumerated type)
   * eGestureNone  eGestureRight  eGestureLeft  eGestureUp  eGestureDown  eGestureForward
   * eGestureBackward  eGestureClockwise  eGestureAntiClockwise  eGestureWave  eGestureWaveSlowlyDisorder
   * eGestureWaveSlowlyLeftRight  eGestureWaveSlowlyUpDown  eGestureWaveSlowlyForwardBackward
   */
  DFRobot_PAJ7620U2::eGesture_t gesture = paj.getGesture();
  if(gesture != paj.eGestureNone ){
   /* Get the string descritpion corresponding to the gesture number.
    * The string description could be 
    *           1      2       4     8        16          32
    * "None","Right","Left", "Up", "Down", "Forward", "Backward", "Clockwise", "Anti-Clockwise", "Wave",
    * "WaveSlowlyDisorder", "WaveSlowlyLeftRight", "WaveSlowlyUpDown", "WaveSlowlyForwardBackward"
    */
    String description  = paj.gestureDescription(gesture);//Convert gesture number into string description
    //Serial.println();
    if(gesture == 4 || gesture == 8 )
    { 
      Serial.println("--------------Gesture Recognition System---------------------------");
      Serial.print("gesture code        = ");Serial.println(gesture);//gesture ID
      Serial.print("gesture description  = ");Serial.println(description);//describe
      switch(gesture)
      {
      //4-up  
      case 4:      {Serial.println("SWITCH STATE    = OPEN");digitalWrite(Switch,HIGH);} break;
      //8-down
      case 8:      {Serial.println("SWITCH STATE    = CLOSE");digitalWrite(Switch,LOW);} break;  
      default : break;
       }
    }
    //{digitalWrite(Switch,LOW);} / / close the water valve
  }
  delay(500);
}

7, Appearance design

8, Finished product display

  • Gag record

summary

Posted on Tue, 23 Nov 2021 20:15:52 -0500 by wittanthony