problem solved
I'd suggest that you add a line Serial.print(msg); to see what comes out in serial monitor.
Can I place Serial.print(msg); anywhere?
Your code snippet seems to have an awful lot of closing braces.
carnivore:
Can I place Serial.print(msg); anywhere?
I'd suggest you put it immediately before sms.print(msg) so you get to see EXACTLY what you're sending to your gsm shield.
Edit: and don't forget to add Serial.begin(9600); in your setup function.
I placed the Serial.print(msg); before sms.print(msg) and the results are below:
Experiment complete
Then when I reset the board, the lcd would be stuck and no messages appear on serial monitor
Just post code.
problem solved
problem solved
int Sensor = xxx;
int buzz = xxx;
int relay = xxx;
int power;
int i = xxx;
int time = xxx;
int time1 = xxx;
int time2 = xxx;
xxx?
Thanks for catching that. I updated it
char msg[200] = {'E','x','p','e','r','i','m','e','n','t',' ','c','o','m','p','l','e','t','e'};
This will not put a terminator on the string
This will. See if it makes a difference.
char msg[200] = {"Experiment complete"};
This will not put a terminator on the string
No, but crt0 will.
Any clue to on how I would solve my issue?
You haven't been very specific about what inconsistent means. I would surmise the sketch occasionally doesn't send the sms, correct? If that is the case, maybe a little error checking is in order. endSMS() returns a value depending on the mode.
If synchronous mode:
// change this
sms.endSMS();
// to something like this. Use the lcd instead of Serial if you wish
if(sms.endSMS() == 1) Serial.println("SMS sent ok");
else Serial.println("SMS send failed");
At the start of your loop function you have
while(1){
Not only is this redundant (the loop function automatically loops. That's what it's there for) but it also prevents your arduino the time that it needs to do it's housekeeping on the Serial bus.
Since your loop NEVER completes, any Serial.print commands you issue are going to be flaky at best. It may even be a suspect in the problem you are having.
Delete the line that I have indicated and remove it's associated closing brace (probably just before the end of the loop function)
I've removed both loop functions while(1){
I have also placed
if(sms.endSMS() == 1) Serial.println("SMS sent ok");
else Serial.println("SMS send failed");
in place of
sms.endSMS();
at both locations with no success.
problem solved
problem solved
The script still does not send SMS messages consistently.
What do you mean by not consistently? Does the endSMS function return 1 and the SMS is not sent?