Skip to main content

This is waterlevel 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

安装方法

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-waterlevel")
import haas-python-waterlevel

水位监测传感器

一、产品简介

   水位监测传感器主要用于测量水位深度的传感器,该传感器测量范围在0cm-4cm,通过使用一系列五个连接到系统接地的裸露走线来工作。在每两个接地迹线之间交错插入一个感测迹线,五个接地迹线和总共五个感测迹线。

引脚定义

  • GND:地
  • VCC:5V
  • NC:不接
  • AO:模拟输出

二、技术参数

工作电压:DC5V
工作电流:小于35mA
数据类型:模拟信号
检测面积:40mm x 18mm最深只能测4cm
制作工艺:FR4双面喷锡
工作温度:10°C-30°C
工作湿度:10%-90%无凝结
模块重量:3.5g
板子尺寸:60mm x 22mm

三、软件接口

水位监测传感器HaaS Python驱动:下载地址

WATER4LEVEL(adcObj) - 创建水位监测传感器驱动对象


  • 函数原型

waterlevelObj = WATER4LEVEL(adcObj)

  • 参数说明
参数 类型 必选参数? 说明
adcObj ADC 调用此函数前需确保adcObj对象已经处于open状态
  • 返回值

WATER4LEVEL对象成功,返回WATER4LEVEL对象;WATER4LEVEL对象创建失败,抛出Exception

  • 示例代码
import water4level
from driver import ADC

print("Testing water level ...")
adcObj = ADC()
adcObj.open("waterlevel")
print("waterlevel inited!")
waterlevelObj = water4level.WATER4LEVEL(adcObj)
  • 输出
Testing water level ...
waterlevel inited!

measureLevel() - 测量水位值,单位cm


  • 函数功能:

测量水位值,单位cm

  • 函数原型:

WATER4LEVEL.measureLevel()

  • 参数说明:

  • 返回值:

返回测到的水位值(数据类型:整型;单位:cm)

  • 示例:
import water4level
from driver import ADC
import utime

print("Testing water level ...")
adcObj = ADC()
adcObj.open("waterlevel")
print("waterlevel inited!")
waterlevelObj = water4level.WATER4LEVEL(adcObj)
while True:             # 无限循环
    level = waterlevelObj.measureLevel()
    print("%d"%level+" cm")
    utime.sleep(1)
  • 输出
Testing water level ...
waterlevel inited!
0 cm
1 cm
1 cm
1 cm
2 cm
2 cm
3 cm
3 cm
3 cm
3 cm
4 cm
4 cm
4 cm
4 cm

四、接口案例

此使用实例在board.json中定义了名为WATER4LEVEL的ADC类型的对象。在Python脚本中获取测量到的水位值并打印在日志中。

  • 案例代码
{
    "name": "board-name",
    "version": "1.0.0",
    "io": {
       "waterlevel": {
        "type": "ADC",
        "port": 0,
        "atten": 2,
        "width": 3,
        "sampling": 12000000
      },
    }
}
import water4level
from driver import ADC
import utime

print("Testing water level ...")
adcObj = ADC()
adcObj.open("waterlevel")
print("waterlevel inited!")
waterlevelObj = water4level.WATER4LEVEL(adcObj)
while True:             # 无限循环
    level = waterlevelObj.measureLevel()
    print("%d"%level+" cm")
    utime.sleep(1)
  • 输出
Testing water level ...
waterlevel inited!
0 cm
1 cm
1 cm
1 cm
2 cm
2 cm
3 cm
3 cm
3 cm
3 cm
4 cm
4 cm
4 cm
4 cm

五、工作原理

   Water Sensor液位(水位)传感器是一款简单易用、小巧轻便、性价比较高的水位/水滴识别检测传感器,其是通过具有一系列的暴露的平行导线线迹测量其水滴/水量大小从而判断水位。轻松完成水量到模拟信号的转换,输出的模拟值可以直接被程序中函数所应用,达到水位报警的功效,低功耗,灵敏度是其又一大特点。


参考文献及购买链接

[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

haas-python-waterlevel-0.0.7.tar.gz (7.9 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page