DHT22
センサー用に存在する定義済みコードの一部を変更しようとしています。値とセンサーが出力する値Adafruit's DHT_Driver
に対応する配列を返すように変更したいと思います。Python スニペットで出力配列を利用できるように、この変更を加えたいと思います。つまり、出力配列値を使用してデータをフィードにアップロードしたいと考えています。Temperature
Humidity
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 はセンサーからのデータを処理するのに十分な速度ではないため、利用する必要があります。理想的には、2 つの値を含む配列を返すだけで、次のように値にアクセスできます。
temp_C = sensorData[0]
humidity = sensorData[1]
また、この Python スニペット内で、DHT_Driver.c ファイル内のメイン メソッドを呼び出すとしたら、これは Python インタープリターによって制限されますか (つまり、C ベースのプログラムは Python ベースのプログラムと同様のパフォーマンスで実行されますか)?
私は Python に非常に不慣れで、C を始めたばかりなので、何か提案や肯定的な批判があれば、気軽に声をかけてください。