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); }
12 Replies
ZacckOsiemo
ZacckOsiemo7mo ago
Been a while since I worked with a SIM module, if I recall you may need an antenna?
ZacckOsiemo
ZacckOsiemo7mo ago
i remember something like going outside my office or to my window for signal
aymen ammari
aymen ammari7mo ago
I'm using 3 cm one but still the same problem
Ben
Ben7mo ago
Sim 900 has an antenna like thing
Ben
Ben7mo ago
Try using the serial monitor to see if you are actually getting value from the module, also check your pin configuration
Ben
Ben7mo ago
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.
Ben
Ben7mo ago
attachment 0
Ben
Ben7mo ago
I saw something please check it out
attachment 0
wafa_ath
wafa_ath7mo ago
hi aymen , The SIM900A seems to be limited to Asia, and only compatible with 2G. Have you check this limitations ?
aymen ammari
aymen ammari7mo ago
I already tryed multiple codes like this and non of them workd + pin configuration is correct just tx and rx
aymen ammari
aymen ammari7mo ago
Oohh I didn't know that, I'm situated in African, lemme check that maybe that's why
Ben
Ben7mo ago
Check the sim module if it's actually working
Want results from more Discord servers?
Add your server