[text] thingspeak

Viewer

copydownloadembedprintName: thingspeak
  1. import thingspeak
  2. import Adafruit_DHT
  3. import time
  4. channel_id= 2537500
  5. write_key='EXCQNZTUKSVUHX0W'
  6. channel=thingspeak.Channel(id=channel_id,api_key=write_key)
  7. DHT_SENSOR=Adafruit_DHT.DHT11
  8. DHT_PIN=4
  9. while True:
  10.   humidity,temperature=Adafruit_DHT.read_retry(DHT_SENSOR,DHT_PIN)
  11.   if humidity is not None and temperature is not None:
  12.     print("Temperature={0:0.1f}*C Humidity={1:0.1f}%".format(tempetature,humidity))
  13.     #update the value in the thingspeak cloud
  14.     response=channel.update({'field1':temperature,'field2':humidity})
  15.   else:
  16.     print("Sensor failure.Check wiring.")

Editor

You can edit this paste and save as new:


File Description
  • thingspeak
  • Paste Code
  • 06 May-2024
  • 597 Bytes
You can Share it: