Hello to everyone in the community, firstly would like to thank all of you for reading this post and that any suggestion or remarks would be greatly appreciated. Lets get to it shall we...I have written some code to send SMS's to a recipient phone number using AT commands transmitted from the Controllino MAXI to the SIM Module instructing it to carry out certain commands.
Devices Used:
- SIM5320E Module
- Mean Well 5V/5A Switch Mode Power Supply
- Controllino MAXI - ATmega 2560-16AU chip
This is my problem:
I am able to receive certain messages but unable to receive some as well.
Within this piece of code you will see a switch that toggles 4 messages to be sent to the users phone. Case 1 and 2 are the main cases that will be used, case 3 and 4 are just to show you how strange a behavior this problem is.
Now, if you were to try out my code...you should be able to observe the symptom that I am currently facing:
- Case 1: Works fine; response from SIM module received and message received on users phone.
- Case 2: Does not work; response from SIM module received but message not received on users phone.
- Case 3: Commented out the first line of the message, works fine; response from SIM module received and message received on users phone.
- Case 4: Commented out the third line of the message, works fine; response from SIM module received and message received on users phone.
Would like to understand better as to why Case 2 SMS message was not able to be sent even with successful responses from the SIM module. Thank you in advance.
This is my code:
#include <Controllino.h>
#include <SoftwareSerial.h>
SoftwareSerial SIM5320(52, 50); //rx, tx
unsigned long initialTime = 0;
byte commandInterval = 50;
String stringUser = "+xxxxxxxxxxx";
void setup() {
Serial.begin(9600);
Serial.println("Remote Control Test Ready!");
SIM5320.begin(9600);
Serial.println("SMS Communication Line Initialised...");
Serial.println("System Setting Up...");
delay(5000);
Serial.println("System Setup Complete!");
}
void loop() {
while (SIM5320.available()) {
Serial.write(SIM5320.read());
}
while (Serial.available()) {
char serialInput = Serial.read();
switch (serialInput) {
case '1':
SIM5320.print(F("AT+CMGS=\""));
SIM5320.print(stringUser);
SIM5320.println(F("\""));
initialTime = millis();
while (millis() < initialTime + commandInterval) {
//Do nothing
}
SIM5320.print(F("Remote Locker Assign Report\n"));
SIM5320.print(F("Locker Number : 1\n"));
SIM5320.print(F("Pin Code : 99999\n"));
SIM5320.print(F("Blocks Paid : 255"));
break;
case '2':
SIM5320.print(F("AT+CMGS=\""));
SIM5320.print(stringUser);
SIM5320.println(F("\""));
initialTime = millis();
while (millis() < initialTime + commandInterval) {
//Do nothing
}
SIM5320.print(F("Remote Locker Terminate Report\n"));
SIM5320.print(F("Locker Number : 1\n"));
SIM5320.print(F("Pin Code : 99999\n"));
SIM5320.print(F("Blocks Paid : 0"));
break;
case '3':
SIM5320.print(F("AT+CMGS=\""));
SIM5320.print(stringUser);
SIM5320.println(F("\""));
initialTime = millis();
while (millis() < initialTime + commandInterval) {
//Do nothing
}
//SIM5320.print(F("Remote Locker Terminate Report\n"));
SIM5320.print(F("Locker Number : 0\n"));
SIM5320.print(F("Pin Code : 99999\n"));
SIM5320.print(F("Blocks Paid : 0"));
break;
case '4':
SIM5320.print(F("AT+CMGS=\""));
SIM5320.print(stringUser);
SIM5320.println(F("\""));
initialTime = millis();
while (millis() < initialTime + commandInterval) {
//Do nothing
}
SIM5320.print(F("Remote Locker Terminate Report\n"));
SIM5320.print(F("Locker Number : 1\n"));
//SIM5320.print(F("Pin Code : 99999\n"));
SIM5320.print(F("Blocks Paid : 0"));
break;
}
}
}