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

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

import smtplib
import time

def sendemail(from_addr, to_addr_list, cc_addr_list,
subject, message,
login, password,
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)
problems = server.sendmail(from_addr, to_addr_list, message)

import RPi.GPIO as GPIO
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(24, GPIO.OUT, initial=False) #Siren pin setup
GPIO.wait_for_edge(23, GPIO.RISING)
print "\nRising edge ALARM"
sendemail(from_addr = '',
to_addr_list = ['@gmail.coml'],
cc_addr_list = [''],
subject = 'ALARM',
message = 'alarm',
login = '',
password = '****')

GPIO.output(24, True)
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