Show Posts
|
|
Pages: [1] 2 3
|
|
1
|
Using Arduino / General Electronics / button pad question
|
on: March 21, 2013, 08:17:18 pm
|
Hi all, just had a quick question about this shield: https://www.sparkfun.com/products/7835I have a similar component that I salvaged. I expected it to short when I depress the button and contact is made. Instead, I observe a resistance(cant recall what it was off the top of my head). Does that seem correct? Should the button be shorting the circuit? Will this still work with the arduino as a push button?
|
|
|
|
|
2
|
Using Arduino / Networking, Protocols, and Devices / Re: EFCom GPRS/GSM Shield
|
on: January 19, 2013, 11:09:42 am
|
|
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.
|
|
|
|
|
3
|
Using Arduino / Networking, Protocols, and Devices / Re: EFCom GPRS/GSM Shield
|
on: January 19, 2013, 10:34:54 am
|
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 }
|
|
|
|
|
4
|
Using Arduino / Networking, Protocols, and Devices / Re: EFCom GPRS/GSM Shield
|
on: January 18, 2013, 10:28:54 pm
|
|
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)
does anyone have any suggestions?
|
|
|
|
|
9
|
Using Arduino / Networking, Protocols, and Devices / Re: serial connection to c168i
|
on: November 29, 2012, 06:09:36 pm
|
UPDATE: I switched the serial port used to communicate with the phone to the softserial (2,3), and was able to get some response from my phone. Here is what I get when I run the code used in the previous post: ÿÿÿÿÿÿÿÿX ÿÿÿÿÿÿÿÿX ÿÿÿÿÿÿÿÿX ÿÿÿÿÿÿÿÿX ÿÿÿÿÿÿÿÿX ÿÿÿÿÿÿÿÿX ÿÿÿÿÿÿÿÿX ÿÿÿÿÿÿÿÿX ÿÿÿÿÿÿÿÿX ÿÿÿÿÿÿÿÿX ÿÿÿÿÿÿÿÿX ÿÿÿÿÿÿÿÿX ÿÿÿÿÿÿÿÿX
my serial monitor is set to 9600, does anyone know what this means? Seems like this is the serials version of -1 (255)? Anyone know how I can use that?
|
|
|
|
|
10
|
Using Arduino / Networking, Protocols, and Devices / Re: serial connection to c168i
|
on: November 28, 2012, 10:31:48 am
|
I appologize, I made a mistake and posted the incorrect code. I have removed it to hopefully avoid confusion. Here is my code that I used to try and listen: EDIT: UPDATED CODE TO BELOW: long prev1 = 0;
#include <SoftwareSerial.h> SoftwareSerial mySerial(2,3); // RX, TX
void setup(){ Serial.begin(9600); mySerial.begin(4800); }
void loop() { long now = millis();
do { now = millis(); if( now - prev1 > (3000) ){ SendText();
prev1 = millis(); }
} while( true ); }
void SendText() { mySerial.println("AT+SWRESET"); Serial.write(mySerial.read()); delay(500); mySerial.println("AT"); // Sends AT command to wake up cell phone Serial.write(mySerial.read()); delay(500);
mySerial.println("AT+CMGF=1"); // Puts phone into SMS mode Serial.write(mySerial.read()); delay(1000); // Wait a second
mySerial.println("AT+CMGW=\"+17084979117\""); // Creates new message to number Serial.write(mySerial.read()); delay(1000);
mySerial.print("The temperature is:"); // Message contents mySerial.println("80"); Serial.write(mySerial.read()); delay(1000);
mySerial.write(26); Serial.write(mySerial.read()); delay(1000);
mySerial.println("AT+CMSS=1"); // Sends message at index of 1 Serial.write(mySerial.read()); delay(1000);
mySerial.println("AT+CMGD=1"); // Deletes message at index of 1 Serial.write(mySerial.read()); Serial.println('X'); }
|
|
|
|
|
12
|
Using Arduino / Networking, Protocols, and Devices / Re: serial connection to c168i
|
on: November 21, 2012, 09:22:50 pm
|
OK I have re-written the code. How does this look? long prev1 = 0; long prev2 = 0; int sensorPin = 0; //the analog pin the TMP36's Vout (sense) float current_tempF = 0; long check_interval = 3000; long text_interval = 120000;
void setup() { Serial.begin(4800); }
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) { pinMode(13, OUTPUT); // Initialize pin 13 as digital out (LED)
Serial.println("AT"); // Sends AT command to wake up cell phone delay(1000);
Serial.println("AT+CMGF=1"); // Puts phone into SMS mode delay(1000); // Wait a second
Serial.println("AT+CMGW=\"+17084979117\""); // Creates new message to number delay(1000);
Serial.print("The temperature is:"); // Message contents Serial.println(msg); delay(1000);
Serial.write(26); delay(1000);
Serial.println("AT+CMSS=1"); // Sends message at index of 1 delay(1000);
Serial.println("AT+CMGD=1"); // Deletes message at index of 1 }
After testing, there is still something wrong with the text messages. They appear in the outbox, and the content looks good, however, there is a red circle with a slash though it when I look at the list of messages sitting in the outbox and they do not always get sent. Does this make any sense?
|
|
|
|
|
13
|
Using Arduino / Networking, Protocols, and Devices / Re: serial connection to c168i
|
on: November 18, 2012, 07:22:14 pm
|
time = time + interval; Adding times is not a good idea. Overflow is not handled properly with addition. delay(interval); If you are going to use the dreaded delay(), why bother with relative times, anyway. I initially tried to not use the "dreaded delay". You may be correct, and this could be part of my problem. I will try and revert back to code that does not use the delay. Serial.begin(4800); // Open serial connection at baud rate of 4800 This belongs in setup(). You don't need to do this every time you want to send a text message. Serial.end(); You don't ever need to do this. I did have this in the "setup", but I moved it into the loop because I was afraid that there was some sort of connection issue between my code and the phone (over time). I will move it back. delay(2000); // Wait a second Can't count, huh? I can't tell you how hard this made my laugh!  Initially, it was 1000, but I did end up changing it. Every AT command elicits a response. Why do you not read the responses?
I suppose I could, I am not sure where I would store them? How could I read these?
|
|
|
|
|
14
|
Using Arduino / Networking, Protocols, and Devices / serial connection to c168i
|
on: November 18, 2012, 05:08:00 pm
|
Hi all. I have read and found several examples where people have sent sms messages from a c168i, here is just one example: http://sheffiel.blogspot.com/2011/02/remote-car-starter-controlling-motorola.htmlMy own code makes the arduino act as a temperature sensor and send a texts at a regular interval or when the temperature gets too low. The code works for the most part, but sometimes ends up sending the texts too often and with the exact same temperature reading. I suspect that there is some serial communication problem that just accumulates until it gets to the point where the phone is not put into the correct mode or something weird. Would anyone mind giving this a look over and checking whether I am doing something wrong? Thanks //TMP36 Pin Variables int sensorPin = 0; //the analog pin the TMP36's Vout (sense)
long interval = 20000; //how often to check long day = 1200000; float low_temp = 71;
long time = 0; float tempF = 0;
void setup(){
}
void loop(){ CheckTemp();
if (tempF < low_temp){ SendText(tempF); time = time-16000+interval; } else if(time == day){ SendText(tempF); time = 0; } else{ time = time + interval; } delay(interval); //SendText(tempF); }
void CheckTemp(){ int reading = analogRead(sensorPin); float voltage = reading * 5.0; voltage /= 1024.0; tempF = ((voltage - 0.5) * 900.0 / 5.0) + 32; }
void SendText(float msg) { Serial.begin(4800); // Open serial connection at baud rate of 4800 delay(2000);
Serial.println("AT"); // Sends AT command to wake up cell phone delay(2000);
Serial.println("AT+CMGF=1"); // Puts phone into SMS mode delay(2000); // Wait a second
Serial.println("AT+CMGW=\"+15555555555\""); // Creates new message to number delay(2000);
Serial.println("The temperature is"); // Message contents Serial.println(msg); delay(2000);
Serial.write(26); delay(2000);
Serial.println("AT+CMSS=1"); // Sends message at index of 1 delay(2000);
Serial.println("AT+CMGD=1"); // Deletes message at index of 1 delay(2000); Serial.end(); }
|
|
|
|
|