Skip to content

Instantly share code, notes, and snippets.

@leighghunt
Created July 15, 2024 03:14
Show Gist options
  • Save leighghunt/016f615ba5af4816482cd7d264b68411 to your computer and use it in GitHub Desktop.
Save leighghunt/016f615ba5af4816482cd7d264b68411 to your computer and use it in GitHub Desktop.
Support/examples for accessing cellular/LTE on ESP32-S3-SIM7670G-4G
#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);
}
}
@leighghunt
Copy link
Author

Hello! Is this a working code? I'm working on that same model but I'm using LILYGO ESP32 S3 SIM7670G.

Hi Makuu6, I can't recall where I got to with this, but I did have some problems accessing HTTPS traffic from a Waveshare ESP32-S3-SIM7670G-4G, and I think I ran out of time to get it working reliably.

Some more info here: https://www.reddit.com/r/esp32/comments/1dxugaq/anyone_managed_to_get_cellular_working_o, including someone saying they got a LilyGo to work.

I've not done any more on the ESP32 side of my project (https://github.com/venari/timelapse) in the last 12 months, but might be doing again in the coming months.

Feel free to look at the code at https://github.com/venari/timelapse/tree/feature/esp32-continued/esp32/take_photos if it's any help.

@Makuu6
Copy link

Makuu6 commented Mar 11, 2025

Ohh thanks boss I'll try to check it out.. I'll let you know after!

@Makuu6
Copy link

Makuu6 commented Mar 11, 2025

But have you successfully execute sms in your waveshare module?

@leighghunt
Copy link
Author

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.

@Makuu6
Copy link

Makuu6 commented Mar 11, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment