I would like to use one of the analog pins in addition to this shield. Does anyone know whether the shield actually uses that IO? Can I just solder on some female IO adapters that pass through the shield?
So I have written my code and my arduino/shield work fine...for a while. After a few days or so the gsm sheid seems to stop sending sms'. I am only able to get things working by resetting the gsm shield (not the arduino)
and my arduino/shield work fine...for a while. After a few days or so the gsm sheid seems to stop sending sms'. I am only able to get things working by resetting the gsm shield (not the arduino)
does anyone have any suggestions?
Not really. I'll bet, though, that you'll think of something real soon.
PaulS, I cant tell if you are angered by my posts or just sarcastic. But I am going to take it in good humor.
Below is my code, hopefully it is not too sloppy:
long prev1 = 0;
long prev2 = 0;
int sensorPin = 0; //the analog pin the TMP36's Vout (sense)
float current_tempF = 0;
unsigned long check_interval = 600000;
unsigned long text_interval = 86400000;
//unsigned long text_interval = 28800000;
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3);
void setup() {
mySerial.begin(19200); // the GPRS baud rat
//Serial.begin(19200);
CheckTemp();
SendText(current_tempF);
}
void loop() {
long now = millis();
do {
now = millis();
//check if temperature is low
if( now - prev2 > (check_interval) ){
CheckTemp();
if( current_tempF < 60 ){
SendText(current_tempF);
}
prev2 = millis();
}
//send the daily text message
if( now - prev1 > (text_interval) ) {
CheckTemp();
SendText(current_tempF);
prev1 = millis();
}
} while( true );
}
void CheckTemp(){
int reading = analogRead(sensorPin);
float voltage = reading * 5.0;
voltage /= 1024.0;
current_tempF = ((voltage - 0.5) * 900.0 / 5.0) + 32;
}
void SendText(float msg) {
//mySerial.println("AT+SWRESET");
//delay(500);
mySerial.println("AT"); // Sends AT command to wake up cell phone
delay(500);
mySerial.println("AT+CMGF=1"); // Puts phone into SMS mode
delay(1000); // Wait a second
mySerial.println("AT+CMGS=\"+15553334444\""); // Creates new message to number
delay(1000);
mySerial.print("The temperature is "); // Message contents
mySerial.println(msg);
delay(1000);
mySerial.write(26);
delay(1000);
//mySerial.println("AT+CMSS=1"); // Sends message at index of 1
//delay(1000);
//mySerial.println("AT+CMGD=1"); // Deletes message at index of 1
}
Literal constants are interpreted as ints, in the absence of any directive to the contrary. 86400000 is not an int value. You need to tell the compiler that it isn't by adding UL on the end.
long now = millis();
Why is now not unsigned?
long prev1 = 0;
long prev2 = 0;
Why are prev1 and prev2 not unsigned? Are you expecting time to flow backwards?
I don't see Serial being initialized, or used for debugging. I suppose that there is a reason wy, but I can't imagine what it is.
So one thing I just noticed, is that if the shield and arduino stop sending texts, I can just reset the phone shield, everything works again.
I am still a newb so I had just copied/pasted variables. If something should be unsigned, I will change it.
I did not initialize the serial and debug because the device is not connected to a computer. At the moment it is in use, I quickly made it for a family member and they have it.
and my arduino/shield work fine...for a while. After a few days or so the gsm sheid seems to stop sending sms'. I am only able to get things working by resetting the gsm shield (not the arduino)
does anyone have any suggestions?
Not really. I'll bet, though, that you'll think of something real soon.
You can reset the Shield from the Arduino using code
digitalWrite(6, LOW); // Turn the GSM Modem OFF
digitalWrite(6, HIGH); // Turn the GSM Modem ON
digitalWrite(5, LOW); // Reset the GSM Modem