Skip to content

4. Remote Monitoring Alarm Email

The Groundhog Whisperer edited this page Jul 24, 2019 · 6 revisions

Greenhouse automation system email/SMS alert notification script

greenhousealarmemail.py

This script runs on the greenhouse Raspberry Pi and sends email/SMS notifications when temperature values are too high or low or soil moisture values are too high.

Example execution using cron and a crontab every thirty minutes

$ sudo crontab -e

*/30 * * * * python /home/pi/Greenhouse/greenhousealarmemail.py

Example email and sms message screenshots generated by greenhousealarmemail.py

greenhousealarmemail.py Example Screenshot SMS Message

greenhousealarmemail.py Example Screenshot Email Message

Configuration of the Email/SMS alarm notification script greenhousealarmemail.py

The greenhousealarmemail.py script requires configuration of the minimum and maximum alarm values located in the script header. The greenhousealarmemail.py script also requires a valid SMTP server address and valid account credentials before an alarm notification may be sent.

Edit the greenhousealarmemail.py using nano and configure the following values.

$ nano /home/pi/Greenhouse/Greenhousealarmemail/greenhousealarmemail.py

# Minimum temperature to trigger an email/sms alarm notification
MINIMUM_TEMPERATURE_ALARM = 32.05

# Maximum temperature to trigger an email/sms alarm notification
MAXIMUM_TEMPERATURE_ALARM = 101.99

# Maximum soil moisture to trigger an email/sms alarm notification
MAXIMUM_SOIL_MOISTURE_ALARM = 3.1

# Email message from address value
FROM_EMAIL_ADDRESS_VALUE = '[email protected]'

# Email message recipients destination address values
RECIPIENTS_EMAIL_ADDRESS_VALUES = ['[email protected]', '[email protected]']

# SMTP email servers host name
EMAIL_SMTP_SERVER_HOST_NAME = 'smtp.email.example'

# SMTP server user name
SMTP_SERVER_LOGIN_NAME = '[email protected]'

# SMTP server password
SMTP_SERVER_LOGIN_PASSWORD = 'shhhhaplaintextpasswordvalue'

Proceed to next section: Section 5. Remote Monitoring Report Email