跳转到主要内容

I2C对数电阻

项目描述

介绍

Documentation Status Discord Build Status Code Style: Black

CircuitPython库,用于Maxim DS1841 I2C对数电阻

依赖项

此驱动程序依赖于

请确保所有依赖项都在CircuitPython文件系统中可用。这可以通过下载Adafruit库和驱动程序包轻松实现。

从PyPI安装

在支持GNU/Linux的系统(如Raspberry Pi)上,您可以从PyPI本地安装驱动程序。为当前用户安装

pip3 install adafruit-circuitpython-ds1841

为系统范围内安装(在某些情况下可能需要这样做)

sudo pip3 install adafruit-circuitpython-ds1841

在当前项目的虚拟环境中安装

mkdir project-name && cd project-name
python3 -m venv .venv
source .venv/bin/activate
pip3 install adafruit-circuitpython-ds1841

用法示例

from time import sleep
import board
import busio
import adafruit_ds1841
from analogio import AnalogIn

####### NOTE ################
# this example will not work with Blinka/rasberry Pi due to the lack of analog pins.
# Blinka and Raspberry Pi users should run the "ds1841_blinka_simpletest.py" example

# WIRING:
# 1 Wire connecting  VCC to RH to make a voltage divider using the
#   internal resistor between RH and RW
# 2 Wire connecting RW to A0

i2c = busio.I2C(board.SCL, board.SDA)
ds1841 = adafruit_ds1841.DS1841(i2c)
wiper_output = AnalogIn(board.A0)

while True:

    ds1841.wiper = 127
    print("Wiper set to %d"%ds1841.wiper)
    voltage = wiper_output.value
    voltage *= 3.3
    voltage /= 65535
    print("Wiper voltage: %.2f"%voltage)
    print("")
    sleep(1.0)

    ds1841.wiper = 0
    print("Wiper set to %d"%ds1841.wiper)
    voltage = wiper_output.value
    voltage *= 3.3
    voltage /= 65535
    print("Wiper voltage: %.2f"%voltage)
    print("")
    sleep(1.0)

    ds1841.wiper = 63
    print("Wiper set to %d"%ds1841.wiper)
    voltage = wiper_output.value
    voltage *= 3.3
    voltage /= 65535
    print("Wiper voltage: %.2f"%voltage)
    print("")
    sleep(1.0)

文档

此库的API文档可在Read the Docs上找到。

有关构建库文档的信息,请参阅此指南

贡献

欢迎贡献!在贡献之前,请阅读我们的行为准则,以帮助本项目保持欢迎。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源代码分发

adafruit-circuitpython-ds1841-1.0.18.tar.gz (27.8 kB 查看哈希值)

上传时间 源代码

构建分发

adafruit_circuitpython_ds1841-1.0.18-py3-none-any.whl (5.9 kB 查看哈希值)

上传时间 Python 3

支持