Hello

Welcome lekule blog

Hi, I`m Sostenes, Electrical Technician and PLC`S Programmer.
Everyday I`m exploring the world of Electrical to find better solution for Automation.
together in the world. #lekule86
Join us on

How to: Send an SMS with PIC16F628A and SIM900A

In this article I'll show you one way of sending an SMS using a PIC 16F628A and a SIMCOM SIM900A module.
In a previous article, I did a firmware upgrade on my GSM module, so it would get registered to a European service provider. In that article, I briefly scratched the surface on AT commands and instructions.
In this article, I'll take it one step further. I'll send an SMS with my PIC 16F628A.


Complete breadboard.

Requirements

To get the most out of this article, you'll need the following:
  • SIMCOM SIM900A module, upgraded to be able to get registered to a European service provider.
  • A computer running MPLAB X, and the XC8 compiler.
  • A PIC 16F628A and an MAX232.
  • A way to program your PIC, I'm using a PICkit 3.
  • Breadboard, jumperwires, and an LCD.
  • Parts from the parts list.

Introduction

When the SIM900A module is powered up, a lot of things are going on. One of them are that the module is trying to get registered to a network. When it is successfully registered to a network, we can send SMS, receive SMS and get the service providers name. The main goal for this article is to send an SMS to a predefined number. To get the service providers name is a bonus.
The module communicates with the surrounding circuitry with TTL or with the onboard MAX232 IC. I'll be using the MAX232 interface. This means that all communication is done with the PICs UART, and all our commands from the PIC will be sent to the UART port with printf.

Hardware

I've connected my breadboard like this:

Click on image for full size resolution.

Since I'm using an MAX232, I can use that to see and troubleshoot what the microcontroller is sending to the GSM module. To do this, I disconnect the GSM module, and connect my serial cable, and open up GtkTerm. Baud setting: 9600-8-N-1.


Connection to a computer to troubleshoot.

This is what the microcontroller is sending to the GSM module. The first three lines are only to verify that serial communication is working and to see what I'm sending. The last two lines are instructions to the GSM module.


I'm not getting a reply from the GSM module since it's not connected.

Partlist

This is a screenshot of the bom.ulp from EagleCAD.


Software

Although the software is commented, I'll go through some parts of it here. When the PIC is powered up, a short welcome message is displayed. Then a 15-second countdown starts. I've put in this countdown, for two reasons:
  1. Allow the GSM module to get registered.
  2. A visual display which shows the user that something is happening and the PIC is working.
When the countdown is finished, the PIC sends the command:
AT+CPOL?\r\n
It is important to add Carriage return – New line, the \r\n. This tells the module to execute the text string that has arrived in the modules buffer.
The module then returns the string:
+CPOL: 1,0,” N NetCom”,1,0,1
This means that the module is registered to NetCom. NetCom is the service provider's name. It's this name we want to display on the LCD. Now we need to extract the name from the string. The way I do that, is to read the whole string into an array. Then I'll search for the “-signs". When the “-signs" are found, I store their position in another array. This is what I call "start and stop". Then I use the values from "start and stop" to display the characters in between on the LCD. Perhaps not the fanciest way of doing it, but it is simple.



To send the SMS I have to send some more AT commands.
First, I send the command:
AT+CMGF=1\r\n
This is the Select SMS Message format. The 1 tells the module to go into text mode.
Second, I send the command:
AT+CMGS=”receiver”\r\n
“receiver” is the number I want to send a message to.
Third, I send the command:
Message from PIC16F628A\r\n
This is the actual message. Since the message has multiple characters, including spaces, there's a nifty way to tell the module where the end of the message is. I have to send the EOF sign, which happens to be CTRL-Z.
printf(“%c”,26);
This is the EOF character in the regular ASCII table. The module will now send the message.
Use this link to find documents regarding the SIM900A module.

Download

You can download the c-source code from the link.

 

Conclusion

You should now be able to get your service providers name, and send an SMS with the SIM900A module, on a European network.

Pictures and video









Share this:

ABOUTME

Hi all. This is deepak from Bthemez. We're providing content for Bold site and we’ve been in internet, social media and affiliate for too long time and its my profession. We are web designer & developer living India! What can I say, we are the best..

Post a Comment
My photo

Hi, I`m Sostenes, Electrical Technician and PLC`S Programmer.
Everyday I`m exploring the world of Electrical to find better solution for Automation. I believe everyday can become a Electrician with the right learning materials.
My goal with BLOG is to help you learn Electrical.

