树莓派安装运行ADS1015库(python)

https://github.com/pimoroni/ads1015-python

安装Installing

 

Stable library from PyPi:使用此命令直接安装后只有python可以执行,python3无法执行,因为只在python2.x中安装了,跳过了python3.x,建议使用git安装方法。

sudo pip install ads1015

Latest/development library from GitHub:

git clone https://github.com/pimoroni/ads1015-python
cd ads1015-python
sudo ./install.sh

 示例程序在examples>read-all.py中

#!/usr/bin/env python
import time
from ads1015 import ADS1015

CHANNELS = ['in0/ref', 'in1/ref', 'in2/ref']

print("""read-all.py - read all three inputs of the ADC
Press Ctrl+C to exit!
""")

ads1015 = ADS1015()
ads1015.set_mode('single')
ads1015.set_programmable_gain(2.048)
ads1015.set_sample_rate(1600)

reference = ads1015.get_reference_voltage()

print("Reference voltage: {:6.3f}v \n".format(reference))

try:
    while True:
        for channel in CHANNELS:
            value = ads1015.get_compensated_voltage(channel=channel, reference_voltage=reference)
            print("{}: {:6.3f}v".format(channel, value))

        print("")
        time.sleep(0.5)

except KeyboardInterrupt:
    pass

 

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值