The Code for Sending a Text Message

The Code for Sending a Text Message

Length: 1577 words (4.5 double-spaced pages)

Rating: Excellent

Open Document

Essay Preview

More ↓
GSM Shield library
GSM coding is significantly facilitated by using the GSM library. The library consists of a few header files and examples. The header files encompass AT commands to start up SIM900 and test the serial communications between Arduino and GSM. Moreover, several functions are integrated in the library to facilitate sending text messages, making phone calls and data transfer. It is worthwhile to note that two GSM libraries can be found on the internet, including GSM_Shield library and GSM-GPRS-GPS-Shield library. Both libraries have been tested in the project and it has been found out that the former is not functional. Therefore, the latter is used.
The GSM-GPRS shield header files include: call.h, GPS.h, GSM.h, HWSerial.h, inetGSM.h, log.h, SIM900.h, sms.h, Streaming.h and Widetextfinder.h. In this project, the objective of GSM shield is to send a text message upon detection of an intruder. The libraries required for sending a text message are SIM900.h and sms.h.
The code for sending a text message is shown below. After declaring the header files, variable “sms” of type SMSGSM is declared. The Boolean variable “started” is used to check whether the shield is started or not. The first function sets up the GSM shield. In the first step the serial port of Arduino is started at a Baud rate of 9600 and then a text message is sent to the serial port. The text messages can be monitored using “Serial Monitor” tool in Arduino IDE or on any serial communication software on a PC. This helps examining the operation of GSM and making sure that it is started without any error. Then, the command “gsm.begin” is used to start GSM. The command encompasses a large number of AT commands, which aim at testing the communication link between GSM and Arduino and starting up the GSM. The serial communication is tested for several different Baud rates. By attempting Baud rates from 19200 to 2400, the maximum valid Baud rate is found. After establishing serial communication, the GSM is started. It is worthwhile to point out that prior to starting up the GSM, the SIM900 has to be turned on by pressing the SIM900 power button on the shield. Otherwise, the program will get stock on “gsm.begin” and the system will not work. Another necessary condition for starting up the GSM is proving appropriate power source. If GSM starting is successful, it will return “1”and the message “status=ready” is printed on the serial monitor.

How to Cite this Page

MLA Citation:
"The Code for Sending a Text Message." 123HelpMe.com. 21 May 2019
    <https://www.123helpme.com/view.asp?id=404202>.

Need Writing Help?

Get feedback on grammar, clarity, concision and logic instantly.

Check your paper »

What is Cryptography? Essay

- I. What is Cryptography Cryptography is a secrecy technique where the users involved create an actual message but it is hidden in some way. One form of Cryptography is Steganography. This is another secrecy technique, a bit more ancient than cryptography itself. It has been used for thousands of years, but as a primitive form of secret messages. The word itself is a derivative of two Greek words: steganos means “covered” and graphein means to “write”. In ancient time, a man named Pliny the Elder used milk from a thitymallus plant as invisible ink....   [tags: Secrecy Technique, Sending Messages]

Research Papers
2005 words (5.7 pages)

The Code Of The Navajo Code Essay

- Sitting in class wanting to tell my friend about the ideas I had for after school meant passing a note to him. But what if I got caught. How would I get the message to him without anyone else knowing about the plans. It meant a secret code needed to be devised. My friends and I pondered what code we could come up with. It had to be simple enough that we wouldn’t forget it, but hard enough that no one could break the code. I believe this was the start of my love for programming. Watching and hearing stories of codes being used such as the Navajo code talkers, and the Germans inventing Enigma left me wanting to know about the subject....   [tags: Cryptography, Encryption, Cipher]

Research Papers
1139 words (3.3 pages)

Text Talk in Students’ Formal Writing Essay

