我正在尝试修改^{Temperature
值和Humidity
值相对应的数组。我希望进行此更改,以便可以在Python代码段中使用输出数组。也就是说,我希望使用输出数组值将数据上载到Xively
提要。在
我在找类似的东西。。。在
#!/usr/bin/env python
import time
import os
import eeml
# Xively variables specific to my account.
API_KEY = 'API Key Here'
FEED = 'FEED # Here'
API_URL = '/v2/feeds/{feednum}.xml' .format(feednum = FEED)
# Continuously read data from the DHT22 sensor and upload
# the results to the Xively feed.
while True:
# Read the data from the sensor.
sensorData = .... // Call on the main method within the DHT_Driver.c file
temp_C = sensorData[0]
humidity = sensorData[1]
if DEBUG:
print("sensorData:\t", sensorData)
print("\n")
if LOGGER:
# Initialize the users Xively account.
pac = eeml.Pachube(API_URL, API_KEY)
# Prepare the data to be uploaded to the Xively
# account.
# temp_C & humidity are extracted from their indices
# above.
pac.update([eeml.Data(0, temp_C, unit=eeml.Celsius())])
pac.update([eeml.Data(1, humidity, unit=eeml.%())])
# Upload the data to the Xively account.
pac.put()
# Wait 30 seconds to avoid flooding the Xively feed.
time.sleep(30)
我需要一些关于从传感器获取温度和湿度值的反馈。它必须利用C
,因为Python不够快,无法处理来自传感器的数据。理想情况下,我可以返回一个包含这两个值的数组,然后访问这些值:
另外,如果在这个Python片段中,我调用DHT_Driver.c文件中的main方法,这会受到Python解释器的限制(即基于c的程序运行时的性能是否与基于Python的程序类似)?在
我对Python非常陌生,而且我刚刚开始使用C语言,所以如果有任何建议和/或积极的批评,请随时加入进来。在
首先,您应该更新代码以使用Xively提供的official Python module。在
关于传感器驱动程序,我想看看AirPi。在
相关问题 更多 >
编程相关推荐