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









Previous
Next Post »
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.
Related Posts Plugin for WordPress, Blogger...

Label

KITAIFA NEWS KIMATAIFA MICHEZO BURUDANI SIASA TECHNICAL ARTICLES f HAPA KAZI TU. LEKULE TV EDITORIALS ARTICLES DC DIGITAL ROBOTICS SEMICONDUCTORS MAKALA GENERATOR GALLERY AC EXPERIMENTS MANUFACTURING-ENGINEERING MAGAZETI REFERENCE IOT FUNDAMENTAL OF ELECTRICITY ELECTRONICS ELECTRICAL ENGINEER MEASUREMENT VIDEO ZANZIBAR YETU TRANSDUCER & SENSOR MITINDO ARDUINO RENEWABLE ENERGY AUTOMOBILE SYNCHRONOUS GENERATOR ELECTRICAL DISTRIBUTION CABLES DIGITAL ELECTRONICS AUTOMOTIVE PROTECTION SOLAR TEARDOWN DIODE AND CIRCUITS BASIC ELECTRICAL ELECTRONICS MOTOR SWITCHES CIRCUIT BREAKERS MICROCONTROLLER CIRCUITS THEORY PANEL BUILDING ELECTRONICS DEVICES MIRACLES SWITCHGEAR ANALOG MOBILE DEVICES CAMERA TECHNOLOGY GENERATION WEARABLES BATTERIES COMMUNICATION FREE CIRCUITS INDUSTRIAL AUTOMATION SPECIAL MACHINES ELECTRICAL SAFETY ENERGY EFFIDIENCY-BUILDING DRONE NUCLEAR ENERGY CONTROL SYSTEM FILTER`S SMATRPHONE BIOGAS POWER TANZIA BELT CONVEYOR MATERIAL HANDLING RELAY ELECTRICAL INSTRUMENTS 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 cartoon CELL CHEMISTRY EARTHING SYSTEM ELECTRIC LAMP ENERGY SOURCE FUNDAMENTAL OF ELECTRICITY 2 BIPOLAR JUNCTION TRANSISTOR 555 TIMER CIRCUITS AUTOCAD C PROGRAMMING HYDRO POWER LOGIC GATES OPERATIONAL AMPLIFIER`S SOLID-STATE DEVICE THEORRY DEFECE & MILITARY FLUORESCENT LAMP HOME AUTOMATION INDUSTRIAL ROBOTICS ANDROID COMPUTER ELECTRICAL DRIVES GROUNDING SYSTEM BLUETOOTH CALCULUS REFERENCE DC METERING CIRCUITS DC NETWORK ANALYSIS ELECTRICAL SAFETY TIPS ELECTRICIAN SCHOOL ELECTRON TUBES FUNDAMENTAL OF ELECTRICITY 1 INDUCTION MACHINES INSULATIONS 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 USB AUDIO 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 ELECTRICAL LAWS HMI[HUMANI INTERFACE MACHINES 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 BASIC CONCEPTS OF ELECTRICITY CONDUCTOR AND INSULATORS TABLES CONDUITS FITTING AND SUPPORTS CONTROL MOTION 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 APPS & SOFTWARE BASIC AC THEORY 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 RESONANCE SCIENTIFIC NOTATION AND METRIC PREFIXES SULFURIC ACID TROUBLESHOOTING TROUBLESHOOTING-THEORY & PRACTICE 12C BUS APPLE BATTERIES AND POWER SYSTEMS ELECTROMECHANICAL RELAYS ENERGY EFFICIENCY-LIGHT INDUSTRIAL SAFETY EQUIPMENTS MEGGER MXED-FREQUENCY AC SIGNALS PRINCIPLE OF DIGITAL COMPUTING QUESTIONS REACTANCE AND IMPEDANCE-CAPATIVE RECTIFIER AND CONVERTERS SEQUENTIAL CIRCUITS SERRIES-PARALLEL COMBINATION CIRCUITS SHIFT REGISTERS BUILDING SERVICES COMPRESSOR CRANES DC MOTOR DRIVES DIVIDER CIRCUIT AND KIRCHHOFF`S LAW ELECTRICAL DISTRIBUTION EQUIPMENTS 1 ELECTRICAL DISTRIBUTION EQUIPMENTS B ELECTRICAL TOOL KIT ELECTRICIAN JOB DESCRIPTION LAPTOP THERMOCOUPLE TRIGONOMENTRY REFERENCE UART WIRELESS BIOMASS CONTACTOR ELECTRIC ILLUMINATION ELECTRICAL SAFETY TRAINING FILTER DESIGN HARDWARE INDUSTRIAL DRIVES JUNCTION FIELD-EFFECT TRANSISTORS NASA NUCLEAR POWER SCIENCE VALVE WWE oscilloscope 3D TECHNOLOGIES COLOR CODES ELECTRIC TRACTION FEATURED FLEXIBLE ELECTRONICS FLUKE GEARMOTORS INTRODUCTION LASSER MATERIAL 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