Labels

LEKULE TV EDITORIALS ARTICLES DC ROBOTICS DIGITAL SEMICONDUCTORS GENERATOR AC EXPERIMENTS MANUFACTURING-ENGINEERING REFERENCE FUNDAMENTAL OF ELECTRICITY ELECTRONICS ELECTRICAL ENGINEER MEASUREMENT TRANSDUCER & SENSOR VIDEO ARDUINO RENEWABLE ENERGY AUTOMOBILE TEARDOWN SYNCHRONOUS GENERATOR DIGITAL ELECTRONICS ELECTRICAL DISTRIBUTION CABLES AUTOMOTIVE MICROCONTROLLER SOLAR PROTECTION DIODE AND CIRCUITS BASIC ELECTRICAL ELECTRONICS MOTOR SWITCHES CIRCUIT BREAKERS CIRCUITS THEORY PANEL BUILDING ELECTRONICS DEVICES MIRACLES SWITCHGEAR ANALOG MOBILE DEVICES WEARABLES CAMERA TECHNOLOGY COMMUNICATION GENERATION BATTERIES FREE CIRCUITS INDUSTRIAL AUTOMATION SPECIAL MACHINES ELECTRICAL SAFETY ENERGY EFFIDIENCY-BUILDING DRONE CONTROL SYSTEM NUCLEAR ENERGY SMATRPHONE FILTER`S POWER BIOGAS BELT CONVEYOR MATERIAL HANDLING RELAY ELECTRICAL INSTRUMENTS ENERGY SOURCE PLC`S TRANSFORMER AC CIRCUITS CIRCUIT SCHEMATIC SYMBOLS DDISCRETE SEMICONDUCTOR CIRCUITS WIND POWER C.B DEVICES DC CIRCUITS DIODES AND RECTIFIERS FUSE SPECIAL TRANSFORMER THERMAL POWER PLANT CELL CHEMISTRY EARTHING SYSTEM ELECTRIC LAMP FUNDAMENTAL OF ELECTRICITY 2 BIPOLAR JUNCTION TRANSISTOR 555 TIMER CIRCUITS AUTOCAD BLUETOOTH C PROGRAMMING HOME AUTOMATION HYDRO POWER LOGIC GATES OPERATIONAL AMPLIFIER`S SOLID-STATE DEVICE THEORRY COMPUTER DEFECE & MILITARY FLUORESCENT LAMP INDUSTRIAL ROBOTICS ANDROID ELECTRICAL DRIVES GROUNDING SYSTEM CALCULUS REFERENCE DC METERING CIRCUITS DC NETWORK ANALYSIS ELECTRICAL SAFETY TIPS ELECTRICIAN SCHOOL ELECTRON TUBES FUNDAMENTAL OF ELECTRICITY 1 INDUCTION MACHINES INSULATIONS USB ALGEBRA REFERENCE HMI[Human Interface Machines] INDUCTION MOTOR KARNAUGH MAPPING USEUL EQUIATIONS AND CONVERSION FACTOR ANALOG INTEGRATED CIRCUITS BASIC CONCEPTS AND TEST EQUIPMENTS DIGITAL COMMUNICATION DIGITAL-ANALOG CONVERSION ELECTRICAL SOFTWARE GAS TURBINE ILLUMINATION OHM`S LAW POWER ELECTRONICS THYRISTOR BOOLEAN ALGEBRA DIGITAL INTEGRATED CIRCUITS FUNDAMENTAL OF ELECTRICITY 3 PHYSICS OF CONDUCTORS AND INSULATORS SPECIAL MOTOR STEAM POWER PLANTS TESTING TRANSMISION LINE C-BISCUIT CAPACITORS COMBINATION LOGIC FUNCTION COMPLEX NUMBERS CONTROL MOTION ELECTRICAL LAWS INVERTER LADDER DIAGRAM MULTIVIBRATORS RC AND L/R TIME CONSTANTS SCADA SERIES AND PARALLEL CIRCUITS USING THE SPICE CIRCUIT SIMULATION PROGRAM AMPLIFIERS AND ACTIVE DEVICES APPS & SOFTWARE BASIC CONCEPTS OF ELECTRICITY CONDUCTOR AND INSULATORS TABLES CONDUITS FITTING AND SUPPORTS ELECTRICAL INSTRUMENTATION SIGNALS ELECTRICAL TOOLS INDUCTORS LiDAR MAGNETISM AND ELECTROMAGNETISM PLYPHASE AC CIRCUITS RECLOSER SAFE LIVING WITH GAS AND LPG SAFETY CLOTHING STEPPER MOTOR SYNCHRONOUS MOTOR AC METRING CIRCUITS BECOME AN ELECTRICIAN BINARY ARITHMETIC BUSHING DIGITAL STORAGE MEMROY ELECTRICIAN JOBS HEAT ENGINES HOME THEATER INPECTIONS LIGHT SABER MOSFET NUMERATION SYSTEM POWER FACTORS REACTANCE AND IMPEDANCE INDUCTIVE RECTIFIER AND CONVERTERS RESONANCE SCIENTIFIC NOTATION AND METRIC PREFIXES SULFURIC ACID TROUBLESHOOTING TROUBLESHOOTING-THEORY & PRACTICE 12C BUS APPLE BATTERIES AND POWER SYSTEMS DC MOTOR DRIVES ELECTROMECHANICAL RELAYS ENERGY EFFICIENCY-LIGHT INDUSTRIAL SAFETY EQUIPMENTS MEGGER MXED-FREQUENCY AC SIGNALS PRINCIPLE OF DIGITAL COMPUTING QUESTIONS REACTANCE AND IMPEDANCE-CAPATIVE SEQUENTIAL CIRCUITS SERRIES-PARALLEL COMBINATION CIRCUITS SHIFT REGISTERS WIRELESS BUILDING SERVICES COMPRESSOR CRANES DIVIDER CIRCUIT AND KIRCHHOFF`S LAW ELECTRICAL DISTRIBUTION EQUIPMENTS 1 ELECTRICAL DISTRIBUTION EQUIPMENTS B ELECTRICAL TOOL KIT ELECTRICIAN JOB DESCRIPTION INDUSTRIAL DRIVES LAPTOP SCIENCE THERMOCOUPLE TRIGONOMENTRY REFERENCE UART oscilloscope BIOMASS CONTACTOR ELECTRIC ILLUMINATION ELECTRICAL SAFETY TRAINING ELECTROMECHANICAL FEATURED FILTER DESIGN HARDWARE JUNCTION FIELD-EFFECT TRANSISTORS NASA NUCLEAR POWER VALVE COLOR CODES ELECTRIC TRACTION FLEXIBLE ELECTRONICS FLUKE GEARMOTORS INTRODUCTION LASSER PID PUMP SEAL ELECTRICIAN CAREER ELECTRICITY SUPPLY AND DISTRIBUTION MUSIC NEUTRAL PERIODIC TABLES OF THE ELEMENTS POLYPHASE AC CIRCUITS PROJECTS REATORS SATELLITE STAR DELTA VIBRATION WATERPROOF