Anyone can use this driver for cellular & LTE communication for IoT based project
This library provides functions for interfacing an STM32 microcontroller with the Quectel EG21 modem via AT commands over UART. It includes functionalities for checking network registration, configuring MQTT, managing GPS, and controlling power modes.
- Send AT commands and receive responses
- Check modem connectivity
- Manage MQTT connections (publish/subscribe)
- Configure GPS
- Network registration status
- Power management for the modem
- STM32 microcontroller (tested with STM32G0 series)
- Quectel EG21 modem
- UART communication enabled (UART1 for modem, UART2 for debugging)
- STM32 HAL library
uint8_t checkAT(); // Check if the modem responds to AT commands
uint8_t Check_OkResponse(); // Verify if the response contains "OK"
void SIMTransmit(char *cmd, uint16_t timeout); // Send AT command and receive responseuint8_t check_IM(); // Check IMEI
uint8_t changeIMEI(char * NewIMEI); // Change IMEI
uint16_t checkRSSI(); // Get signal strengthuint8_t configMQTT(); // Configure MQTT keep-alive time
uint8_t OpenMQTTclient(char *Host, int Port); // Connect to an MQTT broker
uint8_t ConnectMQTTServer(char *cid, char *Username, char *Password); // Authenticate MQTT connection
uint8_t checkMQTTserver(); // Verify MQTT server connection
uint8_t publishtopicMQTT(char *Topic, char *data); // Publish a message to an MQTT topic
uint8_t subtopic(char *topic, uint8_t QoS); // Subscribe to an MQTT topic
uint8_t MQTTdiconnectserver(); // Disconnect from the MQTT serveruint8_t GPSHOTstart(); // Start GPS
uint8_t GPSstop(); // Stop GPS
char* GPSINFO(); // Retrieve GPS informationuint8_t Network_Reg(); // Check network registration status
uint8_t Resetmodem(); // Reset the Quectel modem
uint8_t SetFULLFun(); // Set modem to full functionality
uint8_t SetMinFun(); // Set modem to minimum functionality
uint8_t Quectel_Power_down(); // Power down the modem
uint8_t Sleep_Quectel(); // Put the modem into sleep mode
uint8_t Config_ApReady(); // Configure AP_READY
uint8_t Config_URC(); // Configure URC settings- Initialize UART1 and UART2 in STM32CubeIDE or your preferred IDE.
- Use
checkAT();to verify modem communication. - Configure MQTT or GPS as needed.
- Use
SIMTransmit();to send custom AT commands.
- Ensure UART1 and UART2 are correctly initialized.
- Modify buffer sizes if needed for longer responses.
- Customize MQTT topics and credentials according to your broker settings.
This project is open-source and free to use.