Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Nano and SIM800L Based Battery-Powered GSM Communication System with Keypad Input

View and Edit Project In Cirkit DesignerImage of Arduino Nano and SIM800L Based Battery-Powered GSM Communication System with Keypad Input

Circuit Documentation

Summary

This circuit is designed to interface an Arduino Nano with a SIM800L GSM module, a 4x4 Keypad, a condenser microphone, and a loudspeaker. The circuit allows for sending and receiving SMS, making and receiving calls, and interacting with the user through the keypad. The Arduino Nano serves as the main controller, handling communication with the SIM800L and processing user inputs from the keypad.

Component List

  1. Arduino Nano

    • Description: A small, complete, and breadboard-friendly board based on the ATmega328P.
    • Pins: D1/TX, D0/RX, RESET, GND, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11/MOSI, D12/MISO, VIN, 5V, A7, A6, A5, A4, A3, A2, A1, A0, AREF, 3V3, D13/SCK
  2. 18650 Li-Ion Battery

    • Description: A rechargeable lithium-ion battery commonly used in portable electronics.
    • Pins: Positive, Negative
  3. Rocker Switch

    • Description: A switch that can be toggled between an on and off state.
    • Pins: 1, 2
  4. Condenser Microphone

    • Description: A type of microphone that uses a capacitor to convert sound into an electrical signal.
    • Pins: pin1, pin2
  5. Loudspeaker

    • Description: A device that converts electrical signals into sound.
    • Pins: pin1, pin2
  6. 4x4 Keypad (Simulator)

    • Description: A matrix keypad with 4 rows and 4 columns, used for user input.
    • Pins: R1, C4, R2, C2, R3, R4, C1, C3
  7. SIM800L

    • Description: A GSM/GPRS module that allows for communication over cellular networks.
    • Pins: NET, VCC, RST, RXD, TXD, GND, RING, DTR, MIC+, MIC-, SPK+, SPK-

Wiring Details

Arduino Nano

18650 Li-Ion Battery

Rocker Switch

Condenser Microphone

Loudspeaker

4x4 Keypad (Simulator)

SIM800L

Code Documentation

#include <SoftwareSerial.h>
#include <Keypad.h>

SoftwareSerial mySerial(3, 2); // RX (to TX of SIM800L), TX (to RX of SIM800L)

const byte ROWS = 4; // 4 rows
const byte COLS = 4; // 4 columns
char keys[ROWS][COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {11, 10, 9, 8}; // Connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5, 4}; // Connect to the column pinouts of the keypad

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
char phoneNumber[15]; // Buffer to store phone number (max 14 digits + null terminator)
char message[160];    // Buffer to store SMS message (max 159 characters + null terminator)

void setup() {
  mySerial.begin(9600); // Baud rate for SIM800L
  Serial.begin(9600);   // Baud rate for Serial Monitor
  delay(1000);

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

  if (initializeGSM()) {
    Serial.println("GSM Module initialized successfully!");
    Serial.println("Press 'A' to send an SMS.");
    Serial.println("Press 'C' to make a call.");
    Serial.println("Press 'D' to cut a call or use as a backspace during input.");
    Serial.println("Press 'B' to answer an incoming call.");
    Serial.println("Press '*' to delete all messages.");
  } else {
    Serial.println("GSM Module initialization failed. Check connections and power.");
  }
}

void loop() {
  char key = keypad.getKey(); // Get key input from the keypad
  if (key != NO_KEY) {
    if (key == 'A') { // Send SMS
      Serial.println("Enter phone number and press '#': ");
      getInput(phoneNumber, 15); // Get phone number
      Serial.println("\nEnter message and press '#': ");
      getInput(message, 160); // Get SMS message
      sendSMS(phoneNumber, message);
    } else if (key == 'C') { // Make Call
      Serial.println("Enter phone number and press '#': ");
      getInput(phoneNumber, 15); // Get phone number
      makeCall(phoneNumber);
    } else if (key == 'D') { // Cut Call
      cutCall();
    } else if (key == 'B') { // Answer Call
      answerCall();
    } else if (key == '*') { // Delete all messages
      deleteAllMessages();
    }
  }

  // Check for incoming messages or calls from SIM800L
  if (mySerial.available()) {
    String response = mySerial.readString();

    // Detect incoming call
    if (response.indexOf("RING") != -1) {
      Serial.println("Incoming call detected!");
      displayIncomingNumber();
    }

    // Detect incoming SMS
    if (response.indexOf("+CMTI:") != -1) {
      Serial.println("Message received. Retrieving content...");
      int index = response.indexOf(",") + 1;
      int endIndex = response.indexOf("\r\n", index);
      String messageIndex = response.substring(index, endIndex);
      readMessage(messageIndex.toInt());
    }

    // Print any other responses
    Serial.print(response);
  }
}

// Function to initialize the GSM module
bool initializeGSM() {
  mySerial.println("AT"); // Check