Email alert not working

Hi guys, i´m trying to get an email altert to work but i can´t, the only thing that works fine is the temperature reading.

I have the following sketch, and when it gets compiled it returns a few errors:

28:29: warning: unused parameter 'subject' [-Wunused-parameter]

void sendEmail(char subject[], char message1[], char message2[], float temp) {

                            ^

In function 'void loop()':

87:70: warning: integer overflow in expression [-Woverflow]

if (tempC >= HighThreshold && (millis()>(lastMessage+(emailInterval*1000)))) {

93:74: warning: integer overflow in expression [-Woverflow]

else if (tempC <= LowThreshold && (millis()>(lastMessage+(emailInterval*1000)))) {

My code is:

#include <Ethernet.h>
#include <SPI.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define time 1000

#define ONE_WIRE_BUS 3

char message1[35], message2[35];
char subject[] = "ARDUINO TEMPERATURE ALERT""\0";

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer = { 0x28  ,0xFF  ,0x63, 0x10, 0x00, 0x17, 0x04, 0xCC };

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xF7, 0x38 };

EthernetClient client;

void sendEmail(char subject[], char message1[], char message2[]) {
 Serial.println("connecting...");
 if (client.connect(server) {
   Serial.println("connected");
   client.println("AUTH LOGIN"); delay(time);
   client.println("MAIL FROM:<sender@domain.com>"); delay(time);
   client.println("RCPT TO:<recipient@domain.com>"); delay(time);
   client.println("From: < sender@domain.com >"); delay(time);
   client.println("to: < recipient@domain.com >"); delay(time);
   client.print("SUBJECT: ");
   client.println("subject"); delay(time);
   client.println(); delay(time);
   client.println(message1); delay(time);
   client.println(message2); delay(time);
   client.print("Temperature: ");
   client.println(temp); delay(time);
   client.println("."); delay(time);
   client.println("."); delay(time);
   Serial.println("Email sent."); delay(time);
 } else {
   Serial.println(".");
 }
}
void checkEmail() {
 while (client.available()) {
   char = client.read();
   Serial.print(c);
 }
 if (!client.connected()) {
   Serial.println();
   Serial.println();
   client.();
 }
}

void getTemperature(DeviceAddress deviceAddress) {
 tempC = sensors.getTempC(deviceAddress);
 tempF = DallasTemperature::toFahrenheit(tempC);
}

void setup() {
 lastMessage = 0;
 Ethernet.begin
 Serial.begin(9600);
 sensors.begin(address);
 sensors.setResolution(insideThermometer, TEMPERATURE_PRECISION);
 delay(1000);
}

void loop() {
 sensors.requestTemperatures();
 getTemperature(address);
 Serial.println(tempC);
 delay(2500);
 if (tempC >= HighThreshold && (millis()>(lastMessage+(emailInterval*1000)))) {
   Serial.println("High Threshold Exceeded");
   char message1[] = "Temperature Sensor\0";
   char message2[] = "High Threshold Exceeded\0";
   sendEmail(subject, message1, message2, tempC);
 }
 else if (tempC <= LowThreshold && (millis()>(lastMessage+(emailInterval*1000)))) {
   Serial.println("Low Threshold Exceeded");
   char message1[] = "Temperature Sensor\0";
   char message2[] = "Low Threshold Exceeded\0";
   sendEmail(subject, message1, message2, tempC);
 }
}

Any toughts on how to fix this ?

Thanks

t returns a few errors:

Actually they are warnings, not errors

For instance

28:29: warning: unused parameter 'subject' [-Wunused-parameter]

void sendEmail(char subject[], char message1[], char message2[], float temp) {

Is telling you that although you pass the subject array to the sendEmail() function it is not used within the function

@UKHeliBob thanks for your reply.

Do you have any idea why it´s not working ?

On the serial monitor the only info that i have is the temperature, not even an connection failed.

Thanks !

Even a newbie with five posts should know to read the locked topics at the head of the forum, and then would know to post code with code tags, and perhaps would post error messages with code tags too.

There would be fewer warnings if these two lines

  if (tempC >= HighThreshold && (millis()>(lastMessage+(emailInterval*1000)))) {
:
:
:
  else if (tempC <= LowThreshold && (millis()>(lastMessage+(emailInterval*1000)))) {

were changed to

  if (tempC >= HighThreshold && (millis()>(lastMessage+(emailInterval*1000L)))) {
:
:
:
  else if (tempC <= LowThreshold && (millis()>(lastMessage+(emailInterval*1000L)))) {

Notice the L suffix on the constants of 1000.

EXPLANATION: emailInterval is set to 60. 60 times 1000 would be 60000 which overflows an integer which has a maximum value for some Arduinos of 32767. The L suffix on 1000 causes the calculation to be handled as a long integer which has a maximum of 2147483647.

Hi @vaj4088

You´re right I posted before I read the instructions, I´m sorry about that.
I have already edited my first post and the code and error message are posted using code tags, it looks much more nice now.

Thank you so much for your explanation, my code is being compiled with no errors.

Thanks a lot man!!!!