making a smoke sensor that sends a sms message to a user when it detects smoke.
I'm new to arduino coding and we are tasked with making a smoke sensor that sends a sms message to a user when it detects smoke. One problem that we've encountered is that our gsm module 900a can't seem to find a network (the status LED blinks every second rather than every 3 seconds). How can we fix this problem?
I will provide the code below
int buzzer = 8;
int smokeA0 = A5;
int sensorThres = 0;
#include<SoftwareSerial.h>
SoftwareSerial GSM (9, 10);
void setup()
{
pinMode(buzzer, OUTPUT);
pinMode(smokeA0, INPUT);
Serial.begin(9600);
GSM.begin (9600);
delay(100);
}
void loop() {
int analogSensor = analogRead(smokeA0);
if (analogSensor > sensorThres) { digitalWrite(buzzer, HIGH); delay (1000); Serial.println("AT+CMGF=1");
delay(1000);
Serial.println("AT+CMGS="+639053188487"\r"); Serial.println("smoke detected alert"); Serial.println((char)26); delay(100); } else { digitalWrite(buzzer,LOW); } delay(50); }
if (analogSensor > sensorThres) { digitalWrite(buzzer, HIGH); delay (1000); Serial.println("AT+CMGF=1");
delay(1000);
Serial.println("AT+CMGS="+639053188487"\r"); Serial.println("smoke detected alert"); Serial.println((char)26); delay(100); } else { digitalWrite(buzzer,LOW); } delay(50); }
12 Replies
Been a while since I worked with a SIM module, if I recall you may need an antenna?
i remember something like going outside my office or to my window for signal
I'm using 3 cm one but still the same problem
Sim 900 has an antenna like thing
Try using the serial monitor to see if you are actually getting value from the module, also check your pin configuration
Test the sim module,
#include <SoftwareSerial.h>
//Create software serial object to communicate with SIM900
SoftwareSerial mySerial(7, 8); //SIM900 Tx & Rx is connected to Arduino #7 & #8
void setup()
{
//Begin serial communication with Arduino and Arduino IDE (Serial Monitor)
Serial.begin(9600);
//Begin serial communication with Arduino and SIM900 mySerial.begin(9600); Serial.println("Initializing..."); delay(1000); mySerial.println("AT"); //Handshaking with SIM900 updateSerial(); mySerial.println("AT+CSQ"); //Signal quality test, value range is 0-31 , 31 is the best updateSerial(); mySerial.println("AT+CCID"); //Read SIM information to confirm whether the SIM is plugged updateSerial(); mySerial.println("AT+CREG?"); //Check whether it has registered in the network updateSerial(); } void loop() { updateSerial(); } void updateSerial() { delay(500); while (Serial.available()) { mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port } while(mySerial.available()) { Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port } } Once you have uploaded the sketch, open the serial monitor at baud rate 9600. You should see the output below on the serial monitor.
//Begin serial communication with Arduino and SIM900 mySerial.begin(9600); Serial.println("Initializing..."); delay(1000); mySerial.println("AT"); //Handshaking with SIM900 updateSerial(); mySerial.println("AT+CSQ"); //Signal quality test, value range is 0-31 , 31 is the best updateSerial(); mySerial.println("AT+CCID"); //Read SIM information to confirm whether the SIM is plugged updateSerial(); mySerial.println("AT+CREG?"); //Check whether it has registered in the network updateSerial(); } void loop() { updateSerial(); } void updateSerial() { delay(500); while (Serial.available()) { mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port } while(mySerial.available()) { Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port } } Once you have uploaded the sketch, open the serial monitor at baud rate 9600. You should see the output below on the serial monitor.
I saw something please check it out
hi aymen ,
The SIM900A seems to be limited to Asia, and only compatible with 2G.
Have you check this limitations ?
I already tryed multiple codes like this and non of them workd + pin configuration is correct just tx and rx
Oohh I didn't know that, I'm situated in African, lemme check that maybe that's why
Check the sim module if it's actually working