Raspberry Pi and Cosm

MrMobileWill cosm, python, raspberry pi, xbee Leave a Comment

Over a month ago I decided to give Cosm.com a try instead of using my own MySQL database and graphing in Python. Since this was awhile ago I don’t remember everything I did to get it working but I will post the code and libraries I am using that work. Here is a simple library to making sending to Cosm easy. http://www.netfluvia.org/layer8/?p=175 Here is the full code I am using to log the PIR sensor to Cosm, after the jump. #!/usr/bin/python#PIR LOGGING TO COSMimport RPi.GPIO as GPIOimport sysimport timeimport datetimefrom datetime import timedelta import cosmAPI_KEY=”API_KEY”FEED_ID=”FEED_ID”def writeCosm(status): pfu = cosm.PachubeFeedUpdate(FEED_ID,API_KEY) pfu.addDatapoint(“Pi”,status) pfu.buildUpdate() pfu.sendUpdate() print “Uploaded Motion data to Cosm” return ledPin = 17pirPin = 18motionCount = 0timerMin = 1 #Number of …