Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

Raspberry GPIO email script

OP kawa_j

12th January 2014, 12:15 AM   |  #1  
OP Junior Member
Thanks Meter: 0
 
1 posts
Join Date:Joined: Jan 2013
Hi,

I made a simple script that sends me an email when the raspberry detects a rising signal on a gpio input
Between the switch and the gpio i have mounted a resistor (1K ohm all connections are soldered) to prevent the gpio from flaoting
Script works well but when it is up and running for about 15min the RPI detects a rising signal?

Can someone help me out?

greets kawa

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
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes