heckler wrote:I am trying to do something similar and would love to see how you have implemented this in your code.
Would you be willing to share your code and how you have accomplished this and how you are sending the email alert.
Hi - "my" code is just chunks cribbed from other posts in this forum (or even the documentation!).
In this case the main data collection is done with an Arduino that has been running for about 5 years.
It saves temperatures to a csv file on an sd card and outputs data, status and error messages to the serial port.
The ESP- 01 takes the serial input and does the thingspeak update and checks for temperature changes below preset levels. On a falling change, an email is sent.
The init code includes the email info:-
baudrate 38400
serialflush
setupemail "xxxxx.co.uk", 25, "username", "password"
address$ = "xxxxx@gmail.com"
reply$ = "thermo@xxxxx.co.uk"
subject$ = "Message from Central Heating"
msgsent = 0
serialbranch [serialin]
wait
The thingspeak stuff is done here where top$ and t23$ are two temperatures:-
tskey$ = "xxxxxxxxxxxxx"
tsnum$ = "1"
tsdata$ = top$ & "&field2=" & t23$
sendts(tskey$, tsnum$,tsdata$)
and finally the emails as the water temperature drops:-
If (val(t23$) < 40) and (msgsent = 0 ) Then
body$ = "Yellow warning: two thirds hot water tank is " & t23$ &"C"
email address$, reply$, subject$, body$
msgsent = 1
goto [endit]
End If
If (val(t23$) < 30) and (msgsent < 2 ) Then
body$ = "Amber warning: two thirds hot water tank is " & t23$ &"C"
email address$, reply$, subject$, body$
msgsent = 2
goto [endit]
End If
If (val(top$) < 40) and (msgsent < 3 ) Then
body$ = "Red warning: all hot water tank is " & top$ &"C"
email address$, reply$, subject$, body$
msgsent = 3
goto [endit]
End If
If (val(t23$) > 45) and (val(top$) >45) Then
msgsent = 0 'clear message sent flag
end if
Hope that helps.