- Several decades ago, “Ain’t ain’t a word” was a favorite litany of English teachers everywhere, and they sang it whenever that offending word cropped up in a student’s speech or writing. Today, however, ain’t is a word firmly entrenched in dictionaries, nonstandard, but a word nonetheless. Now, looming on the horizon is something which may make language arts teachers long for the days of ain’t – text talk. Text talk, or text speak, is the language of abbreviations, acronyms, and emoticons people use when communicating through short message service (SMS) on their cell phones, or when instant messaging and emailing each other, and it is beginning to creep into students’ formal writing....   [tags: Language ]

Research Papers
1041 words (3 pages)

Ethics Code And Monitoring Transaction Essay

- Ethics is a set of rules of behavior, that employee should have to follow in order to ensure the company’s values shown in all business exchanges. (Karia, 2010) It should not matter the size of the business, a clearly defined code and monitoring transaction should help and keep the company out of trouble with violating the law. The employee should feel good and comfortable with doing the right things. When it comes to digital forensics, you should want to do the right thing, and handle all evident the way it should be done, and if you don’t know, ask somebody who should know....   [tags: Credit card, Debit card, Dennis Rader]

Research Papers
2595 words (7.4 pages)

The Communication Cycle Of Communication Essays

- Communication is how we make contact with others and it being understood. It involves people sending and receiving messages from one person to another. This could be from one person to another, over text, email or even a phone call. How the communication cycle works: 1. A person has an idea. 2. They code their message and how they want to say it 3. They send their message to someone else 4. Another person then receives the message 5. The second person decodes the message. 6. The message is understood....   [tags: Communication, Message]

Research Papers
1680 words (4.8 pages)

Essay on Mobile Advertising And Marketing Strategies

- Mobile advertising and marketing is used by business to market throughout mobile tools such as mobile phone and portable media gamers. Approaches of mobile marketing that business utilize can be something easy like a visual advertisement or something a little bit a lot more complicated such as a qr code. To make a decision which mobile advertising approach is most ideal for your firm, use the following guidance. Be a leader in mobile marketing, not a fan. Mobile advertising and marketing is still the wild, untamed west when it pertains to advancement and ingenuity....   [tags: Marketing, Advertising, Text messaging]

Research Papers
709 words (2 pages)

Essay about Text Message And Teen Literacy

- In the sources that I found about text message and teen literacy, it showed and also informed me on how teens take the next talk to the classrooms in schools and how it creates bad grammar among themselves. During my research I found out that many kids and kids use shorthanded text and it affects their literacy in so many ways. We as teens don’t think that our findings will benefit anyone unless they want to have a short knowledge in grammar. As teens we don’t really see how doing something wrong can harm us....   [tags: Mobile phone, Text messaging, SMS]

Research Papers
1485 words (4.2 pages)

Essay on A Report On The Marketing Strategy Of Samsung

- Samsung did some really unique experiences with near-field communications. The put NFC-enabled posters at bus stops, and when people waved their Samsung phone across the poster, they got free content such as music delivered right to their phone. Another great experience is augmented reality. If you haven 't tried it you should. Go and get yourself an IKEA catalog. IKEA has AR enabled every single one of their catalogs, and if you hover the IKEA app over the catalog page, you then can superimpose and see what that couch or that table is going to look like in your house before you even buy it....   [tags: Mobile phone, Text messaging, Instant messaging]

Research Papers
1556 words (4.4 pages)

Text Message As A Person Who Never Likes For Address Problems Essay

- As a person who never likes to address problems because of the fear of hurting their feelings, I would do it over text message rather than in real life. An example of this was when I was the editor of my high school yearbook. A girl on my staff (lets call her Tina) had been giving me a hard time throughout the whole year and wasn’t giving complete effort for the class. It was 6 AM on a rainy Tuesday in April, and the last of the yearbook pages needed to be submitted. Tina wasn’t there, as usual....   [tags: Mobile phone, Text messaging, SMS]

Research Papers
1332 words (3.8 pages)

Essay on Text Messages

