I am using a SIM900 GSM module, I need to make it reply with an SMS anytime it receives one, but I'm having problems with the if condition, what should it be?
I wrote it as
but when I run it It keeps sending SMSs every 2-3 seconds even if I didn't send it !
so what should I do ??
If there is ANY data available, without even reading it, send a message. I don't think so.
You want to READ the message first! Only send a message AFTER the WHOLE message has been received.
ok .. that kindda worked but not 100%
it didn't send until I sent it an SMS, but after that it kept sending and sending, plus I still have another problem which is I don't get the SMS on mobile, it's just stays on the serial monitor.
Is it safe to assume (I seriously doubt it) that you are sending messages consisting of ONE character?
yes, it could be one character or more, and it prints the received SMS on the serial monitor (even with more than 1 character) but it is not replying
actually sometimes the message is not delivered, and sometimes it is delivered and then it keeps sending SMSs continuously !!
yes, it could be one character
Bullshit. The message contains a LOT more than the text you sent.
Until you understand how to read a message, you are wasting our time. Read AND DO NOTHING MORE THAN PRINT WHAT YOU READ, each message you receive.
Send several messages, until you get the idea how to read an entire message AND KNOW that you have received the end of message marker.
Only then can you consider sending a message in response.
I know that the message contains a lot more than the text I sent !!
I worked on a GSM module and everything was going fine, but recently I don't know what happened to it, it started to receive only but it does not send
so I had to replace the GSM module with another one and work with the code from the start !!