0% found this document useful (0 votes)
26 views2 pages

GSM 2

This are codes on the operation of GSM using arduino
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

GSM 2

This are codes on the operation of GSM using arduino
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <SoftwareSerial.

h>

// Define RX and TX pins for SIM800L

#define SIM800_RX 10 // Connect to SIM800L TX

#define SIM800_TX 11 // Connect to SIM800L RX

// Create a SoftwareSerial instance

SoftwareSerial sim800(SIM800_RX, SIM800_TX);

void setup() {

// Start hardware serial communication for debugging

Serial.begin(9600);

while (!Serial) {

// Wait for serial to initialize

Serial.println("Initializing SIM800L Serial Communication...");

// Start SIM800L serial communication

sim800.begin(9600); // Default baud rate of SIM800L

delay(1000);

// Test AT command

sendATCommand("AT");

void loop() {

// Forward data from SIM800L to Serial Monitor

if (sim800.available()) {

String response = sim800.readString();

Serial.println("SIM800L: " + response);

}
// Forward data from Serial Monitor to SIM800L

if (Serial.available()) {

String command = Serial.readString();

sim800.println(command);

Serial.println("Sent to SIM800L: " + command);

// Function to send an AT command and check response

void sendATCommand(const char* command) {

Serial.println("Sending AT command: " + String(command));

sim800.println(command);

delay(1000);

while (sim800.available()) {

String response = sim800.readString();

Serial.println("Response: " + response);

You might also like