microrobotics icon

800C GSM Module 3.3/5V - Compatible

microrobotics | PRO | 08/28/23 08:44:21 AM UTC | 0 ⭐ | 5280 👁️ | Never ⏰ | []
Arduino |

2.38 KB

|

None

|

0 👍

/

0 👎

/*
Interfacing the ESP32 with the SIM800C GSM module allows you to communicate over a cellular network. The SIM800C module can be used for sending SMS, making calls, or connecting to the internet. In this sample, I'll demonstrate a simple application that sends an SMS message.
 
Components:
ESP32 development board
SIM800C GSM module
SIM card with active cellular service
Connections:
Connect the VCC of the SIM800C to a 4.2V power supply (or as recommended by the module you have). Make sure the power supply can provide around 2A current, especially during transmission.
Connect GND of the SIM800C to the GND of the ESP32.
Connect the TX pin of the SIM800C to the RX pin (e.g., GPIO 16) of the ESP32.
Connect the RX pin of the SIM800C to the TX pin (e.g., GPIO 17) of the ESP32.
 
Software:
Install the required library for handling AT commands:
TinyGSM: https://github.com/vshymanskyy/TinyGSM
 
Make sure to:
 
Replace the phone_number with the recipient's phone number.
Adjust the sms_text to your desired message.
If your SIM card has a PIN, use modem.simUnlock("yourPIN"); to unlock it.
This is a basic example. The SIM800C module supports a wide range of functionalities that can be leveraged using AT commands and the TinyGSM library. Make sure to refer to the documentation for more advanced use cases.
*/
 
#include <TinyGsmClient.h>
#include <HardwareSerial.h>
 
#define MODEM_RX     16
#define MODEM_TX     17
 
// Create an instance of the TinyGSM object
TinyGsm modem(Serial2);
 
// Phone number and SMS text
const char phone_number[] = "+1234567890";  // Replace with your phone number
const char sms_text[] = "Hello from ESP32 and SIM800C!";
 
void setup() {
  Serial.begin(115200);
  delay(10);
 
  // Start communication with the GSM module
  Serial2.begin(9600, SERIAL_8N1, MODEM_RX, MODEM_TX);
  delay(3000);
 
  Serial.println("Initializing modem...");
  modem.restart();
 
  String modemInfo = modem.getModemInfo();
  Serial.println("Modem Info: " + modemInfo);
 
  // Unlock your SIM card with a PIN if needed
  // modem.simUnlock("yourPIN");
 
  sendSMS();
}
 
void sendSMS() {
  Serial.println("Sending SMS...");
 
  // Send the SMS
  bool res = modem.sendSMS(phone_number, sms_text);
 
  if (res) {
    Serial.println("SMS sent successfully!");
  } else {
    Serial.println("Failed to send SMS.");
  }
}
 
void loop() {
  // Nothing to do here
}
 
 

Comments