[duemilanove] [PIR ALARM] CANT COMUNICATE W/MODEM

This post is the same i have published in International / Spanish Section, but translated (with the help of google).

Someone can Help Me?

I’m finishing a project with Arduino Duemilanove

I only have some programming knowledge and some electricity

Gathering information through the network, I have an alarm that
detects the presence of people through a PIR sensor,
an LCD display, a piezo electric, and a switch (key).

Everything is fine except for one detail, the idea is ejjeej alert by sms.

In-SMS Arduino tutorial, you use a modem (tc35i) very similar to mine ,
but in my duemilanove Arduino, I am not very clear about the topic
for communication with serial port, as I have tried a lot
methods, (Serial, softserial, newsoftserial) …

And I have cant talk to the modem.

The modem, a clone of the TC-35i, I can attack with HyperTerminal
sms-command without problems. Connect with a 9600, 8, n, 1

When I tested with the Arduino, the response I get to
tell the “ATI” (information of the modem)
or “AT + CPIN = 1234” (provides the pin of the sim),

is always the same, (-1)

the modem for any reason you are not getting orders
there is a mass that is common with Arduino and modem
and rx is coneceted to tx and vice versa.

Another thing I’ve noticed is that the modem, only get orders, begins with “AT”
as i test successfuly with hyperterminal.

I think that what I am commanded, not understood by Arduino, perhaps
speaks another language (which changes the parity bit or stop) or because
The format of the commands you’ve sent, char, is not adequate. Or
perhaps put resistance between the pins or something to send and receive.
do i need a max232?

Someone can help me with this issue?

Here I leave with you my code, and some photos.

CODE

#include <NewSoftSerial.h>
#include <LCD4Bit.h>
LCD4Bit lcd = LCD4Bit(2);
int luzfondo = 13;

int llave = 11; // nombrar un pin de entrada para nuestro botón

int zumbador = 3;
int SensorPir = 6;

int desarmado;
boolean presencia ;

int pinSpeaker = 5;
int frec = 2500;
int dur = 400;
int SWnotificado = 0;
int ContadorDesarme;
int incomingByte = 0;

int rxPin = 3;
int txPin = 4;

NewSoftSerial modem(3,4);

void setup() {
lcd.init();
pinMode(luzfondo, OUTPUT); // Para la luz de fondo de la pantalla lcd.
pinMode(llave, INPUT); // declarar el pin como entrada
pinMode(SensorPir, INPUT); //
pinMode(pinSpeaker, OUTPUT);
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);

modem.begin(9600);
}

void playTone(long duration, int freq) {
duration *= 1000;
int period = (1.0 / freq) * 1000000;
long elapsed_time = 0;
while (elapsed_time < duration) {
digitalWrite(pinSpeaker,HIGH);
delayMicroseconds(period / 2);
digitalWrite(pinSpeaker, LOW);
delayMicroseconds(period / 2);
elapsed_time += (period);
}
frec = frec + 10;
dur = dur + 1 ;

}

