Hey guys again I got issue with my sim900 shield I tried the softwareserial library with 7, 8
But it doesn't respond to AT command, it connects to the network alright cause I put a call through the sim and I received a ring back.
And it ought to send a message to a specific number which it didn't. I need help pls
Hi
how is it powered when connected to the Arduino?
how did you connect it to your arduino?
@J-M-L I powered it using the Arduino or 9V battery it was having issues but I learned it should be powered by 5V 2A adapter which I did and since then I have not been having issues with it's power.
The connection was as such the Tx was connected to pin 7 of the Arduino and the Rx to 8 the gnd to common gnd of Arduino
Below is the code which I used
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8); // gsm module connected here
String textForSMS;
int pir = 6;// pir sensor is connected with pin2 of the arduino
int touch= 7;
int ledpin = 2; // Alarm/light can be connected with this led
int buzzer= 3;
void setup() {
randomSeed(analogRead(0));
lcd.begin(16,2);
delay(1000);
Serial.begin(9600);
SIM900.begin(9600); // original 19200. while enter 9600 for sim900A
Serial.println(" logging time completed!");
pinMode(pir, INPUT);
pinMode(ledpin, OUTPUT);
digitalWrite(ledpin, LOW);
pinMode(touch, INPUT);
pinMode(buzzer, OUTPUT);
digitalWrite(buzzer, HIGH);
digitalWrite(ledpin, HIGH);
delay(2000);
digitalWrite(buzzer, LOW);
digitalWrite(ledpin, LOW);
lcd.print("Please wait !");
lcd.setCursor(0,1);
lcd.print("welcome to intruder alarm sys");
delay(3000);
Serial.println("please wait");
Serial.println("welcome to intruder alarm sys");
Serial.println();
delay(5000); // wait for 5 seconds
}
void loop() {
{
int S1=0, S2=0;
S1=digitalRead(pir);
S2=digitalRead(touch);
if (S1 == HIGH) //
{
textForSMS = "\nIntruder detected";
digitalWrite(ledpin, HIGH);
digitalWrite(buzzer, HIGH);
delay(1000);
digitalWrite(ledpin, LOW);
digitalWrite(buzzer, LOW);
lcd.home();
lcd.print("MOTION DETECTED");
delay (3000);
sendSMS(textForSMS);
Serial.println(textForSMS);
Serial.println("message sent.");
delay(5000);
}
if ( S1 == LOW) //
{
digitalWrite(ledpin, LOW);
digitalWrite(buzzer, LOW);
}
else if(S2==HIGH)
{
textForSMS= "\nSomeone is trying to break in.";
digitalWrite(buzzer, HIGH);
digitalWrite(ledpin, HIGH);
delay(1000);
digitalWrite(buzzer, LOW);
digitalWrite(ledpin, LOW);
lcd.home();
lcd.print("touch detected");
delay(1000);
sendSMS(textForSMS);
Serial.println(textForSMS);
Serial.println("message sent");
delay(5000);
}
if(S2==LOW)
{
digitalWrite(buzzer, LOW);
digitalWrite(ledpin, LOW);
}
else{}
}
It's a project for final year sch stuff pls help ASAP
are you sure the board supports 5V for communication?
please edit your post, select the code part and press the </> icon in the tool bar to mark it as code. It's unreadable as it stands. (also make sure you indented the code in the IDE before copying, that's done by pressing ctrlT on a PC or cmdT on a Mac)
Here is the full code and as for the 5V it is specified #include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
#include <SoftwareSerial.h>
SoftwareSerial SIM900(0, 1); // gsm module connected here
String textForSMS;
int pir = 6;// pir sensor is connected with pin2 of the arduino
int touch= 7;
int ledpin = 2; // Alarm/light can be connected with this led
int buzzer= 3;
void setup() {
randomSeed(analogRead(0));
lcd.begin(16,2);
delay(1000);
Serial.begin(9600);
SIM900.begin(9600); // original 19200. while enter 9600 for sim900A
Serial.println(" logging time completed!");
pinMode(pir, INPUT);
pinMode(ledpin, OUTPUT);
digitalWrite(ledpin, LOW);
pinMode(touch, INPUT);
pinMode(buzzer, OUTPUT);
digitalWrite(buzzer, HIGH);
digitalWrite(ledpin, HIGH);
delay(2000);
digitalWrite(buzzer, LOW);
digitalWrite(ledpin, LOW);
lcd.print("Please wait !");
lcd.setCursor(0,1);
lcd.print("welcome to intruder alarm sys");
delay(3000);
Serial.println("please wait");
Serial.println("welcome to intruder alarm sys");
Serial.println();
delay(5000); // wait for 5 seconds
}
void loop() {
{
int S1=0, S2=0;
S1=digitalRead(pir);
S2=digitalRead(touch);
if (S1 == HIGH) //
{
textForSMS = "\nIntruder detected";
digitalWrite(ledpin, HIGH);
digitalWrite(buzzer, HIGH);
delay(1000);
digitalWrite(ledpin, LOW);
digitalWrite(buzzer, LOW);
lcd.home();
lcd.print("MOTION DETECTED");
delay (3000);
sendSMS(textForSMS);
Serial.println(textForSMS);
Serial.println("message sent.");
delay(5000);
}
if ( S1 == LOW) //
{
digitalWrite(ledpin, LOW);
digitalWrite(buzzer, LOW);
}
else if(S2==HIGH)
{
textForSMS= "\nSomeone is trying to break in.";
digitalWrite(buzzer, HIGH);
digitalWrite(ledpin, HIGH);
delay(1000);
digitalWrite(buzzer, LOW);
digitalWrite(ledpin, LOW);
lcd.home();
lcd.print("touch detected");
delay(1000);
sendSMS(textForSMS);
Serial.println(textForSMS);
Serial.println("message sent");
delay(5000);
}
if(S2==LOW)
{
digitalWrite(buzzer, LOW);
digitalWrite(ledpin, LOW);
}
else{}
}
}
void sendSMS(String message)
{
SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message
delay(1000);
SIM900.println("AT + CMGS = "+2348034424400""); // recipient's mobile number, in international format
delay(1000);
SIM900.println("intrusion detected"); // message to send
delay(1000);
SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(1000);
SIM900.println();
delay(100); // give module time to send SMS
} @J-M-L
PLEASE USE CODE TAGS!
the 0 and 1 feel wrong
SoftwareSerial SIM900(0, 1); // gsm module connected here
...
Serial.begin(9600);
SIM900.begin(9600); // original 19200. while enter 9600 for sim900A
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8); // gsm module connected here
String textForSMS;
int pir = 6;// pir sensor is connected with pin2 of the arduino
int touch= 7;
int ledpin = 2; // Alarm/light can be connected with this led
int buzzer= 3;
void setup() {
randomSeed(analogRead(0));
lcd.begin(16,2);
delay(1000);
Serial.begin(19200);
SIM900.begin(19200); // original 19200. while enter 9600 for sim900A
Serial.println(" logging time completed!");
pinMode(pir, INPUT);
pinMode(ledpin, OUTPUT);
digitalWrite(ledpin, LOW);
pinMode(touch, INPUT);
pinMode(buzzer, OUTPUT);
digitalWrite(buzzer, HIGH);
digitalWrite(ledpin, HIGH);
delay(2000);
digitalWrite(buzzer, LOW);
digitalWrite(ledpin, LOW);
lcd.print("Please wait !");
lcd.setCursor(0,1);
lcd.print("welcome to intruder alarm sys");
delay(3000);
Serial.println("please wait");
Serial.println("welcome to intruder alarm sys");
Serial.println();
delay(5000); // wait for 5 seconds
}
void loop() {
{
int S1=0, S2=0;
S1=digitalRead(pir);
S2=digitalRead(touch);
if (S1 == HIGH) //
{
textForSMS = "\nIntruder detected";
digitalWrite(ledpin, HIGH);
digitalWrite(buzzer, HIGH);
delay(1000);
digitalWrite(ledpin, LOW);
digitalWrite(buzzer, LOW);
lcd.home();
lcd.print("MOTION DETECTED");
delay (3000);
sendSMS(textForSMS);
Serial.println(textForSMS);
Serial.println("message sent.");
delay(5000);
}
if ( S1 == LOW) //
{
digitalWrite(ledpin, LOW);
digitalWrite(buzzer, LOW);
}
else if(S2==HIGH)
{
textForSMS= "\nSomeone is trying to break in.";
digitalWrite(buzzer, HIGH);
digitalWrite(ledpin, HIGH);
delay(1000);
digitalWrite(buzzer, LOW);
digitalWrite(ledpin, LOW);
lcd.home();
lcd.print("touch detected");
delay(1000);
sendSMS(textForSMS);
Serial.println(textForSMS);
Serial.println("message sent");
delay(5000);
}
if(S2==LOW)
{
digitalWrite(buzzer, LOW);
digitalWrite(ledpin, LOW);
}
else{}
}
}
void sendSMS(String message)
{
SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message
delay(1000);
SIM900.println("AT + CMGS = "+2348034424400""); // recipient's mobile number, in international format
delay(1000);
SIM900.println("intrusion detected"); // message to send
delay(1000);
SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(1000);
SIM900.println();
delay(100); // give module time to send SMS
}
Code tags I really don't know about that beside am new in coding Arduino
Pls I just changed the softwareserial to 7, 8
And the baudrate to 19200 dunno if that's good for my region Nigeria
SoftwareSerial SIM900(7, 8);
int touch= 7;
You can not use pin 7 for both SS rx and your sensor.
Publish the real code ... and please edit your previous posts, select the code part and press the </> icon in the tool bar to mark it as code. It’s unreadable as it stands. (also make sure you indented the code in the IDE before copying, that’s done by pressing ctrlT on a PC or cmdT on a Mac)
Hey buddy I have figured out a way to make it right and now it's working fine ` #include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#include <SoftwareSerial.h>
SoftwareSerial SIM900(7. 8); // gsm module connected here
String textForSMS;
int pir = 10;// pir sensor is connected with pin10 of the arduino
int touch= 6;
int alarm = 13 // Alarm/light can be connected with this led
int SIMPOWER= 9;
void setup() {
randomSeed(analogRead(0));
lcd.begin(16,2);
delay(1000);
Serial.begin(9600);
SIM900.begin(9600); // original 19200. while enter 9600 for sim900A
Serial.println(" logging time completed!");
pinMode(pir, INPUT);
pinMode(alarm, OUTPUT);
digitalWrite(alarm, LOW);
pinMode(touch, INPUT);
pinMode(SIMPOWER, OUTPUT);
digitalWrite(alarm, HIGH);
delay(2000);
digitalWrite(alarm, LOW);
lcd.print("Please wait !");
lcd.setCursor(0,1);
lcd.print("welcome to intruder alarm sys");
delay(3000);
Serial.println("please wait");
Serial.println("welcome to intruder alarm sys");
Serial.println();
delay(5000); // wait for 5 seconds
}
void loop() {
{
int S1=0, S2=0;
S1=digitalRead(pir);
S2=digitalRead(touch);
if (S1 == HIGH) //
{
textForSMS = "\nIntruder detected";
digitalWrite(ledpin, HIGH);
digitalWrite(buzzer, HIGH);
delay(1000);
digitalWrite(ledpin, LOW);
digitalWrite(buzzer, LOW);
lcd.home();
lcd.print("MOTION DETECTED");
delay (3000);
sendSMS(textForSMS);
Serial.println(textForSMS);
Serial.println("message sent.");
delay(5000);
}
if ( S1 == LOW) //
{
digitalWrite(alarm, LOW);
}
else if(S2==HIGH)
{
textForSMS= "\nSomeone is trying to break in.";
digitalWrite(alarm, HIGH);
delay(1000);
digitalWrite(alarm, LOW);
lcd.home();
lcd.print("touch detected");
delay(1000);
sendSMS(textForSMS);
Serial.println(textForSMS);
Serial.println("message sent");
delay(5000);
}
if(S2==LOW
digitalWrite(alarm, LOW);
}
else{}
}
}
void sendSMS(String message)
{
SIM900.print("AT");
SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message
delay(1000);
SIM900.println("AT + CMGS = "+2348034424400""); // recipient's mobile number, in international format
delay(1000);
SIM900.println("intrusion detected"); // message to send
delay(1000);
SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(1000);
SIM900.println();
delay(100); // give module time to send SMS
}
`` `
glad you solved it
the code tags need to be on a line by themselves, that's why your previous post does not look good)
Oops my bad you know am new in this whole stuff @
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.