General area when it fits no where else

Moderator: Mmiscool

User avatar
By bugs
#60477
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:-
Code: Select allbaudrate 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:-
Code: Select all  tskey$ = "xxxxxxxxxxxxx"
  tsnum$ = "1"
  tsdata$ = top$ & "&field2=" & t23$
  sendts(tskey$, tsnum$,tsdata$)


and finally the emails as the water temperature drops:-
Code: Select all 
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.
User avatar
By Oldbod
#60799
Mmiscool wrote:Take a look at this thread.

It shows a php script on a web server that logs data to a my sql database.


Sounds interesting but I can't see anything (on firefox) on my screen linking to the thread that "shows a php script on a web server that logs data to a my sql database." Tantalising :)