学物联网,来万物简单IoT物联网!!
一、产品简介
红外避障传感器具有一对红外线发射与接收管,发射管发射出一定频率的红外线,当检测方向遇到障碍物(反射面)时,红外线反射回来被接收管接收。它常用于安装在小车上,判断前方是否有障碍物。可通过电位器设置阀值。正前方有障碍时绿灯亮起,OUT引脚为低电平,反之为高电平。红外避障传感器可以广泛应用于机器人避障、避障小车、流水线计数及黑白线循迹等众多场合。
引脚定义
- VCC:3.3V
- GND:地
- OUT:输出信号
二、技术参数
- 工作电压:3.3V-5V
- 有效检测距离:2cm-30cm
- 工作电流:10mA
- 输出电平:TTL
- 检测角度:35°
- 工作温度:-20°C~85°C
- 检测距离:可调节电位器
- 电路板尺寸:3.2cm*1.4cm
三、软件接口
IRDISTANCE(gpioObj) - 创建红外避障传感器对象
- 函数原型
irObj = IRDISTANCE(gpioObj)
- 参数说明
参数 | 类型 | 必选参数? | 说明 |
---|---|---|---|
gpioObj | GPIO | 是 | GPIO输入,传入GPIO对象 |
- 返回值
IRDISTANCE对象成功,返回IRDISTANCE对象;IRDISTANCE对象创建失败,抛出Exception
- 示例代码
from machine import Pin
import irdistance
gpioObj = Pin(2, Pin.IN, Pin.PULL_UP)
irDev = irdistance.IRDISTANCE(gpioObj)
print("Testing IR detector ...")
- 输出
Testing IR detector ...
objectDetection() - 检查红外避障传感器的状态
- 函数功能:
检查红外避障传感器的状态
- 函数原型:
IRDISTANCE.objectDetection()
- 参数说明:
无
- 返回值:
成功返回IRDISTANCE热体红外状态,0 - 有障碍物 1 - 无障碍物;失败抛出Exception
- 示例:
from machine import Pin
import irdistance
import utime
gpioObj = Pin(2, Pin.IN, Pin.PULL_UP)
irDev = irdistance.IRDISTANCE(gpioObj)
print("Testing IR detector ...")
while True: # 无限循环
status = irDev.objectDetection()
if status == 0:
print("object detected")
elif status == 1:
print('no object detected')
utime.sleep(1) # 打印完之后休眠1秒
- 输出
Testing IR detector ...
object detected
object detected
object detected
no object detected
no object detected
no object detected
object detected
object detected
no object detected
四、接口案例
- 案例代码
from machine import Pin
import irdistance
import utime
gpioObj = Pin(2, Pin.IN, Pin.PULL_UP)
irDev = irdistance.IRDISTANCE(gpioObj)
print("Testing IR detector ...")
while True: # 无限循环
status = irDev.objectDetection()
if status == 0:
print("object detected")
elif status == 1:
print('no object detected')
utime.sleep(1) # 打印完之后休眠1秒
- 输出
Testing IR detector ...
object detected
object detected
object detected
no object detected
no object detected
no object detected
object detected
object detected
no object detected
五、工作原理
原理介绍
红外线接收管是将红外线光信号变成电信号的半导体器件,它的核心部件是一个特殊材料的PN结,和普通二极管相比,在结构上采取了大的改变,红外线接收管为了更多更大面积的接受入射光线,PN结面积尽量做的比较大,电极面积尽量减小,而且PN结的结深很浅,一般小于1微米。红外线接收二极管是在反向电压作用之下工作的。没有光照时,反向电流很小(一般小于0.1微安),称为暗电流。当有红外线光照时,携带能量的红外线光子进入PN结后,把能量传给共价键上的束缚电子,使部分电子挣脱共价键,从而产生电子—空穴对(简称:光生载流子)。它们在反向电压作用下参加漂移运动,使反向电流明显变大,光的强度越大,反向电流也越大。这种特性称为“光电导”。红外线接收二极管在一般照度的光线照射下,所产生的电流叫光电流。如果在外电路上接上负载,负载上就获得了电信号,而且这个电信号随着光的变化而相应变化。
参考文献及购买链接
[1] 购买链接