- Introduction Research Question: The effect of text messages on students writing skills at the University of the West Indies. This Topic has intrigued the researchers interest and as a result this proposal will be investigating how text messaging and the affects the writing skills of students that attend the University of the West Indies. This topic is indeed worth studying because of the poor English skills that students are experiencing. I have also had personal experience where as a result of texting my writing skills have been negatively affected....   [tags: Effects, Writing Skills, West Indies]

Research Papers
2139 words (6.1 pages)

Otherwise, status=IDLE is printed. The time consuming process of starting up the GSM is only conducted once after turning on the device.
#include "SIM900.h"
#include
#include "sms.h"
SMSGSM sms;
boolean started=false;
void GSMset () {
//Serial connection.
Serial.begin(9600);
Serial.println("GSM Shield testing.");
if (gsm.begin(2400)){
Serial.println("\nstatus=READY");
started=true;
}
else Serial.println("\nstatus=IDLE");
}

The function SMSsend is called to send a text message. First of all, it is checked whether the GSM has started or not. If so, the command “sms.SendSMS” is used to send a text message. The script accepts two arguments: phone number and text message. If the sending is successful, warning message is printed on serial monitor.
void SMSsend (){
//Serial connection.
Serial.begin(9600);
Serial.println("GSM Shield testing.");
if(started){
if (sms.SendSMS("+61424251544", "Security Alarm"))
Serial.println("\nSMS sent OK");
}
}
It is noteworthy to mention some practical experiences here. The GSM shield is the most complex part of the system. Setting up GSM requires several AT commands and the program is prone to instability. From hardware standpoint, GSM requires stable power supply and dedicated communication pins. One problem that we faced during setting up the GSM shield was the confliction between LCD/keypad and GSM. The LCD uses pin 3 for adjusting the LCD contrast and GSM uses the same pin for communicating with Arduino. This issue was resolved by moving the LCD to the auxiliary box. Another possible solution is to use higher quality, more flexible GSM shield manufactured by Freetronics. Another issue is the confliction between GSM and Xbee in utilizing the serial port. This issue, however, does not result in any malfunction because the Xbee on main box operates as router (receiver) and GSM operates as sender of messages.
Sensors
The PIR sensor code consists of PIR sensor setup and PIR sensor loop functions, as shown below. The PIRset initializes the pin corresponding to PIR as an input pin. It is worthwhile to mention that “inputPin” is defined as pin 32 in the beginning of the auxiliary box code. The command “pinMode” is used to set pin32 as input.
The PIRloop function is called in the main loop to check the status of PIR sensor. If an intruder is detected, the “inputPin” is changed to HIGH and the counter “piri” is incremented. when piri reaches 5, the function Trigsiren is called and piri is changed back to zero. Therefore, a delay is introduced between two successive alarms when PIR sensor detects and intruder. This is helpful for presentation purpose to discriminate between detections of PIR sensors and other sensors.
void PIRset() {
pinMode(inputPin, INPUT);
}
void PIRloop(){
val = digitalRead(inputPin);
if (val == HIGH) {
piri=piri+1;
if(piri>5)
{
Trigsiren(1);
piri=0;
}
}
else {
}
}
The ultrasonic sensor detects an intruder by measuring the distance between the sensor and the nearest object. A range of detection is defined for the sensor. If a thief enters the range of detection of the sensor, it will trigger the alarm. The ultrasonic sensor has four pins including VCC, GND, trigger and echo. In order to measure the distance, a pulse is sent to trigger pin and the program waits for the echo. The time delay between the trigger pulse and echo is used to determine the distance of the object from the sensor.
The ultrasonic sensor code is shown below. In the initialization stage, the trigger and echo pins are indicated as output and input, respectively. Then, in “sonicloop” function a pulse is sent to trigger pin. The pulse is generated in three steps. In the first step, trigger pin is kept LOW for 2ms. Then, the pin is changed to high for 10 microseconds, after which it is changed back to low. The time delay of the echo is measured by command “pulseIn”. The distance is then calculated by time delay over speed of sound over 2. Then, it is checked whether the object is within the pre-specified range and the siren is triggered.

