一、项目背景
在许多大型公共场所,人员流动量大,公共设施的卫生情况普遍恶劣;传统的接触式水龙头存在着严重的卫生隐患。
家用厨房 洗碗、洗手时沾着油渍或洗手液洗手的手不方便触及水龙头。
医院里 容易滋生细菌、病毒,对水龙头的清洁要求更高。
红外感应水龙头虽然能够达到非接触的效果,但是其很容易被其他光线或异物干扰,导致水流不停或不出水等问题。
二、问题描述
红外感应水龙头的优缺点(链接)
-
1、需要电源驱动,因此要做到定期更换内部供电系统。
-
2、不能兼顾接水和洗手,如洗脸要接一盆水,不可能手一直防着感应,就这一点来说,目前并不适合家居使用,如果后期有改善,是可以考虑的。
-
3、造价比较高,目前市场上的感应水龙头价格需在400元至1000元之间,有的甚至更贵。
-
4、由于感应水龙头的特殊性,它的生产成本较高,所以现在装修材料市场上的感应水龙头价格较贵,一般在400元至1000元之间,有的感应水龙头可能还会因为其他的优异的性能价格甚至更贵。
-
5、感应水龙头由于是采用需要电源驱动的,所以我们在品是的使用过程中要,定期进行感应水龙头的内部的供电系统元件的检修以及更换。更多详细内容可以百度查查吧。
三、PAJ7620U2 模块介绍
手势感应普遍应用于智能家居、智能可穿戴设备和VR等电子设备领域。
本方案采用的是 PAJ7620U2 的手势识别模块,可直接识别9种基本手势,支持I2C接口,兼容3.3V/5V电平。
相比 APDS-9960 等方案,具有识别速度更快,准确度更高,可识别手势更多等优点,且抗干扰性更强,适用于智能家居、机器人交互等低功耗应用场景。
其特点有:
- 1、基于PAJ7620U2传感器,可直接识别9种基本手势,支持手势中断输出
- 2、内置红外LED和光学镜头,能在低光和黑暗环境下工作
- 3、支持I2C接口通信,仅需两根信号脚即可控制
- 4、板载电平转换电路,可兼容3.3V/5V的逻辑电平
PAJ7620U2 传感器参数:
- 工作电压:3.3V/5V
- 通信接口:I2C
- 识别距离:5CM ~ 15CM
- 识别手势:上、下、左、右、前、后、顺时针、逆时针、摇摆
- 识别速度:240HZ
- 识别视角:60° (对角线)
- 环境光免疫力:<100K LUX
- 产品尺寸:20MM × 20MM
- 过孔直径:2.0MM
PAJ7620U2 传感器模块说明
引脚功能 | 描述 |
---|---|
VCC | 电源正(3.3V/5V) |
GND | 电源地 |
SDA | I2C数据线 |
SCL | I2C时钟线 |
INT | 外部中断 |
四、所需器件
硬 件
- UNO x1
- IO 传感器拓展板 x1
- PAJ7620U2手势识别传感器x1 (DFrobot 技术文档)
- 数字继电器模块 + 3V 水泵
- 3.7V 锂电池
软 件
- Arduino IDE
前导知识
数字继电器模块使用教程
- 控制信号:TTL电平,高电平通。
- 触点方式:1H,1Z
- 额定负载:10A 250VAC/10A 24VDC
- 最大开关电压:250VAC/30VDC
- 最大开关功率:250VA/210W
- 最大切换电流:1H 15A/1Z 10A
- 触点动作时间:10ms以下
- 触点状态:未通电时常开
继电器模块接线端字符含义:
-
NC表示常闭;
-
NO表示常开;
-
N/A表示空脚;
-
COM表示公共端;
五、电路搭设
六、程序编写
关键代码展示 :
#include <DFRobot_PAJ7620U2.h>
DFRobot_PAJ7620U2 paj;
#define Switch 3 //继电器开关
void setup()
{
pinMode(Switch,OUTPUT);//输出模式
digitalWrite(Switch,LOW);//初始化为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);//描述
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);}//关闭水阀
}
delay(500);
}
七、外观设计
八、成品展示
- 花絮记录