Micro-controllers, wireless transmission and database
SIM7600 comes in different version. The one I am using is SIM7600G (Global) that can work with many bands. I checked here in Australia with two different providers (Telstra and Vodafone). Both sim cards worked fine.
The pin outs are quite simple. Connect four pins VCC,GND,UART(RX) and UART(TX), it will just work. This module includes proper power regulator, so we can connect 5V to the V pin. Also the TX/RX serial communication already includes necessary 3.3V level shifter. So we can connect to 3.3V ESP or STM microcontroller directly.
AT command manual, Schematic and Datasheet can be found in the following links. https://www.adrive.com/public/bPqyGe/BK-SIM7600E-H.zip
Items can be purchased from https://www.aliexpress.com/store/605000. I bought my items from https://www.aliexpress.com/item/4000224044192.html
This project assumes you have already installed STM32CubeIDE. You need to have previously done a basic program using STM32CubeIDE. I have made a complete video from installing STM32CubeIDE to LED blink program. You can watch it by clicking this link. https://www.youtube.com/watch?v=kXg467nVd_A
Click RCC → High Speed Clock (HSE) to Crystal/Ceramic Resonator
Click Clock Configuration tab → HCLK (MHz) to 72
Click Pinout and Configuration tab
Enable USART1 asynchronous
Configuration → Parameter Settings → Basic Parameters → Baud rate 115200
Configuration → NVIC Settings → USART1 global interrupt (tick)
Set PA1 to GPIO_Output
/* USER CODE BEGIN Includes */ #include <string.h> #include <stdio.h> /* USER CODE END Includes */ /* USER CODE BEGIN PV */ #define PREF_SMS_STORAGE "\"SM\"" char ATcommand[80]; uint8_t ATisOK = 0; uint8_t slot = 0; uint8_t rx_buffer[100] = {0}; uint8_t rx_index = 0; uint8_t rx_data; /* USER CODE END PV */ /* USER CODE BEGIN 2 */ // Wait until getting response OK to AT while(!ATisOK) { sprintf(ATcommand,"AT\r\n"); HAL_UART_Transmit(&huart1,(uint8_t *)ATcommand,strlen(ATcommand),1000); HAL_UART_Receive (&huart1, rx_buffer, 100, 100); HAL_Delay(1000); if(strstr((char *)rx_buffer,"OK")) { ATisOK = 1; } HAL_Delay(1000); memset(rx_buffer,0,sizeof(rx_buffer)); } // Send AT+CMGF=1 sprintf(ATcommand,"AT+CMGF=1\r\n"); HAL_UART_Transmit(&huart1,(uint8_t *)ATcommand,strlen(ATcommand),1000); HAL_UART_Receive (&huart1, rx_buffer, 100, 100); HAL_Delay(1000); memset(rx_buffer,0,sizeof(rx_buffer)); // Send AT+CNMI=2,1 to enable notification when SMS arrives sprintf(ATcommand,"AT+CNMI=2,1\r\n"); HAL_UART_Transmit(&huart1,(uint8_t *)ATcommand,strlen(ATcommand),1000); // Enabling interrupt receive HAL_UART_Receive_IT(&huart1,&rx_data,1);// receive data (one character only) /* USER CODE END 2 *//* USER CODE BEGIN 4 */ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { if(huart->Instance==USART1) { // if the character received is other than 'enter' ascii13, save the data in buffer if(rx_data!=13) { rx_buffer[rx_index++]=rx_data; } else { // if new message arrived, read the message if( sscanf((char*)rx_buffer, "\n+CMTI: " PREF_SMS_STORAGE ",%hhd", &slot)==1) { sprintf(ATcommand,"AT+CMGR=%d\r\n",slot); HAL_UART_Transmit_IT(&huart1,(uint8_t *)ATcommand,strlen(ATcommand)); } // if message read contains "ledon", switch the LED ON else if (strstr((char *)rx_buffer,"ledon")) { HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, 1); } // if message read contains "ledoff", switch the LED OFF else if (strstr((char *)rx_buffer,"ledoff")) { HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, 0); } // This will delete all messages in the SIM card. (Is it ok for you?) if (strstr((char *)rx_buffer,"READ")) { sprintf(ATcommand,"AT+CMGD=,4\r\n"); HAL_UART_Transmit_IT(&huart1,(uint8_t *)ATcommand,strlen(ATcommand)); } rx_index=0; memset(rx_buffer,0,sizeof(rx_buffer)); } // Enabling interrupt receive again HAL_UART_Receive_IT(&huart1,&rx_data,1); // receive data (one character only) } } /* USER CODE END 4 */