Email and sms if temp gets too high - Raspberry Pi Forums


hi, trying send email , text when temperature of cooler gets high.
trying combine codes sms , email dht11 sensor code keep receiving error, can tell me proper way combine codes.

code: select all

.#!/bin/bash echo "sample text" | mail -s "subject" username@domain.com 

code: select all

#!/usr/bin/python import sys import adafruit_dht    while true:     humidity, temperature = adafruit_dht.read_retry(11,4)    temperature= temp: {0:01f} f %.format(temperature) 

new , useful

not sure how far have got combining , kind error getting here few general suggestions.
1. can run command line things inside python using

code: select all

import subprocess ... subprocess.run(['echo', '"sample text"', '|', 'mail', '-s', '"subject"', 'username@domain.com'])
2. format() method 'belongs' string objects can

code: select all

temperature= 'temp: {:4.1f}f'.format(temperature)
both these things @ python documentation on line see how work. might take little while find relevant sections process of looking lot.


raspberrypi



Comments