I2C对数电阻
项目描述
介绍
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 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | f0c713c310b0b7a0fe76cb6c7bb5a1befac2451bf4c264b3bcabbb75add4ce3a |
|
MD5 | 87893625075641c2cd1fe7e166516233 |
|
BLAKE2b-256 | a32b6065bebc0e2eb261a9c941d571c19e87d4e7ee764d7e935ba22e9b835613 |
关闭
adafruit_circuitpython_ds1841-1.0.18-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 837f6bd191e7ba38da7905907a7c4d3a358aa0ddbdaa53cf6640711425726704 |
|
MD5 | fad3b22b0ef9dc0ab0f50bcc58f56990 |
|
BLAKE2b-256 | 2f727118ce1fafc1e8a0ff5a048b5d74e6a5841126cc07f53e94bb24e34857f8 |