Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- In this example, I'll provide you with an Arduino code to test the all-round functionality of the SIM7020E module by sending various AT commands and receiving responses. The code will cover basic operations such as checking the module status, registering to the network, getting network information, and sending a UDP packet. Note that this code assumes you are using an Arduino Uno or a similar board.
- First, connect the SIM7020E module to the Arduino as follows:
- Vcc to 5V
- GND to GND
- RX (SIM7020E) to TX (Arduino)
- TX (SIM7020E) to RX (Arduino)
- Upload this code to your Arduino and open the Serial Monitor. The Arduino will send various AT commands to the SIM7020E module and display the received responses in the Serial Monitor. This will help you to test the all-round functionality of the SIM7020E module.
- Make sure you have a proper power supply for the SIM7020E module, as it may draw a high current during operation. Also, ensure you have an NB-IoT SIM card inserted into the module and that it is registered with the network.
- Please note that the "IP" and "PORT" placeholders in the "AT+CSOSEND" command should be replaced with the actual IP address and port number of the destination server you want to send the UDP packet to.
- */
- // SIM7020E GSM Module
- // Example code for Arduino
- #include <SoftwareSerial.h>
- const int simRxPin = 10; // Connect the RX pin of the SIM7020E to Digital Pin 10
- const int simTxPin = 11; // Connect the TX pin of the SIM7020E to Digital Pin 11
- SoftwareSerial simSerial(simRxPin, simTxPin); // Create a SoftwareSerial object for communication with the SIM7020E
- void setup() {
- Serial.begin(9600); // Initialize the serial communication for debugging
- simSerial.begin(9600); // Initialize the software serial communication with the SIM7020E
- delay(5000); // Wait for the SIM7020E to power on and initialize
- Serial.println("SIM7020E Test");
- }
- void loop() {
- // Test AT command
- sendATCommand("AT");
- // Check SIM card status
- sendATCommand("AT+CPIN?");
- // Query network registration status
- sendATCommand("AT+CEREG?");
- // Get network information
- sendATCommand("AT+CGPADDR");
- // Set UDP parameters
- sendATCommand("AT+CSOSEND=0,\"IP\",\"PORT\",\"Hello World!\"");
- delay(10000); // Wait for 10 seconds before running the test again
- }
- void sendATCommand(const char *command) {
- // Send an AT command to the SIM7020E
- simSerial.println(command);
- // Wait for a response from the SIM7020E
- while (!simSerial.available()) {
- delay(100);
- }
- // Read the response from the SIM7020E
- String response = simSerial.readStringUntil('\n');
- // Print the command and response to the Serial Monitor
- Serial.print("Command: ");
- Serial.println(command);
- Serial.print("Response: ");
- Serial.println(response);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement