Hi there
I have this simple code:
#include<Sim800l.h>
Sim800l Sim800l;
int t;
void setup() {
t=95;
Sim800l.begin();
Sim800l.sendSms("+1xxxxxx",t);
}
void loop() {
}
but my phone does not receive "95" ! but it receives some characters like "@"
please help me how to use a variable instead of the text of an sms in sendSms function!
J-M-L
May 24, 2022, 12:11pm
3
amirelahi1010:
Sim800l.h
won't work either
the library's API is (if working with GitHub - vittorioexp/Sim800L-Arduino-Library-revised: The SIM800L Arduino Library is a simple and easy-to-use library for the SIM800L module, allowing for quick and efficient communication with the module using the Arduino platform. )
bool Sim800L::sendSms(char* number,char* text)
so you need to pass a cString (null terminated char buffer)
either
#include<Sim800l.h>
Sim800l Sim800l;
char message[] = "42";
void setup() {
t=95;
Sim800l.begin();
Sim800l.sendSms("+1xxxxxx", message);
}
void loop() {
}
or if you want to use the String class
#include<Sim800l.h>
Sim800l Sim800l;
String message = "42";
void setup() {
Sim800l.begin();
Sim800l.sendSms("+1xxxxxx", message.c_str()); // you might get a warning or error depending on the board you use as this is a const char* and the API expects char*
}
void loop() {
}
system
Closed
November 20, 2022, 12:12pm
4
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.