Hi, this is my first post. I am a total noob, please be nice.
I am working on one of those projects where a plant emails you if it needs watering. Somehow I have managed so far to get the sensor sending info to the UNO, and connect to an smtp server with the ethernet shield. I want to get different messages depending on the needs of the plant. Example, "Water me urgently!", Water me.", "Thanks for watering me", "You over watered me".
So far what I have is: When a very low humidity level is detected, the sendmeEmail() function is called. This function simply sends me an email with the body saying "URGENT: Water me!". This is done with the line client.write("URGENT! Water me!\r\n");
But I need the message body to vary, and say the other conditions. How can I pass a specific condition to the sendmeEmail() function and have it email me different body messages depending on each condition? I'm sure it's not hard but my noobiness took over at this point, any help is appreciated. Cheers!
You could add arguments to the sendEmail() function so that you can pass in the subject line and message body, and provide different values depending on the circumstances.
Thanks Peter. That's exactly what I need. I tried but my knowledge of programing is quite limited. I am not sure how I could pass these (strings?) to the function and have that text replaced by them. I've searched quite a bit on google but wasn't able to find out how to do that. Any leads? Cheers
You haven't added the arguments to the sendEmail() function. You've added them instead to the sendmeEmail() function, which doesn't do anything with them so far.
I'm not sure why you have two functions for the same job, but the one that actually sends the email needs the extra arguments I showed you. If you want to wrap that with another function that does the same thing, you would need to add the arguments to that function too and then pass them through to the other function that actually sends the email. I don't see the point of having two functions though - why not just call sendEmail() directly? It also seems strange for sendmeEmail() to reinitialise the ethernet interface each time it is called. That should normally only be done once, during setup().
I removed that second sendmeEmail() function, and also had the ethernet initialize only once now!
Had some trouble today it wouldn't talk to the smtp server. I'm not sure why it worked yesterday and no today but looking at some examples I changed HELO for EHLO and works perfectly now!