Closed vittorioexp closed 7 years ago
Hi. Currently sending SMS is not supported, but it is planned to be added in future. PRs are always welcome ;)
You can now try:
modem.sendSMS("+380679837464", "some text");
or for Unicode (needs data length):
modem.sendSMS_UTF16("+380679837464", u"Привіііт!", 10);
Hi, how do we get the status result of the sent sms whether success or fail?
I have tried the function:
modem.sendSMS("0xxxxxxxxx", "Text here");
I have received the SMS, but its text is wrong
The same using:
modem.sendSMS("0xxxxxxxxx", String ("Text here"));
Please could you double check?
Same problem here with
res = modem.sendSMS(SMS_TARGET, "Hello from TinyGSM");
I got
ßeiØΠ-70V
@ClemensGruber Can you turn on debug and check what is actually going on from the modem's point of view?
For
res = modem.sendSMS(SMS_TARGET, "Hello from TinyGSM");
DBG("SMS:", res ? "OK" : "fail");
I got on serial
SMS: OK
I mean all AT communication between your controller and the modem. Check the HttpClient example, it's here:
#define DUMP_AT_COMMANDS
...
#ifdef DUMP_AT_COMMANDS
#include <StreamDebugger.h>
StreamDebugger debugger(SerialAT, Serial);
TinyGsm modem(debugger);
#else
TinyGsm modem(SerialAT);
#endif
Then you'll see all AT communication.
The SMS function seems not to be very complicated.
My output is (AT and debug from AllFunctions.ino
AT+CMGF=1
OK
AT+CMGS="+49[numberdeleted]"
>Hello from TinyGSM
+CMGS: 14
OK
SMS: OK
An article about SMS encoding: "7 Things You Need to Know about International SMS" https://www.telesign.com/blog/post/7-things-you-need-to-know-about-international-sms/
I don't know yet on which position the problem is. I have a German SIM card mobile phone with German UI and also a German operator. Does this matter?
I used till now AllFunctions.ino as is with all sample / example code. Now I deleted some code that is not necessary before the SMS example and the text is displayed accurate on the phone.
For some reason I can't send SMS at all from my modem. Not sure were issue is. Sorry, can't confirm.
This line: +CMGS: 14
(I think) indicates the number of characters the modem received.
Hello from TinyGSM
length is 18. Maybe this is the issue?
Try the following:
(I saw your code before you deleted it)
Change res = modem.sendSMS("number", "Hello from TinyGSM");
to res = modem.sendSMS("number", String("Hello from TinyGSM"));
I'm not a C++ expert, but I think you should send to the function object types that it expects. You are sending char* instead of String.
I think I got it, the bad boy is
String ussd_balance = modem.sendUSSD("*111#");
DBG("Balance (USSD):", ussd_balance);
String ussd_phone_num = modem.sendUSSD("*161#");
DBG("Phone number (USSD):", ussd_phone_num);
With this functions the modem is set to HEX mode via
AT+CSCS="HEX"
and it is never set back to GSM
Oh, the version that I am using already has this fix. Not sure where I got it :)
bool sendSMS(const String& number, const String& text) {
sendAT(GF("+CMGF=1"));
waitResponse();
sendAT(GF("+CSCS=\"GSM\""));
waitResponse();
sendAT(GF("+CMGS=\""), number, GF("\""));
...
@hubaksis Thanks for your help! Without your comment and the provoken motivation to have a second look this night I would not have solved this issue -- although it was a stupid cause. ;-)
@ClemensGruber No worries. I'm glad that you could find a cause of the problem.
Seems to be fixed for some modems, e.g. the M590 but not for the SIM800.
I've created a pull request.
Spotted already and liked! :-) Thanks!
`// SIM card PIN (leave empty, if not defined) const char simPIN[] = ""; // Your phone number to send SMS: + (plus sign) and country code, for Hungary +36, followed by phone number String mobile_number = "01954004571"; // Configure TinyGSM library
// TTGO T-Call pins
// Set serial for debug console (to Serial Monitor, default speed 115200)
// Set serial for AT commands (to SIM800 module)
// Define the serial console for debug prints, if needed //#define DUMP_AT_COMMANDS
StreamDebugger debugger(SerialAT, SerialMon); TinyGsm modem(debugger);
TinyGsm modem(SerialAT);
void setup() { // Set console baud rate SerialMon.begin(115200); // Set modem reset, enable, power pins pinMode(MODEM_PWKEY, OUTPUT); pinMode(MODEM_RST, OUTPUT); pinMode(MODEM_POWER_ON, OUTPUT); digitalWrite(MODEM_PWKEY, LOW); digitalWrite(MODEM_RST, HIGH); digitalWrite(MODEM_POWER_ON, HIGH); // Set GSM module baud rate and UART pins SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX); delay(3000); // Restart SIM800 module, it takes quite some time // To skip it, call init() instead of restart() SerialMon.println("Initializing modem"); modem.init();
} void loop() { modem.sendSMS("+8801954004571", "some text"); delay(10000); }`
You probably need to check your network registration status first.
How can i send a simple SMS? And could you tell me how long does it take to send it?