loading
2Comments

Tell us about yourself!

Complete Your Profile
  • JeremyB86 followed dmainmon6 days ago
      • ESP8266 Soil Moisture Sensor With Arduino IDE
      • Using a 5 Volt Mechanical Relay
      • Arduino Pulse Sensor Cardio Graph
  • Raspberry Pi: Launch Python script on startup

    Hi Scott, many thanks for writing this tutorial on a foundation topic. I combined the skills learnt here with this Instructable "Build Your First IOT with a Raspberry Pi, DHT11 sensor, and Thingspeak These two instructables make a perfect pair! Shown is the image is the breadboarded project, with the thingspeak.com web page open displaying the data from the sensors on the breadboard. I used your tutorial to run at boot up the python script created in the "Build Your First IOT with a Raspberry Pi, DHT11 sensor, and Thingspeak" instructable.

    View Instructable »
  • JeremyB86 followed SolderingSunday3 weeks ago
      • Build Your First IOT with a Raspberry Pi, DHT11 sensor, and Thingspeak.
      • EZ LED Glasses
      • Circuit Stickers Holiday Centerpiece
  • Build Your First IOT with a Raspberry Pi, DHT11 sensor, and Thingspeak.

    Here is how to get the project to work:Step 1Replace my write API key Y5HGYOS51NFJ2I5O with your write api key in 3 lines (85,161 and 217).Step 2Save the file using the name dht11_thingspeak.py Iin the /home/pi folderStep 3You run the python script by entering this command in the command prompt. Replace YOURWRITEAPIKEY in the command with your write API key:sudo python dht11_thingspeak.py YOURWRITEAPIKEY Here is the corrected python code:#My First Internet of Things#Temperature/Humidity Light monitor using Raspberry Pi, DHT11, and photosensor #Data is displayed at thingspeak.com#2015/06/15#SolderingSunday.com#Based on project by Mahesh Venkitachalam at electronut.in# Import all the libraries we need to runimport sysimport RPi.GPIO as GPIOimport osfrom time import sleepimport Adafru...see more »Here is how to get the project to work:Step 1Replace my write API key Y5HGYOS51NFJ2I5O with your write api key in 3 lines (85,161 and 217).Step 2Save the file using the name dht11_thingspeak.py Iin the /home/pi folderStep 3You run the python script by entering this command in the command prompt. Replace YOURWRITEAPIKEY in the command with your write API key:sudo python dht11_thingspeak.py YOURWRITEAPIKEY Here is the corrected python code:#My First Internet of Things#Temperature/Humidity Light monitor using Raspberry Pi, DHT11, and photosensor #Data is displayed at thingspeak.com#2015/06/15#SolderingSunday.com#Based on project by Mahesh Venkitachalam at electronut.in# Import all the libraries we need to runimport sysimport RPi.GPIO as GPIOimport osfrom time import sleepimport Adafruit_DHTimport urllib2DEBUG = 1# Setup the pins we are connect toRCpin = 24DHTpin = 23#Setup our API and delaymyAPI = "Y5HGYOS51NFJ2I5O"myDelay = 15 #how many seconds between posting dataGPIO.setmode(GPIO.BCM)GPIO.setup(RCpin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)def 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))def RCtime(RCpin): LT = 0 if (GPIO.input(RCpin) == True): LT += 1 return (str(LT))# main() functiondef main(): print 'starting...' baseURL #My First Internet of Things#Temperature/Humidity Light monitor using Raspberry Pi, DHT11, and photosensor #Data is displayed at thingspeak.com#2015/06/15#SolderingSunday.com#Based on project by Mahesh Venkitachalam at electronut.in# Import all the libraries we need to runimport sysimport RPi.GPIO as GPIOimport osfrom time import sleepimport Adafruit_DHTimport urllib2DEBUG = 1# Setup the pins we are connect toRCpin = 24DHTpin = 23#Setup our API and delaymyAPI = "Y5HGYOS51NFJ2I5O"myDelay = 15 #how many seconds between posting dataGPIO.setmode(GPIO.BCM)GPIO.setup(RCpin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)def 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))def RCtime(RCpin): LT = 0 if (GPIO.input(RCpin) == True): LT += 1 return (str(LT))# main() functiondef main(): print 'starting...' baseURL = 'https://api.thingspeak.com/update?api_key=%s' % myAPI print baseURL while True: try: RHW, TW, TWF = getSensorData() LT = RCtime(RCpin) f = urllib2.urlopen(baseURL + "&field1=%s&field2=%s&field3=%s" % (TW, TWF, RHW)+ "&field4=%s" % (LT)) print f.read() print TW + " " + TWF+ " " + RHW + " " + LT f.close() sleep(int(myDelay)) except: print 'exiting.' break# call main#My First Internet of Things#Temperature/Humidity Light monitor using Raspberry Pi, DHT11, and photosensor #Data is displayed at thingspeak.com#2015/06/15#SolderingSunday.com#Based on project by Mahesh Venkitachalam at electronut.in# Import all the libraries we need to runimport sysimport RPi.GPIO as GPIOimport osfrom time import sleepimport Adafruit_DHTimport urllib2DEBUG = 1# Setup the pins we are connect toRCpin = 24DHTpin = 23#Setup our API and delaymyAPI = "Y5HGYOS51NFJ2I5O"myDelay = 15 #how many seconds between posting dataGPIO.setmode(GPIO.BCM)GPIO.setup(RCpin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)def 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))def RCtime(RCpin): LT = 0 if (GPIO.input(RCpin) == True): LT += 1 return (str(LT))# main() functiondef main(): print 'starting...' baseURL #My First Internet of Things#Temperature/Humidity Light monitor using Raspberry Pi, DHT11, and photosensor #Data is displayed at thingspeak.com#2015/06/15#SolderingSunday.com#Based on project by Mahesh Venkitachalam at electronut.in# Import all the libraries we need to runimport sysimport RPi.GPIO as GPIOimport osfrom time import sleepimport Adafruit_DHTimport urllib2DEBUG = 1# Setup the pins we are connect toRCpin = 24DHTpin = 23#Setup our API and delaymyAPI = "Y5HGYOS51NFJ2I5O"myDelay = 15 #how many seconds between posting dataGPIO.setmode(GPIO.BCM)GPIO.setup(RCpin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)def 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))def RCtime(RCpin): LT = 0 if (GPIO.input(RCpin) == True): LT += 1 return (str(LT))# main() functiondef main(): print 'starting...' baseURL = 'https://api.thingspeak.com/update?api_key=%s' % myAPI print baseURL while True: try: RHW, TW, TWF = getSensorData() LT = RCtime(RCpin) f = urllib2.urlopen(baseURL + "&field1=%s&field2=%s&field3=%s" % (TW, TWF, RHW)+ "&field4=%s" % (LT)) print f.read() print TW + " " + TWF+ " " + RHW + " " + LT f.close() sleep(int(myDelay)) except: print 'exiting.' break# call mainif __name__ == '__main__': main() baseURL = 'https://api.thingspeak.com/update?api_key=%s' % myAPI print baseURL while True: try: RHW, TW, TWF = getSensorData() LT = RCtime(RCpin) f = urllib2.urlopen(baseURL + "&field1=%s&field2=%s&field3=%s" % (TW, TWF, RHW)+ "&field4=%s" % (LT)) print f.read() print TW + " " + TWF+ " " + RHW + " " + LT f.close() sleep(int(myDelay)) except: print 'exiting.' break# call mainif __name__ == '__main__': main()if __name__ == '__main__': main() baseURL = 'https://api.thingspeak.com/update?api_key=%s' % myAPI print baseURL while True: try: RHW, TW, TWF = getSensorData() LT = RCtime(RCpin) f = urllib2.urlopen(baseURL + "&field1=%s&field2=%s&field3=%s" % (TW, TWF, RHW)+ "&field4=%s" % (LT)) print f.read() print TW + " " + TWF+ " " + RHW + " " + LT f.close() sleep(int(myDelay)) except: print 'exiting.' break# call mainif __name__ == '__main__': main()

    View Instructable »