Olá pessoal,
chegou essa semana um shild que comprei da china (http://dx.com/p/freaduino-gsm-gprs-shield-expansion-board-for-ardui...)
É um SIM900.
Mas estou apanhando para enviar um sms via software.
Conectei e via telnet consegui enviar o sms, mas programando e salvando nada...
usei esse que achei na net.
Obrigado pessoal
-----------------------------------------------------
#include <NewSoftSerial.h>
NewSoftSerial mySerial(2, 3);
void setup()
{
delay(10000);
Serial.begin(19200); //Default serial port setting for the GPRS modem is 19200bps 8-N-1
Serial.print("\r");
delay(1000); //Wait for a second while the modem sends an "OK"
Serial.print("AT+CMGF=1\r"); //Because we want to send the SMS in text mode
delay(1000);
Serial.print("AT+CMGS=\"981510000\"\r"); //Start accepting the text for the message
//to be sent to the number specified.
//Replace this number with the target mobile number.
delay(1000);
Serial.print("SIM900 and Arduino say Hi!\r"); //The text for the message
delay(1000);
Serial.print(0x1A,BYTE);
Serial.print(26,BYTE); //Equivalent to sending Ctrl+Z
}
void loop()
{
//We just want to send the SMS only once, so there is nothing in this loop.
//If we put the code for SMS here, it will be sent again and again and cost us a lot.
}
Tags:
Permalink Responder até sergio silva em 15 outubro 2012 at 2:02
Pessoal, com o código acima deu certo, mas precisei comentar a linha
NewSoftSerial mySerial(2, 3);
e setar os jumpers para hardware.
Mas ele deveria enviar também com soft certo?
Alguem tem alguma dica?
Valeu gente.
Permalink Responder até sergio silva em 15 outubro 2012 at 2:44
Oi pessoal...consegui algo com o código abaixo.
obrigado
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3);
void setup()
{
mySerial.begin(19200);
Serial.begin(19200);
}
void loop()
{
mySerial.print("\r");
delay(1000);
mySerial.print("AT+CMGF=1\r");
delay(1000);
mySerial.print("AT+CMGS=\"+5511981510000\"\r");
delay(1000);
mySerial.print("SIM900 and Arduino say Hi!\r");
delay(1000);
mySerial.write(26);
}
Bem-vindo a
Laboratorio de Garagem (arduino, eletrônica, robotica, hacking)
Por: R$ 29,00
Ou em até 6x de
R$ 5,18
Por: R$ 54,00
Ou em até 12x de
R$ 5,10
Por: R$ 195,00
Ou em até 18x de
R$ 13,00
Válvula Solenóide de 12V - 3/4"
Por: R$ 36,00
Ou em até 7x de
R$ 5,56
© 2013 Criado por Marcelo Rodrigues.