0

I'm following this guide - http://videos.cctvcamerapros.com/digital-io-alarm-in-out/send-push-notifications-from-raspberry-pi.html

I've installed pycurl using sudo apt-get install python-pycurl but when i run the code it simply shows:

Traceback (most recent call last): File "/home/pi/desktop/doorsensor.py", line 1, in <module> import pycurl, json importError: No module named pycurl

Can anyone help?

Here is my code

import pycurl, json
from StringIO import StringIO
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
appID = "56cbc8e95659e3f40dc56c64"
appSecret = "a8c3c0302545ad64f71f7aa5f10e52ef"
pushEvent = "DoorAlert"
pushMessage = "Door Opened!"
buffer = StringIO()
c = pycurl.Curl()
c.setopt(c.URL, 'https:api.instapush.im/v1/post')
c.seopt(c.HTTPHEADER, ['x-instapush-appid: ' + appID,
                   'x-instapush-appsecret: ' + appSecret,
                   'Content-Type: application/json'])
json_fields = {}
json_fields['event']=pushEvent
json_fields['trackers'] = {}
json_fields['trackers']['message']=pushMessage
postfields = json.dumps(json_fields)
c.setopt(c.POSTFIELDS, postfields)
c.setopt(c.WRITEFUNCTION, buffer.write)
c.setopt(c.VERBOSE, True)
while True:
GPIO.wait_for_edge(23, GPIO.RISING)
print("Door Opened!\n")
c.perform()
body= buffer.getvalue()
print(body)
buffer.turncate(0)
buffer.seek(0)
GPIO.wait_for_edge(23, GPIO.FALLING)
print("Door Closed!\n")
c.close()
GPIO.cleanup()

Ok so I ran in it Python v2.7. and it works. But now I'm getting

traceback (most recent call last):
  File "/home/pi/Desktop/doorSensor.py", line 5, in <module>
    GPIO.setup(26, GPIO.IN, pull_up_down=GPIO.PUD_UP)
RuntimeError: No access to /dev/mem. Try running as root!
Trevor Hess
  • 1
  • 1
  • 2

0 Answers0