我使用TSL235R(https://www.sparkfun.com/products/9768)和Beaglebone Black(BBB)。不幸的是,我找不到一个教程如何使用BBB和python传感器,并编写了我自己的脚本,但要么接线不正确,要么脚本有错误-当我改变光强度时,输出数据不会改变。我需要得到每秒的辐照度值(平均值为100)。这是我的剧本:
import Adafruit_BBIO.GPIO as GPIO
import time
GPIO.setup("P8_11", GPIO.IN)
# area of TSL235R in cm2
area = 0.0092
while True:
for n in 100:
f = []
start = time.time()
for i in range(100):
GPIO.input("P8_11")
duration = time.time() - start
frequency = 100 / duration
irradiance = frequency / area
f.append(irradiance)
avg = sum(f)/len(f)
print " irradiance is {}".format(avg)
time.sleep(1)
接线:
^{pr2}$如有任何意见和建议,我们将不胜感激!在
你好像根本没有测量频率
也许你是想做点什么(未经测试):
^{pr2}$注意:BBB可能太慢,无法测量设备输出的更高频率,因此您可能会在某些光照水平下得到错误的读数。它是否适合您的应用将取决于输入读取的速度以及到达传感器的最大光照强度。你可以考虑减少进入传感器的总光线(比如说通过针孔)使其回到可用范围。在
编辑
另外,您是否将1-GND和2-VDD引脚连接到BBB上的接地和正极,或者它们也使用GPIO线路?在
编辑2
下面是一个测量多个脉冲以提高精度的例子
相关问题 更多 >
编程相关推荐