This is htb485 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-htb485")
import haas-python-htb485
建大仁科光照温湿度变送器 - htb485
一、产品简介
建大仁科光照温湿度变送器支持Modbus-RTU协议,是工农业场景选用最多的传感器之一。详细参数如下:
接线方法
线色 | 说明 |
---|---|
棕色 | 电源正(10~30V DC) |
黑色 | 电源负 |
黄色 | 485-A |
蓝色 | 485-B |
二、技术参数
三、软件接口
HTB485(...) - 创建 htb485 驱动对象
- 函数原型:
htb485Obj = HTB485(mbObj, mbAddr)
- 参数说明:
参数 | 类型 | 必选参数? | 说明 |
---|---|---|---|
mbObj | modbus | 是 | 调用此函数前需确保 modbus 对象已初始化 |
mbAddr | int | 是 | 默认值 1 |
-
返回值: 成功返回HTB485对象,失败抛出 Exception
-
示例代码:
import modbus as mb
import yuanda_htb485
mb.init('modbus_485_4800')
htb485Obj = yuanda_htb485.HTB485(mb, 1)
getHumidity() - 获取湿度值
-
函数功能: 获取环境湿度(百分比)
-
返回值: 成功返回当前环境湿度值,抛出异常,参考modbus错误码表
getTemperature() - 获取温度值
-
函数功能: 获取环境温度(摄氏度)
-
返回值: 成功返回当前环境温度值,抛出异常,参考modbus错误码表
getBrightness() - 获取光照强度值
-
函数功能: 获取当前光照强度(流明)
-
返回值: 成功返回当前环境光照强度,抛出异常,参考modbus错误码表
getHTB() - 获取湿度,温度,光照强度
-
函数功能: 获取湿度,温度,光照强度
-
返回值: 成功返回当前环境湿度,温度,光照强度,抛出异常,参考modbus错误码表
-
参考代码
import modbus as mb
import yuanda_htb485
mb.init('modbus_485_4800')
htb485Obj = yuanda_htb485.HTB485(mb, 1)
htb = htb485Obj.getHTB()
print('Humidity:', htb[0])
print('Temperature:', htb[1])
print('Brightness:', htb[3])
* 输出
Humidity: 30.1
Temperature: 28
Brightness: 300
四、接口案例
采集当前环境的温度,湿度,光照强度
- 代码:
# board.json配置:
{
"name": "board-name",
"version": "1.0.0",
"io": {
"modbus_485_4800": {
"type": "MODBUS",
"mode": 0,
"port": 2,
"baudrate": 4800,
"priority": 0,
"timeout": 200
},
},
"debugLevel": "ERROR",
"repl": "disable"
}
# Python代码
import modbus as mb
import yuanda_htb485
mb.init('modbus_485_4800')
htb485Obj = yuanda_htb485.HTB485(mb, 1)
htb = htb485Obj.getHTB()
print('Humidity:', htb[0])
print('Temperature:', htb[1])
print('Brightness:', htb[3])
* 输出:
```python
...
Humidity: 100
Temperature: 28
Brightness: 300
...
参考文献及购买链接
[1] 光照温湿度变送器使用说明书
[2] 商品链接
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
File details
Details for the file haas-python-htb485-0.0.8.tar.gz
.
File metadata
- Download URL: haas-python-htb485-0.0.8.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9fa2aff0b9224ba3afd67e466518fa672a93997ba18abbfc5457cc6080a17c9 |
|
MD5 | ab4c93edc8aaa853a319e35467073895 |
|
BLAKE2b-256 | bdc1e89c3b673764e48341383cfb94b0dffbe3f71409627724224e66907b87e9 |