← Back to questions

Q: GPIO alarm python script

Hi There, I made a script in python that detects a rising edge on one of the GPIO's of my pi, then sends an email and rings a bel Script is running But stil have one problem For some reason the script/Pi detects a rising edge (when the script is running for 4min)? The gpio input has a 1K Ohm resistor so it is not floating What is going wrong? Can you guys help me out? Greets from Holland kawa Here is the script: ------------------------------------------------------------------- import smtplib import time def sendemail(from_addr, to_addr_list, cc_addr_list, subject, message, login, password, smtpserver='smtp.gmail.com:587'): header = 'From: %s\n' % from_addr header += 'To: %s\n' % ','.join(to_addr_list) header += 'Cc: %s\n' % ','.join(cc_addr_list) header += 'Subject: %s\n\n' % subject message = header + message server = smtplib.SMTP(smtpserver) server.starttls() server.login(login,password) problems = server.sendmail(from_addr, to_addr_list, message) server.quit() import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(24, GPIO.OUT, initial=False) #Siren pin setup try: GPIO.wait_for_edge(23, GPIO.RISING) print "\nRising edge ALARM" sendemail(from_addr = '@gmail.com', to_addr_list = ['@gmail.coml'], cc_addr_list = [''], subject = 'ALARM', message = 'alarm', login = '@gmail.com', password = '****') GPIO.output(24, True) time.sleep(5) except KeyboardInterrupt: GPIO.cleanup() # clean up GPIO on CTRL+C exit GPIO.cleanup() # clean up GPIO on normal exit
kawa_j Asked by: kawa_j