void loop() {

inicioloop:
desarmado = digitalRead(llave);

if ( (SWnotificado == 1) && (desarmado == LOW) ) { goto inicioloop; }

SWnotificado = 0;
desarmado = digitalRead(llave);
presencia = digitalRead(SensorPir);
lcd.clear();
if (desarmado == HIGH) {

digitalWrite(luzfondo, HIGH);
lcd.clear();
lcd.printIn(“SISTEMA”) ;
lcd.cursorTo(2, 0);
lcd.printIn(“DESARMADO”);
delay (3000);

} else { // AHORA ESTA FUNCIONANDO

lcd.clear();
digitalWrite(luzfondo, HIGH);
lcd.printIn(“ARMANDO EN”) ;
lcd.cursorTo(2, 0);
lcd.printIn(“10 SEGUNDOS”);
delay (1000);

desarmado = digitalRead(llave); if ( desarmado == HIGH) { goto inicioloop ; }

lcd.cursorTo(2, 0);
lcd.printIn(“09 SEGUNDOS”);
delay (1000);
desarmado = digitalRead(llave); if ( desarmado == HIGH) { goto inicioloop ; }

lcd.cursorTo(2, 0);
lcd.printIn(“08 SEGUNDOS”);
delay (1000);
desarmado = digitalRead(llave); if ( desarmado == HIGH) { goto inicioloop ; }

lcd.cursorTo(2, 0);
lcd.printIn(“07 SEGUNDOS”);
delay (1000);
desarmado = digitalRead(llave); if ( desarmado == HIGH) { goto inicioloop ; }

lcd.cursorTo(2, 0);
lcd.printIn(“06 SEGUNDOS”);
delay (1000);
desarmado = digitalRead(llave); if ( desarmado == HIGH) { goto inicioloop ; }

lcd.cursorTo(2, 0);
lcd.printIn(“05 SEGUNDOS”);
delay (1000);
desarmado = digitalRead(llave); if ( desarmado == HIGH) { goto inicioloop ; }

lcd.cursorTo(2, 0);
lcd.printIn(“04 SEGUNDOS”);
delay (1000);
desarmado = digitalRead(llave); if ( desarmado == HIGH) { goto inicioloop ; }

lcd.cursorTo(2, 0);
lcd.printIn(“03 SEGUNDOS”);
delay (1000);
desarmado = digitalRead(llave); if ( desarmado == HIGH) { goto inicioloop ; }

lcd.cursorTo(2, 0);
lcd.printIn(“02 SEGUNDOS”);
delay (1000);
desarmado = digitalRead(llave); if ( desarmado == HIGH) { goto inicioloop ; }

lcd.cursorTo(2, 0);
lcd.printIn(“01 SEGUNDOS”);
delay (1000);
desarmado = digitalRead(llave); if ( desarmado == HIGH) { goto inicioloop ; }

lcd.clear();
digitalWrite(luzfondo, HIGH);
lcd.printIn(“SISTEMA ARMADO”);
delay (1500);
digitalWrite(luzfondo, LOW);
lcd.clear();

delay (5000);

presencia = LOW;

do {
presencia = digitalRead(SensorPir);
} while ( presencia == LOW ) ;

//EN CASO DE DETECCION
ContadorDesarme = 0;
do {
desarmado = digitalRead(llave); //ver si han desarmado
playTone(dur, frec); // un pitido.
lcd.clear();
digitalWrite(luzfondo, HIGH); // enciende pantalla
lcd.printIn(“ATENCION INTRUSO”);
lcd.cursorTo(2, 0);
lcd.printIn(“DESARME AHORA”);
ContadorDesarme = ContadorDesarme + 1;
delay (1000);
digitalWrite(luzfondo, LOW);} //apaga pantalla
while (desarmado == LOW && ContadorDesarme <= 15);
// FIN ContadorDesarme

if (desarmado == HIGH) { goto inicioloop; } ; //Si has desarmado, que empiece de nuevo

if ( (SWnotificado == 1) && (desarmado == LOW) ) { goto inicioloop; } // si esta armado,
pero ya ha notificado SMS que vaya al princiopio donde no volvera a empezar hasta que rearme de nuevo.

digitalWrite(luzfondo, HIGH);
lcd.clear();
lcd.printIn(“Preparado para”);
lcd.cursorTo(2, 0);
lcd.printIn(“Mandar SMS”);
delay (10000);


HERE IS THE PROBLEM

modem.println (“AT+CPIN=1234”); // Stablish the pin of sim, i have
tested that this command dont arrives to modem.

modem.print(“AT+CMGS=”);
modem.println(34,BYTE);
modem.print("+34622622622"); // sms destination.
modem.println(34,BYTE);
modem.print(“Someone is stealing”);
modem.println(26,BYTE); // Write Ctrl+Z

------------------------------------- lcd.clear();
lcd.printIn(“SMS”);
lcd.cursorTo(2, 0);
lcd.printIn(“SENT”);
delay (3000);
SWnotificado = 1 ;
}
}

Pics are in:
(just copy and paste in address bar, i can´t post it)

personales.ya.com/jesusillo/alarma.jpg
personales.ya.com/jesusillo/alarma2.jpg
personales.ya.com/jesusillo/alarma3.jpg