Water Heater Fault Notification using Raspberry Pi

Connecting a light sensor:
https://pimylifeup.com/raspberry-pi-light-sensor/

Sending email in python:
https://stackoverflow.com/questions/16381527/sending-e-mails-using-yahoo-account-in-python

Photoresistors: https://amzn.to/2tSmzfm
1uf electrolytic capactiors: https://amzn.to/2VGYVOG
Solderless prototyping breadboard: https://amzn.to/2Hhxyac
Breadboard jumper wires: https://amzn.to/2XE850k
Raspberry Pi case: https://amzn.to/2Up8hia

Raspberry Pi 3 (Amazon Affiliate)
US: https://amzn.to/2z01nKu
UK: https://amzn.to/3fO896P
CA: https://amzn.to/360IEL4
ES: https://amzn.to/2T3o4nY
FR: https://amzn.to/2WUiKVb
IT: https://amzn.to/3brTtqA
DE: https://amzn.to/361cqPR
IN: https://amzn.to/3eG2LBx

#!/usr/bin/python

import RPi.GPIO as GPIO
import time
import smtplib
from datetime import datetime
current_time = datetime.now()

fromMy = 'fromaddress@yahoo.com' # fun-fact: from is a keyword in python, you can't use it as variable, did abyone check if this code even works?
to  = 'toaddress@example.com'
subj='Water Heater is Down'
date=current_time.strftime('%m/%d/%Y')
message_text='Water heater is down'

msg = "From: %s\nTo: %s\nSubject: %s\nDate: %s\n\n%s" % ( fromMy, to, subj, date, message_text )
import smtplib
username = str('fromaddress@yahoo.com')  
password = str('fromaddresspassword')  

__author__ = 'Gus (Adapted from Adafruit)'
__license__ = "GPL"
__maintainer__ = "pimylifeup.com"

GPIO.setmode(GPIO.BOARD)

#define the pin that goes to the circuit
pin_to_circuit = 7
threshold = 400
#time between notifications (in seconds)
time_between_notifications = 7200
last_notification = 0

def rc_time (pin_to_circuit):
    count = 0
  
    #Output on the pin for 
    GPIO.setup(pin_to_circuit, GPIO.OUT)
    GPIO.output(pin_to_circuit, GPIO.LOW)
    time.sleep(0.1)

    #Change the pin back to input
    GPIO.setup(pin_to_circuit, GPIO.IN)
  
    #Count until the pin goes high
    while (GPIO.input(pin_to_circuit) == GPIO.LOW):
        count += 1

    return count

#Catch when script is interupted, cleanup correctly
try:
    # Main loop
    while True:
	if rc_time(pin_to_circuit) < threshold and (time.time() > last_notification + time_between_notifications):
		try :
		    server = smtplib.SMTP("smtp.mail.yahoo.com",587)
		    server.starttls()
		    server.login(username,password)
		    server.sendmail(fromMy, to,msg)
		    server.quit()    
		    print ('ok the email has sent ')
		except :
		    print ('can\'t send the Email')
		print 'test'
		last_notification = time.time()
        print rc_time(pin_to_circuit)
except KeyboardInterrupt:
    pass
finally:
    GPIO.cleanup()

Audio-Technica AT-LP120-USB Stylus Replacement including Alignment and Tracking Force

Audio-Technica AT-LP120-USB: https://amzn.to/2TirF3R (Amazon affiliate)

Audio-Technica ATN95E Stylus (Amazon Affiliate)
US: https://amzn.to/3mkHUXU
UK: https://amzn.to/2RbQ8Uw
CA: https://amzn.to/2thg4WP
ES: https://amzn.to/3fU7YWJ
FR: https://amzn.to/31dUj95
IT: https://amzn.to/31fyGFo
DE: https://amzn.to/3hT069X
IN: https://amzn.to/2A15fM1
AU: https://amzn.to/2AWuvDH

Samyo Stylus Scale (Amazon Affiliate)
US: https://amzn.to/2Hdkhzn
UK: https://amzn.to/2FPR3Vo (similar)
CA: https://amzn.to/2FPR1ge
ES: https://amzn.to/3e4i0Dz (similar)
FR: https://amzn.to/3e9Jho7 (similaire)
IT: https://amzn.to/3e1PUc0 (simile)

Audio-Technica AT-LP120-USB Alignment Template:
https://audio-technica.com.au/wp-content/uploads/2013/10/0406_2904_00_cartridge_headshell_alignment_sheet.pdf

Audio-Technica AT-LP120-USB Manual: https://www.scribd.com/document/322824497/p52120-03-at-lp120-usb-at95e-om-pdf