void sonicset() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}

void sonicloop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
//Calculate the distance (in cm) based on the speed of sound.
distance = duration/58.2;

if (distance >= maximumRange || distance <= minimumRange){
}
else {
Trigsiren(2);
}
}

The door sensor consists of a reed switch and a magnet, connected to wall and door, respectively. When the door is closed, the magnet causes the reed switch to stay closed. When the door opens, the magnet is moved away and the reed switch opens. Arduino continually checks the status of door sensor by reading the doorPin. The doorPin is set as an input pin with internal pull up resistor. When the door is opened, the pin goes HIGH and the siren is triggered.
void doorset() {
pinMode(doorPin, INPUT_PULLUP);//Pull up resistor connected between Arduino input and 5V (internally)
}

void doorloop(){
val = digitalRead(doorPin); // read input value
if (val == HIGH) {
Trigsiren(3);
}
}

Temperature changes can be used as a means of detecting intrusion. Unlike other sensors, temperature sensor is an analog sensor, the output of which is proportional to temperature. The sensor output voltage is approximately 3V at 25°C and increases 10mV with 1°C temperature rise. However, the offset voltage can change from device to device. In this project, the offset voltage is calibrated experimentally. In order to determine the offset voltage, the sensor output at room temperature is monitored. Knowing the room temperature, the offset voltage is calculated as follows:

where, 3/5*1024=614 is the ADC output corresponding to the 3V offset and 1024/500=2.05 is the ADC output variations corresponding to 1°C temperature rise. If ambient temperature is 25°C and sensor output is 3V, the temperature offset will be the default value of 25°C. However, experimental measurements indicated that the temperature corresponding to 3V sensor output and ADC output of 614 is 10°C.
The temperature sensor code is shown below. First of all, the command “analogRead” is used to read the ADC output. Subtracting 614 from the ADC output “temp” is calculated. . Temperature threshold of 34°C is used for detection of an intruder. Having temperature offset=10°C, it is inferred that at 34°C temp corresponds to temp= (34°C -10°C)*2.05≈48. If temperature rises above 34°C, alarm is triggered.
int temploop()
{
temp= analogRead(1)-614;
if(temp>48)
alarm=1;
}

Siren
When the alarm is triggered, the main box plays a siren. The siren is in fact a beep with frequency of 600Hz and duration of 0.2s. This is most suitable for demonstration purposes but more powerful siren with power amplifiers can be adopted in practice.
The code for triggering alarm and playing siren consists of three functions, including “sirenset”, “Trigsiren” and “Playtone”. Function “sirenset” initializes the speaker and LED pins. Function Trigsiren plays a beep sound by calling “Playtone” and sends a text message. Each time alarm is triggered, a counter (ia) is incremented. After 100 successive alarms, a text message is sent. This prevents repetitive text messages, which are not only costly but also introduces delay in the flow of the program.
void sirenset()
{
pinMode(pinSpeaker, OUTPUT);
pinMode(ledPin, OUTPUT);
}
void Trigsiren ()
{
ia=ia+1;
playTone(200, 600);
if(ia>100)
{
SMSsend ();
ia=0;
}
}
A simple yet effective way to produce a siren is to generate a square wave. The function “Playtone” conducts this task. Duration (ms) and frequency (Hz) of siren are declared as arguments of the function. Next, duration and period of the square wave are calculated (μs). The speaker pin is set to high and then low with equal durations of period/2 to generate a pulse. The pulse is repeated in while loop until the elapsed time reaches the siren duration.

void playTone(long duration, int freq) {
duration *= 1000;
int period = (1.0 / freq) * 1000000;
long elapsed_time = 0;
while (elapsed_time < duration) {
digitalWrite(pinSpeaker,HIGH);
delayMicroseconds(period/2);
digitalWrite(pinSpeaker, LOW);
delayMicroseconds(period/2);
elapsed_time = elapsed_time+(period);
}
}




Return to 123HelpMe.com