Hello community. Once again I'm desperate need of your assistance...
I'm controlling Arduino Uno with VB.NET application which is working just fine. I also have SIM900 shield connected to Arduino as I need to send text messages to various numbers. The phone numbers are extracted from MySQL DB by the VB application and send to Arduino. This is my first time using SIM900 and AT commands so I checked Google and there are hundreds of simple guides out there for general uses. So at first I tested with the simple 4-line send SMS program which worked well and then I switched to 'call' command which is just 1 line and cost no money to test with it while developing.
So far everything that worked perfectly was this - VB app sends this:
spArduino.WriteLine("<ATD+ " & phone & ";>")
where 'phone' was the extracted number from the DB. And in Arduino it looked like this:
if (receivedChars[0] == 'A') {
digitalWrite(indication, HIGH);
SIM900.println(receivedChars);
//updateSerial();
delay(1000);
digitalWrite(indication, LOW); }
The above worked outstandingly. So, I reached the very end of my project and all I had left to do is switch the voice call command to SMS command.
The VB command became:
spArduino.WriteLine("<AT + CMGS = \""" & phone & "\"">")
...and the Arduino code became:
if (receivedChars[0] == 'A') {
digitalWrite(indication, HIGH);
SIM900.println("AT+CMGF=1");
updateSerial();
SIM900.println(receivedChars);
updateSerial();
SIM900.println("sms body");
updateSerial();
SIM900.println((char)26);
updateSerial();
SIM900.println();
delay(1000);
updateSerial();
digitalWrite(indication, LOW); }
And it turned out for some reason this is not working. I turned on the debugging 'updateSerial();' to monitor what's happening and it appears the trouble line is 'SIM900.println(receivedChars);'.
If I change it to 'SIM900.println("AT+CMGS="+35xxxxxxxxx5"");' it works but when it comes from VB it doesn't. I checked the whole line symbol by symbol and it's absolutely the same, it makes no sense not to work. I also tried splitting the command in 2 with end line:
spArduino.WriteLine("<\""" & phone & "\"">")
if (receivedChars[2] == '+') {
digitalWrite(indication, HIGH);
SIM900.println();
SIM900.println("AT+CMGF=1");
updateSerial();
SIM900.println();
SIM900.print("AT+CMGS=");
SIM900.print(receivedChars);
SIM900.println();
updateSerial();
SIM900.print("sms body");
delay(3000);
SIM900.println();
SIM900.write(26);
updateSerial();
digitalWrite(indication, LOW);
Same error on the same line. I thought maybe the '' symbols are doing something wrong inside the array as this is the only difference between the voice call command and the SMS command so I tried converting to String and use it like that but still the same error on the same place.
I honestly have no idea what else I can try and I'd really appreciate any advise here.
Thank you.