Ich bin interessierter Laie, bisher hat Google gute Dienste geleistet. Jetzt brauche ich aber Hilfe von Profis
Das Projekt:
Raspberry Pi Zero WH
CO2 mit MH-Z19b (https://tutorials-raspberrypi.de/raspbe ... -tutorial/)
Luftdruck/Temperatur mit DHT22, die Daten sollen mittels Thingspeak geloggt/angezeigt werden (https://tutorials-raspberrypi.de/raspbe ... auswerten/)
Zum testen habe ich zwei Skripte:
Code: Alles auswählen
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import Adafruit_DHT
humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.AM2302, 17)
print("%.2f °C %.2f %%" % (temperature, humidity))
16.20 °C 62.60 %
Code: Alles auswählen
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import mh_z19
print(mh_z19.read())
{'co2': 575}
So weit, so gut!
Also Thingspeak-Account eingerichtet und die Anleitung (aus dem Link oben) befolgt. Das Skript habe ich (mit meinen ergoogelten Py-Skills ) um die CO2-Werte ergänzt:
Code: Alles auswählen
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import thingspeak
import time
import Adafruit_DHT
import mh_z19
channel_id = xxxx # PUT CHANNEL ID HERE
write_key = 'xxx' # PUT YOUR WRITE KEY HERE
read_key = 'xxx' # PUT YOUR READ KEY HERE
pin = 17
sensor = Adafruit_DHT.AM2302
def measure(channel):
try:
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
co2 = mh_z19.read()
# write
response = channel.update({'field1': temperature, 'field2': humidity, 'field3': co2})
except:
print("connection failed")
if __name__ == "__main__":
channel = thingspeak.Channel(id=channel_id, write_key=write_key, api_key=read_key)
while True:
measure(channel)
# free account has an api limit of 15sec
time.sleep(15)
Feld 3 für CO2 bleibt aber leer. Jetzt ist die Frage: warum! Und wo habe ich was falsch gemacht?
Danke im Voraus, ich freu mich auf Hilfe!