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

ESP8266 NodeMCU with SIM900A GSM Module for SMS and Call Functions

View and Edit Project In Cirkit DesignerImage of ESP8266 NodeMCU with SIM900A GSM Module for SMS and Call Functions

Circuit Documentation

Summary

The circuit in question is designed to interface an ESP8266 NodeMCU microcontroller with a SIM900A GSM/GPRS module, allowing for cellular communication capabilities such as making calls, sending SMS, and receiving messages. The ESP8266 NodeMCU is powered by a 3.3V battery, while the SIM900A module is powered by a separate 5V battery. Communication between the ESP8266 and the SIM900A is established via serial communication with the appropriate TX and RX connections.

Component List

ESP8266 NodeMCU

SIM900A

5V Battery

3.3V Battery

Wiring Details

ESP8266 NodeMCU

SIM900A

5V Battery

3.3V Battery

Documented Code

#include <SoftwareSerial.h>

// Define RX and TX pins for SoftwareSerial on ESP8266
SoftwareSerial SIM900A(D2, D3);  // RX, TX

void setup()
{
  // Start communication with SIM900A at 9600 baud rate
  SIM900A.begin(9600);
  // Start Serial Monitor communication at 115200 baud rate
  Serial.begin(115200);

  Serial.println("SIM900A Module Initialized");
  delay(100);
  Serial.println("Type 'c' for calling, 's' to send SMS, or 'r' to receive messages.");
}

void loop()
{
  if (Serial.available() > 0)
  {
    switch (Serial.read())
    {
      case 'c':
        MakeCall();
        break;
      case 's':
        SendMessage();
        break;
      case 'r':
        ReceiveMessage();
        break;
    }
  }

  if (SIM900A.available() > 0)
  {
    Serial.write(SIM900A.read()); // Display data from SIM900A
  }
}

// Function to make a call
void MakeCall()
{
  Serial.println("Making a call...");
  SIM900A.println("ATD+91XXXXXXXXXX;");  // Replace with actual number, don't forget to add ';' at the end of the number
  delay(10000);  // Wait for call to proceed
  SIM900A.println("ATH");  // Hang up the call
  Serial.println("Call ended.");
}

// Function to send an SMS
void SendMessage()
{
  Serial.println("Sending Message...");

  // Set SMS text mode
  SIM900A.println("AT+CMGF=1");  
  delay(1000);

  // Set the receiver's phone number (replace with actual number)
  SIM900A.println("AT+CMGS=\"+91XXXXXXXXXX\"");  
  delay(1000);

  // Message content
  SIM900A.println("Hello, this is a message from ESP8266 and SIM900A module.");
  delay(1000);

  // End the message with a CTRL+Z character (ASCII code 26)
  SIM900A.write(26);  
  delay(1000);

  Serial.println("Message sent.");
}

// Function to receive SMS
void ReceiveMessage()
{
  Serial.println("Receiving Message...");

  // Enable SMS reception
  SIM900A.println("AT+CNMI=2,2,0,0,0");  
  delay(1000);

  // The received SMS will be automatically displayed via Serial when available
  Serial.println("Waiting for messages...");
}

This code is designed to run on the ESP8266 NodeMCU and provides basic functionality for interfacing with the SIM900A module. It includes functions for making a call, sending an SMS, and setting up the module to receive SMS messages. The code uses the SoftwareSerial library to create a serial connection on pins D2 and D3 of the ESP8266, which are connected to the SIM900A's TXD and RXD pins, respectively.