haas-python-zzio606 0.0.7
This is zzio606 driver for HaaS Python. HaaS Python is forked from micropython.
License: Apache License, Version 2.0


## HaaS Python介绍
HaaS Python是阿里云IoT团队最新研发的一套低代码编程框架，兼容MicroPython编程规范，依托HaaS平台软硬件积木提供AI、支付、蓝牙配网、云连接、UI等物联网场景常用的能力，从而解决了物联网应用开发难的问题。有了Python轻应用框架，物联网编程不再局限于专业软件开发人员，一般的技术员也可以快速实现复杂的物联网需求。
更多HaaS Python介绍和开发资料见[HaaS Python官网](https://haas.iot.aliyun.com/haasapi/index.html?spm=a2cpu.b16145223.0.0.595660b1dZDX71#/?from=corp),[创意案例](https://haas.iot.aliyun.com/solution?from=crop), [硬件积木](https://haas.iot.aliyun.com/solution/hardware?from=corp)

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](https://haas.iot.aliyun.com/haasapi/index.html?spm=a2cpu.b16145223.0.0.595660b1dZDX71#/?from=corp), [Creative Case](https://haas.iot.aliyun.com/solution?from=crop), [Hardware Building Blocks](https://haas.iot.aliyun.com/solution/hardware?from=corp)

## 安装方法
* 在[HaaS Python官网](https://haas.iot.aliyun.com/haasapi/index.html?spm=a2cpu.b50127119.0.0.4e1260b1ebMIf1#/)下载开发板对应的固件，并完成固件烧录

Download the firmware corresponding to the development board at [HaaS Python website](https://haas.iot.aliyun.com/haasapi/index.html?spm=a2cpu.b50127119.0.0.4e1260b1ebMIf1#/) and complete the firmware burning

* 在开发板上运行以下命令完成安装和使用,如果您在使用过程中遇到问题，欢迎在[github上向我们提交issue](https://github.com/alibaba/AliOS-Things/issues)，我们的工程师会及时解答

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](https://github.com/alibaba/AliOS-Things/issues), Our engineers will answer in time
```
import upip
upip.install("haas-python-zzio606")
import haas-python-zzio606
```
# 郎汉德6路继电器 - ZZIO606

## 一、产品简介

&emsp;&emsp;
郎汉德6路继电器支持Modbus-RTU协议，是工农业场景选用最多的传感器之一。详细参数如下：
<div align="center">
<img src=../../docs/images/485环境监测/zzio606.jpg width=50%/>
</div>
<br>

## 二、技术参数
<div align="center">
<img src=../../docs/images/485环境监测/ZZIO详细参数.jpg width=80%/>
</div>
<br>

## 三、软件接口

### ZZIO606(...) - 创建 ZZIO606 驱动对象
* 函数原型：
> zzioObj = ZZIO606(mbObj, mbAddr)

* 参数说明：

|参数|类型|必选参数？|说明|
|-----|----|:---:|----|
|mbObj|modbus|是|调用此函数前需确保 modbus 对象已初始化|
|mbAddr|int|是|默认值是1|

* 返回值：
成功返回ZZIO606对象，失败抛出 Exception

* 示例代码：

```python
import modbus as mb
import zzio606

mb.init('modbus_485_4800')
zzioObj = zzio606.ZZIO606(mb, 1)
```

### openChannel() - 关闭指定通道

* 函数原型：
> zzioObj.openChannel(channelID)

* 参数说明：

|参数|类型|必选参数？|说明|
|-----|----|:---:|----|
|channelID|int|是|通道id|


* 返回值：
打开指定通道，失败抛出异常，参考[modbus错误码表](https://haas.iot.aliyun.com/haasapi/index.html?spm=a2cpu.b16145223.0.0.595660b1KQYjx1#/Python/docs/zh-CN/haas_extended_api/modbus)


### closeChannel() - 关闭指定通道

* 函数原型：
> zzioObj.closeChannel(channelID)

* 参数说明：

|参数|类型|必选参数？|说明|
|-----|----|:---:|----|
|channelID|int|是|通道id|

* 返回值：
关闭指定通道，失败抛出异常，参考[modbus错误码表](https://haas.iot.aliyun.com/haasapi/index.html?spm=a2cpu.b16145223.0.0.595660b1KQYjx1#/Python/docs/zh-CN/haas_extended_api/modbus)


* 参考代码
```python
import modbus as mb
import zzio606

mb.init('modbus_485_4800')
zzioObj = zzio606.ZZIO606(mb, 1)

zzio606.openChannel(1)
zzio606.closeChannel(1)

```


## 四、接口案例
控制第一个通道开闭

* 代码：
```python
# 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 zzio606

mb.init('modbus_485_4800')
zzioObj = zzio606.ZZIO606(mb, 1)

zzio606.openChannel(1)
zzio606.closeChannel(1)

```

## 参考文献及购买链接
[1] [郎汉德官网](https://www.lonhand.com/index/io/22.html?hmsr=tb)

[3] [商品链接](https://item.taobao.com/item.htm?spm=a230r.1.14.12.68c03096UXtt9a&id=566347546505&ns=1&abbucket=18#detail)