loading
3Comments

Tell us about yourself!

Complete Your Profile
  • Build Your First IOT with a Raspberry Pi, DHT11 sensor, and Thingspeak.

    Here's the fixed python below. The downloadable python seems to have some serious copy-paste issues. :(I also cleaned away the photo sensor bits as I don't have it, but you can use the original downloaded version. My script uses GPIO4, but you can change that easily. Also change the thinkspeak channel key.Thanks for the original poster a great project.---- code below ----"""My First Internet of ThingsTemperature/Humidity Light monitor using Raspberry Pi, DHT11 Data is displayed at thingspeak.com2015/06/15SolderingSunday.comBased on project by Mahesh Venkitachalam at electronut.in"""# Import all the libraries we need to runimport sysimport osfrom time import sleepimport Adafruit_DHTimport urllib2# Setup the pin we connect toDHTpin = 4#Setup our API and delay...see more »Here's the fixed python below. The downloadable python seems to have some serious copy-paste issues. :(I also cleaned away the photo sensor bits as I don't have it, but you can use the original downloaded version. My script uses GPIO4, but you can change that easily. Also change the thinkspeak channel key.Thanks for the original poster a great project.---- code below ----"""My First Internet of ThingsTemperature/Humidity Light monitor using Raspberry Pi, DHT11 Data is displayed at thingspeak.com2015/06/15SolderingSunday.comBased on project by Mahesh Venkitachalam at electronut.in"""# Import all the libraries we need to runimport sysimport osfrom time import sleepimport Adafruit_DHTimport urllib2# Setup the pin we connect toDHTpin = 4#Setup our API and delaymyAPI = "insert_here_your_thingspeak_channel_key"myDelay = 15 #how many seconds between posting datadef getSensorData(): RHW, TW = Adafruit_DHT.read_retry(Adafruit_DHT.DHT11, DHTpin) #Convert from Celius to Farenheit TWF = 9/5*TW+32 # return dict return (str(RHW), str(TW),str(TWF))# main() functiondef main(): print 'starting...' baseURL = 'https://api.thingspeak.com/update?api_key=%s' % myAPI print baseURL while True: try: RHW, TW, TWF = getSensorData() f = urllib2.urlopen(baseURL + "&field1=%s&field2=%s&field3=%s" % (TW, TWF, RHW)) print f.read() print "tempC " + TW + ", tempF " + TWF+ ", humidity " + RHW f.close() sleep(int(myDelay)) except: print 'exiting.' break# call mainif __name__ == "__main__": main()

    Check my post way up for the python fix

    Check my post up there

    View Instructable »
  • jussipla followed Raspberry Pi channel 6 months ago