/********* Pleasedontcode.com **********
Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- Terms and Conditions:
You have a non-exclusive, revocable, worldwide, royalty-free license
for personal and commercial use. Attribution is optional; modifications
are allowed, but you're responsible for code maintenance. We're not
liable for any loss or damage. For full terms,
please visit pleasedontcode.com/termsandconditions.
- Project: GSM Setup
- Source Code NOT compiled for: ESP32 DevKit V1
- Source Code created on: 2024-08-27 02:07:27
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* The system shall utilize the SIM800L module for */
/* GSM communication, ensuring reliable data */
/* transmission and reception through SoftwareSerial */
/* on specified TX/RX pins. */
/****** END SYSTEM REQUIREMENTS *****/
/****** DEFINITION OF LIBRARIES *****/
#include //https://github.com/plerup/espsoftwareserial
#include //https://github.com/vittorioexp/Sim800L-Arduino-Library-revised
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t GSM1_SIM800L_RING_PIN_D16 = 16;
/***** DEFINITION OF DIGITAL OUTPUT PINS *****/
const uint8_t GSM1_SIM800L_RST_PIN_D14 = 14;
const uint8_t GSM1_SIM800L_DTR_PIN_D17 = 17;
/***** DEFINITION OF Software Serial *****/
const uint8_t GSM1_SIM800L_Serial_PIN_SERIAL_TX_D4 = 4;
const uint8_t GSM1_SIM800L_Serial_PIN_SERIAL_RX_D13 = 13;
EspSoftwareSerial::UART GSM1_SIM800L_Serial;
/***** DEFINITION OF OUTPUT RAW VARIABLES *****/
/***** used to store raw data *****/
bool GSM1_SIM800L_RST_PIN_D14_rawData = 0;
bool GSM1_SIM800L_DTR_PIN_D17_rawData = 0;
/***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
/***** used to store data after characteristic curve transformation *****/
float GSM1_SIM800L_RST_PIN_D14_phyData = 0.0;
float GSM1_SIM800L_DTR_PIN_D17_phyData = 0.0;
/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
// Initialize the Sim800L object with RX, TX, and RST pins
Sim800L GSM1_SIM800L(GSM1_SIM800L_Serial_PIN_SERIAL_RX_D13, GSM1_SIM800L_Serial_PIN_SERIAL_TX_D4, GSM1_SIM800L_RST_PIN_D14);
void setup(void)
{
// Set the ring pin as input with pull-up
pinMode(GSM1_SIM800L_RING_PIN_D16, INPUT_PULLUP);
// Set the RST pin as output
pinMode(GSM1_SIM800L_RST_PIN_D14, OUTPUT);
// Set the DTR pin as output
pinMode(GSM1_SIM800L_DTR_PIN_D17, OUTPUT);
// Start the software serial communication
GSM1_SIM800L_Serial.begin(9600, SWSERIAL_8N1, GSM1_SIM800L_Serial_PIN_SERIAL_RX_D13, GSM1_SIM800L_Serial_PIN_SERIAL_TX_D4, false);
// Initialize the GSM module with the default baud rate
GSM1_SIM800L.begin(9600);
}
void loop(void)
{
// Refresh output data
updateOutputs();
// Example: Sending an SMS (you can modify the number and text)
char* text = "Testing SMS"; // Message to be sent
char* number = "+1234567890"; // Replace with the actual number
bool error = GSM1_SIM800L.sendSms(number, text); // Send SMS
}
void updateOutputs()
{
// Update the state of the output pins based on raw data
digitalWrite(GSM1_SIM800L_RST_PIN_D14, GSM1_SIM800L_RST_PIN_D14_rawData);
digitalWrite(GSM1_SIM800L_DTR_PIN_D17, GSM1_SIM800L_DTR_PIN_D17_rawData);
}
/* END CODE */