This is vibration_sensor driver for HaaS Python. HaaS Python is forked from micropython.
Project description
HaaS Python介绍
HaaS Python是阿里云IoT团队最新研发的一套低代码编程框架,兼容MicroPython编程规范,依托HaaS平台软硬件积木提供AI、支付、蓝牙配网、云连接、UI等物联网场景常用的能力,从而解决了物联网应用开发难的问题。有了Python轻应用框架,物联网编程不再局限于专业软件开发人员,一般的技术员也可以快速实现复杂的物联网需求。 更多HaaS Python介绍和开发资料见HaaS Python官网,创意案例, 硬件积木
HaaS Python is a set of low-code programming frameworks newly developed by Alibaba Cloud IoT team. It is compatible with MicroPython programming specifications. It relies on the hardware and software building blocks of the HaaS platform to provide capabilities commonly used in IoT scenarios such as AI, payment, Bluetooth network configuration, cloud connection, and UI. Solve the difficult problem of IoT application development. With the Python light application framework, IoT programming is no longer limited to professional software developers, and general technicians can quickly implement complex IoT requirements. For more HaaS Python introduction and development materials, see HaaS Python official website, Creative Case, Hardware Building Blocks
安装方法
- 在HaaS Python官网下载开发板对应的固件,并完成固件烧录
Download the firmware corresponding to the development board at HaaS Python website and complete the firmware burning
- 在开发板上运行以下命令完成安装和使用,如果您在使用过程中遇到问题,欢迎在github上向我们提交issue,我们的工程师会及时解答
Run the following commands on the development board to complete the installation and use. If you encounter problems during use, please submit an issue to us on github, Our engineers will answer in time
import upip
upip.install("haas-python-vibration_sensor")
import haas-python-vibration_sensor
VibrationSensor 震动传感器模块
一、产品简介
震动传感器用于各种震动触发作用,如防盗报警,智能小车,地震报警等。
引脚定义
- VCC:电源正 3.3V~5V
- GND:电源地
- DO:数字信号输出
- AO:不使用
二、技术参数
- SW-18010P震动传感器
- 比较器输出,信号干净,波形好,驱动能力强,超过15mA
- 工作电压3.3V-5V
- 输出形式:数字开关量输出(0和1)
- 设有固定螺栓孔,方便安装
- 小板PCB尺寸:5.3cmx1.4cm
- 使用宽电压LM393比较器
三、软件接口
震动传感器HaaS Python驱动:下载地址
VibrationSensor - 创建震动传感器对象
- 函数原型
sensorObj = VibrationSensor(gpioObj)
- 参数说明
该方法初始化一个 VibrationSensor 对象,用于震动传感器数据读取。
参数 | 类型 | 必选参数? | 说明 |
---|---|---|---|
gpioObj | GPIO | 是 | DO引脚的GPIO对象。调用此函数前需确保对象已被open |
- 返回值
若VibrationSensor对象创建成功,返回VibrationSensor对象;否则抛出Exception
- 示例代码
from VibrationSensor import VibrationSensor
from driver import GPIO
doPin = GPIO()
doPin.open("VibrationSensor")
sensor = VibrationSensor(doPin)
isVibrating() - 获取震动传感器状态
- 函数功能:
获取震动传感器状态
- 函数原型:
VibrationSensor.isVibrating()
- 参数说明:
无
- 返回值:
若传感器震动,返回1;否则返回0。
- 示例代码
from VibrationSensor import VibrationSensor
from driver import GPIO
doPin = GPIO()
doPin.open("VibrationSensor")
sensor = VibrationSensor(doPin)
print(sensor.isVibrating())
四、接口案例
board.json配置
{
"name": "board-name",
"version": "1.0.0",
"io": {
"VibrationSensor": {
"type": "GPIO",
"port": 28,
"dir": "input",
},
}
}
Python代码
from VibrationSensor import VibrationSensor
from driver import GPIO
doPin = GPIO()
doPin.open("VibrationSensor")
sensor = VibrationSensor(doPin)
while True:
utime.sleep(1)
print(sensor.isVibrating())
参考文献及购买链接
[1] 购买链接
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for haas-python-vibration_sensor-0.0.7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 897ffe9e270338f8307a185497dfe63f83ef6881ca9e41c17306bd87bb901200 |
|
MD5 | 14cb7e8485eff046948eb062d710599c |
|
BLAKE2b-256 | 5f8f487858a7314ad8ef566c8f017909929806fea8814e715919241dbd8c4436 |