Execute tabbed code from main tab.

Thanks for clicking this. My question to me sounds like it has a simple answer but don't we all have to start sometime somewhere.

My task is to have, using the arduino base shield, an email sent when the temperature reaches a preset number (taken from the temperature sensor v1.2) then the led then turns off.

My code for the temperature and led function works fine on it's own. It's posted here.
My e-mail code (generated using the Temboo tutorials) also works fine on it's own, bearing in mind it has two tabs, e-mail tab and TembooAccount.h tab.

So I'm left with 2 separate arduino ide's, one does the temperature thingy and the other sends an e-mail. Both work.

My question, how do I somehow use the e-mail code efficiently within the if statement of the temperature code so an e-mail will be sent or in other words the e-mail code will be executed when the if statement executes the "led off" line. Thanks for your patience in decrypting my sloppy english above :smiley:

Temperature code

const int B=4275; // B value of the thermistor
const int R0 = 100000; // R0 = 100k
const int pinTempSensor = A3; // Grove - Temperature Sensor connect to A5

void setup()
{
Serial.begin(9600);
pinMode(2, OUTPUT);
}

void loop()
{
int a = analogRead(pinTempSensor );

float R = 1023.0/((float)a)-1.0;
R = 100000.0*R;

float temperature=1.0/(log(R/100000.0)/B+1/298.15)-273.15;//convert to temperature via datasheet ;

Serial.print("temperature = ");
Serial.println(temperature);

delay(100);

if (temperature < 32 )
{
digitalWrite(2, HIGH); // turn the LED on (HIGH is the voltage level)
}
else
{
digitalWrite(2, LOW); // turn the LED off by making the voltage LOW

}

}

It doesn't appear that that code is what you are having problems with. It is the message sending code that you need to integrate that code into. It is that code that you need to (also) post IN CODE TAGS.

Legalece102:
I am getting the same problem!

Given the profile picture you've chosen, you deserve to have problems.

PaulS:
It doesn't appear that that code is what you are having problems with. It is the message sending code that you need to integrate that code into. It is that code that you need to (also) post IN CODE TAGS.

Thanks for reply, so is it like the #include "email.ino" tags that your saying? I'm not an expert at this but I can sort of get what your getting at.

Say then I had one Arduino IDE interface open and it had three tabs. The first tab is the temperature code (posted above) and the other two tabs are the standard copied code from temboo's email tutorial, one the e-mail tab and the other the TembooAccount.h tab.
In the e-mail tab i have at the top, amongst other includes, I have #include "TembooAccount.h". This seems to call the temboo tab. So do I do the same within the temperature code tab , so I can call the e-mail tab as long as the if statement has the else output?
Regards

PaulS:
Given the profile picture you've chosen, you deserve to have problems.

I would ask trump, but he has a habit of tweeting his own stuff and then disappearing from all the TRUTHFUL replies.

If you're going to quote some one, at least credit the quote accordingly.

You don't need to include .ino files. They are all automatically concatenated into a single file in the order the tabs are shown. during compilation. Breaking a sketch into multiple .ino files is only done to organize code and make it easier to navigate through large projects. The "CODE TAGS" mentioned by PaulS is referring to the way you're supposed to post code on the forum, which you would know if you had read the How to use this forum post. Please read it.

loosetile2:
so I can call the e-mail tab as long as the if statement has the else output?

No, it doesn't work that way. #include is a preprocessor directive, it's done before the sketch starts to run, or even compile. Once it's running the file was either included or not included. You can do conditional includes but you have to use preprocessor conditionals (e.g. #if) and as before this will be done prior to compilation.