28 February 2016

Send and Receive SMS from Arduino Using GSM Modem

This post shows the basic use of GSM Modem interfaced with Arduino Uno which Sends and receives SMS .You could select the sending or receiving mode and  you can even Chat with your Buddies . Yup , i have tried :-)





Get the right things.....

Components needed :-


1. Arduino Uno
2. GSM modem SIM 900 with a 12v battery supply or 12v Adapter
3. Bread board(Optional)
4. Jumper wires.
5. Arduino IDE software (latest version).
6. And Enthusiasm :-)

GSM modem


Power Supply GMS Modem SIM 900 :-


Be careful while selecting your GSM modem . The modem that i am using needs 12v/1A supply .
There are also other types which could run on just 5V. So be careful and don't burn your board .

12 V Adaptor to power GSM Modem



Coding :-

Connect the arduino to PC while uploading

Download Link--> https://drive.google.com/file/d/0BxsMZLQokV3CX2Ewc0EzWTZJMUk/view?usp=sharing

or just copy paste it into Arduino IDE



// LK's code
// lookforlk.blogspot.com
// lookforlk.blogspot.com
#include <SoftwareSerial.h>
SoftwareSerial mySerial(9, 10);  // tx,rx
void setup()
{
  mySerial.begin(9600);   // Setting the baud rate of GSM Module
  Serial.begin(9600);  
  delay(100);
}
void loop()
{
  if (Serial.available()>0)
   switch(Serial.read())
  {
    case 's':
      SendMessage();
      break;
    case 'r':
      RecieveMessage();
      break;
  }

 if (mySerial.available()>0)
   Serial.write(mySerial.read());
}
 void SendMessage()
{
  mySerial.println("AT+CMGF=1");
  delay(1000);  // Delay of 1000 milli seconds or 1 second
  mySerial.println("AT+CMGS=\"+91 x \"\r"); // Replace x with mobile number
  delay(1000);
  mySerial.println("I am LK Karthikeya texing from GSM module");// The SMS text you want to send  change any msg
  delay(100);
   mySerial.println((char)26);
  delay(1000);
}
 void RecieveMessage()
{
  mySerial.println("AT+CNMI=2,2,0,0,0");
  delay(1000);
 }

Code Screenshot , the code looks like this :-) 




Connection:-

Hardware wiring is very simple. It needs just 3 wiring :

1.Connect TX to Arduino digital pin 9
2.Connect RX to Arduino Digital pin 10
3.Connect GND to Arduino's GND

And don't forget to insert sim into GSM modem





Note :- 

   
Upload code into arduino then connect the GSM modem otherwise you may encounter error like "Error"  .

Execution :-

Before execution make sure the hardware connection and coding part is done correctly


1.In arduino ,Open the Serial monitor (Ctrl +Shift + M) or tools -->Serial Monitor

2. Now Type and enter 's' for sending text (Check the Image)

The text that we entered in program has not been displayed but the full text will be sent no worries


Now check your mobile, you would have received an sms



3 To receive Sms from someone , just open serial monitor again and Type 'r' . This will show the sms and the number of the sim (Check the Image)



Yup i succeeded doing it . check My SS(ScreenShot) last image



Check and Arduino's serial monitor and Screenshot


 If you face any issues, you can contact me.I can help you online .

Regards,
lkkarthikeya@gmail.com



#SMS
#Send
#Receive
#DIY
#Wireless
#Arduino
#project
#Code






22 February 2016

Arduino based EarthQuake detector with coding DIY


Before going into this project i would like to tell you that this is just a school project . Ofcourse I did this during my third year of college and this project may help the Beginners who wants to learn Arduino.

Description
     Here i have used 3-axis Accelerometer Sensor interfaced with Arduino . whenever the Accelerometer is shaken or mover there will be a buzzer sound beeping and i call it a EarthQuake Detector

Components/Software required

1. Arduino UNO
2. Accelerometer Sensor (ADXL3xx)
3. BreadBoard
4. Jumper Wires (Female to male) -6
5. Buzzer / LED (For indication)
6. Arduino IDE Software - https://www.arduino.cc/en/Main/Software




Accelerometer Sensor (ADXL3xx)

Arduino Uno

                                                   
Connections

1. ST - A0
2. Z - A1
3. Y - A2
4. Z - A3
5. GND - A4
6. VDD - A5
7.Buzzer or LED on Digital PIN 12 and Digital Ground the -ve terminal of Buzzer/LED

You could use male to female jumper wires to connect accelerometer to Arduino Analog Pins


Coding :

1.First we have to find the values of accelerometer in its actual position then write actual code for the buzzer indications


TEST CODE :

Before Uploading the sketch make sure you have given the Hardware connection correctly and place Accelerometer in a narrow surface.

Here is the test code Copy paste in Arduino IDE


const int xpin = A3;                  // x-axis of the accelerometer
const int ypin = A2;                  // y-axis
const int zpin = A1;                  // z-axis (only on 3-axis models)

void setup()
{
  // initialize the serial communications:
  Serial.begin(9600);

}

void loop()
{
  // print the sensor values:
  Serial.print(analogRead(xpin));
  // print a tab between values:
  Serial.print("\t");
  Serial.print(analogRead(ypin));
  // print a tab between values:
  Serial.print("\t");
  Serial.print(analogRead(zpin));
  Serial.println();
  // delay before next reading:
  delay(500);
}



2.Now compile the code  .

3.Connect the Arduino to PC and Upload the code . If you get any error regarding ports  then go to
   Tools--> Ports and change the port . This will work .

4 . Open Serial monitor . Tools --> Serial Monitor . Now you will be seeing X,Y,Z values of Accelerometer in its surface position . When you move the Accelerometer the value will be changed

5. Note the optimu value . I got 300   280   300 . If you get a different value note it and change in the Following code

Now lets check the final code...


Final Code:

Note: If you get any other value than 300   280   300 , make change in code at xmin,ymin and                zmin


int buzzerop = 12;
int xpin = A3;                   // x-axis of the accelerometer
int ypin = A2;                   // y-axis
int zpin = A1;
long xmin=300;   //     If you get different value while running the TEST.ino code
long ymin=280;   //     Put that here
long zmin=300;   //      300    280    300 are the value taken from my TEST.ino output
long x=0;
long y=0;
long z=0;

void setup()
{
  Serial.begin(9600);

  pinMode(12,OUTPUT);

}

void loop()
{
   x = analogRead(xpin);
   y = analogRead(ypin);
   z = analogRead(zpin);

 
   if(y<ymin || x<xmin || z<zmin)               // the buzzer will be beeped only if they cross this condition
   {
     digitalWrite(12,HIGH);
     delay(500);
   }
   else
   {
     digitalWrite(12,LOW);
          delay(250);
   }
}





Thats all folks , whenever you shake or tilt the Accelerometer there will be a Buzzer sound.

If you want the Device to be more sensitive then alter the values of  X , Y , Z



If you cannot get the output contact me :-

lkkarthikeya@gmail.com




#DIY
#Arduino
#Project
#Earthquake
#detector
#Accelerometer