-
-
Save leighghunt/016f615ba5af4816482cd7d264b68411 to your computer and use it in GitHub Desktop.
#include <Arduino.h> | |
static const int RXPin = 17, TXPin = 18; | |
static const uint32_t GPSBaud = 115200; | |
String rev; | |
void SentSerial(const char *p_char) { | |
for (int i = 0; i < strlen(p_char); i++) { | |
Serial1.write(p_char[i]); | |
delay(10); | |
} | |
Serial1.write('\r'); | |
delay(10); | |
Serial1.write('\n'); | |
delay(10); | |
} | |
bool SentMessage(const char *p_char, unsigned long timeout = 2000) { | |
SentSerial(p_char); | |
unsigned long start = millis(); | |
while (millis() - start < timeout) { | |
if (Serial1.available()) { | |
rev = Serial1.readString(); | |
if (rev.indexOf("OK") != -1) { | |
Serial.println("Got OK!"); | |
return true; | |
} | |
} | |
} | |
Serial.println("Timeout!"); | |
return false; | |
} | |
void setup() { | |
Serial.begin(115200); | |
Serial1.begin(GPSBaud, SERIAL_8N1, RXPin, TXPin); | |
while (!SentMessage("AT", 2000)) { | |
delay(1000); | |
} | |
SentMessage("ATD10086;", 2000); | |
SentSerial("ATE1;"); | |
SentSerial("AT+COPS?"); | |
SentSerial("AT+CGDCONT?"); | |
SentSerial("AT+SIMCOMATI"); | |
} | |
void loop() { | |
if (Serial1.available()) { | |
rev = Serial1.readString(); | |
Serial.println(rev); | |
} | |
} |
But have you successfully execute sms in your waveshare module?
But have you successfully execute sms in your waveshare module?
From memory this was for sending messages (i.e. AT Commands) over serial to the AT chip (whilst I was trying to establish network access) - not sending text messages over SMS. The example function names can be slightly misleading.
Some examples out there that might help:
Using TinyGSM library to send SMS (don't think it supports receiving SMS): https://github.com/search?q=repo%3Avshymanskyy%2FTinyGSM+sendsms&type=issues
This might also be helpful: https://github.com/vshymanskyy/TinyGSM/blob/master/examples/AllFunctions/AllFunctions.ino
If instead of using a library, you want to use AT commands directly, the AT Command Manual (e.g. https://files.waveshare.com/wiki/ESP32-S3-SIM7670G-4G/SIM767XX_Series_AT_Command_Manual_V1.01.pdf) might be helpful.
I think the command you're after is AT+CMGS
, but they're a pain to work with.
Ohh thanks boss I'll try to check it out.. I'll let you know after!