Monday, November 30, 2015

Remote Controlled Arduino Motor

In these blog we are going to learn that how to build an arduino dual motor shield and how we can decode and used the infrared remote.


Remote controlled Arduino motor

Step 1: Parts and assembly!

Remote controlled Arduino motor


Remote controlled Arduino motor


Remote controlled Arduino motor




















Parts:


- L298 Motor Driver (x1)

- Vero board (x1)
- Male or female Header Strip (enough to fit your arduino (32)) 

- 1N4007 Diodes (x8)

- 0.1uf and a 22uf capacitor

- Block connectors (x3)

- Jumper Wires

NOTE: 

+5V connected to the E1-2 & E2-3 and these pins are enable pins so we are not connected to the block connector in these we need to add servo for steering and need enough PWM pins. 
In these blog we are going to use the Red,Green LED’s and 2.2KHM resistor and counted on the serial communication.

Assembly:-

You can etch a circuit board and we are going to use the jumper wires.
In this blog firstly you can cut them so that it can be match your arduino pins if we are not using all pins then its is better to fit the headers on all of them so its looking very nice and stable.

then place the headers like you would any component and solder from beneath.

L1 and L2 are connected to Arduino pins 5 and 6 respectively which control motor (A) on pins 2,3 of l298 (forwards and backwards).

L3 and L4 are connected to Arduino pins 9 and 10 respectively .which control motor (B)on pins 13,14 of l298(forwards and backwards).

Step 2: Decode an IR remote.

Remote controlled Arduino motor



In this blog the most important part is IR receiver.

You could either buy it or salvage it from and remote controlled device.

Pin1 of IR receiver goes to pin 11 of arduino , pin2 to ground ,pin 3 to +5v.

That’s everything for the hardware, now upload the attached file "IR-Decoder" to you arduino and open serial and make sure the baud rate is 9600.

Now get a remote and start clicking you should start getting values on the screen.

You need 2 buttons for the forwards direction(increase and decrease speed), 2 buttons for the backwards direction(increase and decrease speed),and 1 button for stop.

You choose whatever buttons you need .

NOTE: 
Some of you may have noticed that if you press the same button for a long duration you'll get a different value which won’t work in the code, so you have to click the button gradually not continuously.
I found a lot of TV remotes that give you the same values while pressed for a long duration(example: Sony),you just need to keep testing remotes.

The code will work fine even if you don't find one but its better and faster this way.


#include <IRremote.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
  delay(100);
}

Step 3: Updating and uploading the code.

Now we're done with the IR-Decode file,we don't need it anymore,we only need the values that we noted.

now take these values and place them here but in the code(attached file):

#define upi 0x"value" ...(up increase)

#define upd 0x"value"... (up decrease)

#define Stop 0x"value" ...(stop)

#define downi 0x"value" ...(down increase)

#define downd 0x"value" ..(down decrease)

replace the ones in the quotes " replace" .

If your decoding and you get letters and numbers at the same time you have to place a 0x at the beginning, if you only have numbers don't place it. 

So now connect everything up, place the shield on the arduino solder the IR Receiver pins as described before on the shield, connect the USB, and upload only the motor-shield-dual-motor-variable-speed file which you modified.

And after uploading open Serial and check if you’re getting feedback and attach one motor at a time because the arduino alone can’t handle two motors so it starts glitching.

After checking everything remove the USB cable connect an external power supply (12-18vdc)

and test both motors at the same time .

Note:-

if your motors aren’t rotating in the same direction and you dont want to flip the pins on the arduino or change the pins in the code just reverse the polarity of the motor

UPDATE:

I updated the code so that if you’re going forwards and u suddenly went backwards without stopping I’ll momentarily stop and start reversing and no matter how many times you pressed forwards and backwards without stopping you'll start from initial value or speed 0.

#include <IRremote.h>
#define upi 0x10FED22D
#define upd 0x10FE50AF
#define Stop 0x10FEB04F
#define downi 0x10FE30CF
#define downd 0x10FE926D
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
int outPin1 = 9;
int outPin2 = 10;
int outPin3 = 5;
int outPin4 = 6;
int i=0,j=0,a=0,b=0,c=0,d=0;
void setup()
{
Serial.begin(9600); 
pinMode(outPin1, OUTPUT);
pinMode(outPin2, OUTPUT);
pinMode(outPin3, OUTPUT);
pinMode(outPin4, OUTPUT);
irrecv.enableIRIn(); 
}
void loop()
{
if (irrecv.decode(&results))
{
irrecv.resume();
if(results.value== upi){
delay(30);
if(a>=1){
  i+=5;
   }
Serial.println(i);
digitalWrite(outPin2, LOW);
digitalWrite(outPin4, LOW);
Serial.println("increase speed forwards");
   a++;
if(i>250){
   i=250;
}
if(j<=250 && j>=0){
  j=0;
  c=0;
}
analogWrite(outPin1,i);
delay(100);
analogWrite(outPin3,i);
}
if(results.value== upd){
delay(30);
Serial.println(i);
if(b>=1){
  i-=5;
  }
digitalWrite(outPin2, LOW);
digitalWrite(outPin4, LOW);
Serial.println("decrease speed forwards");
   b++;
if(i<0 ){
   i=0;
}
analogWrite(outPin1,i);
delay(100);
analogWrite(outPin3,i);
}
if(results.value== downi){
delay(30);
if(c>=1){
   j+=5;
  }
Serial.println(j);
digitalWrite(outPin1, LOW);
digitalWrite(outPin3, LOW);
Serial.println("increase speed backwards");
   c++;
if(j>250){
   j=250;
}
if(i<=250 && i>=0){
  i=0;
  a=0;
}
analogWrite(outPin2,j);
delay(100);
analogWrite(outPin4,j);
}
if(results.value== downd){
delay(30);
Serial.println(j);
if(d>=1){
  j-=5;
  }
digitalWrite(outPin1, LOW);
digitalWrite(outPin3, LOW);
Serial.println("decrease speed backwards");
  d++;
if(j<0){
  j=0;
}
analogWrite(outPin2,j);
delay(100);
analogWrite(outPin4,j);
}
if(results.value== Stop){
delay(30);
  i=0;
  j=0;
digitalWrite(outPin1, LOW);
digitalWrite(outPin2,LOW);
digitalWrite(outPin3, LOW);
digitalWrite(outPin4,LOW);
Serial.println("Stop");
}
}
}

Step 4: update

Remote controlled Arduino motor



If I get good feedback on this blog I’ll do a follow up that features a self navigating RC car with IR proximity sensors, and I’ll also share my Arduino code and explain how to modify it if you want to add more sensors for better navigation. Feel free to post comments and suggestions in the section below.



Saturday, November 28, 2015

Arduino Uno with GSM shield

In this system we use  a very simple and chip arduino GSM and GPRS shield.Here we are going to use the SIM 900.This module is available in market in very lower price.This module is not easy to mount so here we use a Break board TDGGSM-900.
To make the connection module and arduino we make a  PCB in which we use LM317 and capacitor filter and no other thing we use in it.In this system LM317 give the 3.9v to the module.
To communicate with Arduino we use a switch.
throw serial hardware (pin 0 and 1)
throw serial software (pin 4 and 5)
Arduino Uno GSM shield
Arduino Uno GSM shield
Arduino Uno GSM shield







Step 1: The GSM library

This is the GSM_shield library documentation:

Here is a GSM_shield Library intended for GSM Shield by Futura Elettronica (www.futurashop.it).

This Library is derived from Hwkitchen’s GSM Library http://www.hwkitchen.comand include the NewSoftSerial library to comunicate using the pin 4 (RX) and 5 (TX).

You can also use the pin 0 and 1 (RX and TX) but you must disconnect the module to upload the sketch (so it’s not very nice), and you must modify the library.

How install the library for Arduino

After downloading of the GSM_Shield Library unzip the GSM_Shield folder to Arduino

Folder\libraries\ (es. C:\Programs\arduino-0022\libraries\GSM_Shield)

In the GSM_Shield.zip you can find the library to comunicate with gsm module and the file for use the NewSoftSerial.

Basic description

GSM_Shield library is created as standard class with the Gsm_Shield.cpp and Gsm_Shield.h source files. GSM_Shield class is based mainly on the serial communication

between the Arduino board and the GSM module placed on the GSM Shield. There are used standard AT commands for the communication with the GSM Module.

The Current version of library uses blocking version of communication.

It means that the program is blocked until the communication function is finished – so until required data are sent and required answer is received. The Advantage of that blocking approach is that it is easy to

understand the program flow. On the other hand there is also disadvantage that we can’t use the processor resources in the time when the program just waits for the incoming data.

Note: please pay attention to serial comunication mode. With the serial hardware (pin 0 and 1) you can reach the default baudrate of the module SIM900 (115200). But if you use the pin 4 and 5 the NewSoftSerial library can’t support (receive) the baudrate, so you must chose a lower baudrate.

With the command TurnOn(baudrate) you turn on the module and fix the baudrate. e.g. TurnOn(9600);

Methods

There are described important functions for the end user in this document.

The GSM_Shield Library contains also some functions that are used internally

and are not described in the document. It is also possible to use these

functions by the end user of course as they are defined as public but there

is needed to check the library source code with notes.


int LibVer(void)

returns library version in format XYY -it means X.YY (e.g. 100 means vers. 1.00)

Sample: GSM_Shield_LibVer


void TurnOn(baud)

turns on the GSM module in case module is off and sends some initialization AT commands which are possible to send before registration -> InitParam(PARAM_SET_0)

Should be used at the beginning of the sketch in the setup() function.

Set also the module baudrate (Note: if you use the hardware serial, there are no limit to the baudrate, 115200 is possibile. But using the pin 4 and 5 the NewSoftSerial must be use and the baud limit is 57600).

baud value possibile: 4800, 9600, 19200, 38400, 57600, 115200(no use with this library which include NewSoftSerial)

void setup()

{

gsm.TurnOn(9600);

}

Sample: GSM_Shield_LibVer



void InitParam(byte group)

Sends parameters for initialization of GSM module
group: 0 – parameters of group 0 – not necessary to be registered in the GSM

AT&F

1 – parameters of group 1 – it is necessary to be registered

AT+CLIP=1

AT+CMEE=0

AT+CMGF=1

Sample: GSM_Shield_LibVer

void Echo(byte state)
Function to enable or disable echo

Echo(1) enable GSM echo mode

Echo(0) disable GSM echo mode

Sample: GSM_Shield_LibVer


byte CheckRegistration(void)

checks if the GSM module is registered in the GSM net.

This method communicates directly with the GSM module in contrast to the method IsRegistered() which reads the flag from the module_status

(this flag is set inside this method)

must be called regularly at the one place in the main sketch loop

(recommendation repeat time is from 1sec. to 10 sec.)

return valus:

REG_NOT_REGISTERED – not registered

REG_REGISTERED – GSM module is registered

REG_NO_RESPONSE – GSM doesn’t response

REG_COMM_LINE_BUSY – comm line is not free

Sample: GSM_Shield_Reg



byte IsRegistered(void)

returns flag if the GSM module is registered in the GSM net

this method does not communicate directly with the GSM module,

just reads the flag so it is very fast unlike CheckRegistration()

which takes more than 20msec.

it is recommended to use this function everytime it is necessary to use some GSM function which needs GSM module is registered – checking ingoing SMSs, checking calls etc.

return valus:

0 – not registered

>0 – GSM module is registered

Sample: GSM_Shield_Reg



byte CallStatus(void)

checks call status

return values:

CALL_NONE – no call

CALL_INCOM_VOICE – incoming voice call

CALL_ACTIVE_VOICE – active voice call

CALL_NO_RESPONSE – no response

Sample: GSM_Shield_Call



byte CallStatusWithAuth(char *phone_number, byte first_authorized_pos, byte last_authorized_pos)

checks status of call(incoming or active) and makes authorization with specified SIM positions range

parameters and return values:

phone_number: a pointer where the tel. number string of current call will be placed so the space for the phone number string must be reserved

first_authorized_pos: initial SIM phonebook position where the authorization process starts

last_authorized_pos: last SIM phonebook position where the authorization process finishes

Note(important):

================

In case first_authorized_pos=0 and also last_authorized_pos=0 the received incoming phone number is NOT authorized at all, so every incoming is considered as authorized (CALL_INCOM_VOICE_NOT_AUTH is returned)

return:

CALL_NONE – no call activity

CALL_INCOM_VOICE_AUTH – incoming voice – authorized

CALL_INCOM_VOICE_NOT_AUTH – incoming voice – not authorized

CALL_ACTIVE_VOICE – active voice

CALL_INCOM_DATA_AUTH – incoming data call – authorized

CALL_INCOM_DATA_NOT_AUTH – incoming data call – not authorized

CALL_ACTIVE_DATA – active data call

CALL_NO_RESPONSE – no response to the AT command

CALL_COMM_LINE_BUSY – comm line is not free



void PickUp(void)

picks up the incoming call

Sample: GSM_Shield_Call



void HangUp(void)

hangs up call(incoming or active)

Sample: GSM_Shield_Call



void Call(char *number_string)

calls the specific number

e.g. gsm.Call(“+390123456789″);



void Call(int sim_position)

calls the number stored at the specified SIM position

e.g. gsm.Call(1); // call to the number stored at the 1st SIM position



char SendSMS(char *number_str, char *message_str)

sends SMS to the specific phone number

parameters and return values:

number_str: pointer to the phone number string

message_str: pointer to the SMS text string

return:

ERROR ret. val:

—————

-1 – comm. line to the GSM module is not free

-2 – GSM module didn’t answer in timeout

-3 – GSM module has answered “ERROR” string

OK ret val:

———–

0 – SMS was not sent

1 – SMS was sent 9/15

example of use:

gsm.SendSMS(“00XXXYYYYYYYYY”, “SMS text”);



char SendSMS(byte sim_phonebook_position, char *message_str)

sends SMS to the specified SIM phonebook position

parameters and return values:

sim_phonebook_position: SIM phonebook position <1..20>

message_str: pointer to the SMS text string

return:

ERROR ret. val:

—————

-1 – comm. line to the GSM module is not free

-2 – GSM module didn’t answer in timeout

-3 – specified position must be > 0

OK ret val:

———–

0 – SMS was not sent

1 – SMS was sent

an example of usage:

GSM gsm;

gsm.SendSMS(1, “SMS text”);



char IsSMSPresent(byte required_status)

finds out if there is present at least one SMS with specified status

if there is new SMS before IsSMSPresent() is executed this SMS has a status UNREAD and then after calling IsSMSPresent() method status of SMS is automatically changed to READ

parameters and return values:

required_status:

SMS_UNREAD – new SMS – not read yet

SMS_READ – already read SMS

SMS_ALL – all stored SMS

return:

ERROR ret. val:

—————

-1 – comm. line to the GSM module is not free

-2 – GSM module didn’t answer in timeout

OK ret val:

———–

0 – there is no SMS with specified status

1..20 – position where SMS is stored

example of use:

char position;

char phone_number[20]; // array for the phone number string

char *sms_text;

position = gsm.IsSMSPresent(SMS_UNREAD);

if (position) { // read new SMS

gsm.GetGSM(position, tel_number, &sms_text);

}



char GetSMS(byte position, char *phone_number, char *SMS_text, byte max_SMS_len)

reads SMS from specified memory(SIM) position

parameters and return values:

position: SMS position <1..20>

phone_number: a pointer where the phone number string of received SMS will be placed

so the space for the phone number string must be reserved – see example

SMS_text : a pointer where SMS text will be placed

max_SMS_len: maximum length of SMS text excluding also string terminating 0×00 character

return:

ERROR ret. val:

—————

-1 – comm. line to the GSM module is not free

-2 – GSM module didn’t answer in timeout

-3 – specified position must be > 0

OK ret val:

———–

GETSMS_NO_SMS – no SMS was found at the specified position

GETSMS_UNREAD_SMS – new SMS was found at the specified position

GETSMS_READ_SMS – already read SMS was found at the specified position

GETSMS_OTHER_SMS – other type of SMS was found an example of usage:

GSM gsm;

char position;

char phone_num[20]; // array for the phone number string

char sms_text[100]; // array for the SMS text string

position = gsm.IsSMSPresent(SMS_UNREAD);

if (position) {

// there is new SMS => read it

gsm.GetGSM(position, phone_num, sms_text, 100);

Serial.println(“DEBUG SMS phone number: “, 0);

Serial.println(phone_num, 0);

Serial.println(“\r\n SMS text: “, 0);

Serial.println(sms_text, 1);

}

char GetAuthorizedSMS( byte position, char *phone_number, char *SMS_text, byte max_SMS_len, byte first_authorized_pos, byte last_authorized_pos)

reads SMS from specified memory(SIM) position and makes authorization -

it means SMS phone number is compared with specified SIM phonebook position(s) and in case numbers match GETSMS_AUTH_SMS is returned, otherwise GETSMS_NOT_AUTH_SMS is returned

parameters and return values:

position: SMS position to be read <1..20>

phone_number: a pointer where the tel. number string of received SMS will be placed so the space for the phone number string must be reserved – see example

SMS_text : a pointer where SMS text will be placed

max_SMS_len: maximum length of SMS text excluding terminating 0×00 character

first_authorized_pos: initial SIM phonebook position where the authorization process starts

last_authorized_pos: last SIM phonebook position where the authorization proces finishes

Note(important):

================

In case first_authorized_pos=0 and also last_authorized_pos=0

the received SMS phone number is NOT authorized at all, so every

SMS is considered as authorized (GETSMS_AUTH_SMS is returned)

return:

ERROR ret. val:

—————

-1 – comm. line to the GSM module is not free

-2 – GSM module didn’t answer in timeout

-3 – position must be > 0

OK ret val:

———–

GETSMS_NO_SMS – no SMS was found at the specified position

GETSMS_NOT_AUTH_SMS – NOT authorized SMS found at the specified position

GETSMS_AUTH_SMS – authorized SMS found at the specified position

an example of usage:

GSM gsm;

char phone_num[20]; // array for the phone number string 12/15

char sms_text[100]; // array for the SMS text string

// authorize SMS with SIM phonebook positions 1..3

if (GETSMS_AUTH_SMS == gsm.GetAuthorizedSMS(1, phone_num, sms_text, 100, 1, 3)) {

// new authorized SMS was detected at the SMS position 1

Serial.println(“DEBUG SMS phone number: “, 0);

Serial.println(phone_num, 0);

Serial.println(“\r\n SMS text: “, 0);

Serial.println(sms_text, 1);

}

// don’t authorize SMS with SIM phonebook at all

if (GETSMS_AUTH_SMS == gsm.GetAuthorizedSMS(1, phone_num, sms_text, 100, 0, 0)) {

// new SMS was detected at the SMS position 1

// because authorization was not required

// SMS is considered authorized

Serial.println(“DEBUG SMS phone number: “, 0);

Serial.println(phone_num, 0);

Serial.println(“\r\n SMS text: “, 0);

Serial.println(sms_text, 1);

}



char DeleteSMS(byte position)

deletes SMS from specified SMS position

parameters and return values:

position: SMS position <1..20>

return:

ERROR ret. val:

—————

-1 – comm. line to the GSM module is not free

-2 – GSM module didn’t answer in timeout

-3 – position must be > 0

OK ret val:

———–

0 – SMS was not deleted

1 – SMS was deleted



char GetPhoneNumber(byte position, char *phone_number)

reads phone number string from specified SIM position

parameters and return values:

position: SMS position <1..20>

return:

ERROR ret. val:

—————

-1 – comm. line to the GSM module is not free

-2 – GSM module didn’t answer in timeout

-3 – position must be > 0

phone_number is empty string

OK ret val:

———–

0 – there is no phone number on the position

1 – phone number was found

phone_number is filled by the phone number string finished by 0×00

so it is necessary to define string with at least

15 bytes(including also 0×00 termination character)

an example of usage:

GSM gsm;

char phone_num[20]; // array for the phone number string

if (1 == gsm.GetPhoneNumber(1, phone_num)) {

// valid phone number on SIM pos. #1

// phone number string is copied to the phone_num array

Serial.println(“DEBUG phone number: “, 0);

Serial.println(phone_num, 1);

}

else {

// there is not valid phone number on the SIM pos.#1

Serial.println(“DEBUG there is no phone number”, 1);

}



char WritePhoneNumber(byte position, char *phone_number)

writes phone number string to the specified SIM position

parameters and return values:

position: SMS position <1..20>

phone_number: phone number string for the writing

return:

ERROR ret. val:

—————

-1 – comm. line to the GSM module is not free

-2 – GSM module didn’t answer in timeout

-3 – position must be > 0

OK ret val:

———–

0 – phone number was not written

1 – phone number was written 14/15

char DelPhoneNumber(byte position)

del phone number from the specified SIM position

parameters and return values:

position: SIM position <1..20>

return:

ERROR ret. val:

—————

-1 – comm. line to the GSM module is not free

-2 – GSM module didn’t answer in timeout

-3 – position must be > 0

OK ret val:

———–

0 – phone number was not deleted

1 – phone number was deleted



char ComparePhoneNumber(byte position, char *phone_number)

compares specified phone number string with phone number stored at the specified SIM position

parameters and return values:

position: SMS position <1..20>

phone_number: phone number string which should be compare

return:

ERROR ret. val:

—————

-1 – comm. line to the GSM module is not free

-2 – GSM module didn’t answer in timeout

-3 – position must be > 0

OK ret val:

———–

0 – phone numbers are different

1 – phone numbers are the same

an example of usage:

if (1 == gsm.ComparePhoneNumber(1, “123456789″)) {

// the phone num. “123456789″ is stored on the SIM pos. #1

// phone number string is copied to the phone_num array

Serial.println(“DEBUG phone numbers are the same”, 1);

}

else {

Serial.println(“DEBUG phone numbers are different”, 1);

}

Step 2:

In this step there are the schematics and PCB.

Step 3: The sketch


Arduino Uno GSM shield

Arduino-GSM Based Relay

Hi friends we are going to make a blog and I hope this blog become useful for every person.
In this blog we are going to make a  GSM latching relay.
In this system firstly the phone is hung and then output is turned on and when again phone is rung then the output is turned off.


GSM based Arduino Relay

Warnings:

At this point the electricity is dangerous and its can kill.
If we are not use the cover then we cant do the internals work in projects nad there will be live contacts exposed  when the unit is connected to the mains.

 Materials & Parts

To build this system we have some items which is very important for this system.

Shopping List

Project Box –Biggest size.
Arduino Uno – visit at - https://www.robomart.com/arduino-uno-online-india
This module has not lower price but we cnan purchase it minimum price by visit that link
Arduino Relay – visit at- https://www.robomart.com/single-channel-12v-relay-board
The small relay connect to the main relay of the Arduino.
Mains Relay - visit at - https://www.robomart.com/single-channel-12v-relay-board
This one is rated 30A at 240V and is used to switch the high voltage on and off.
12V Power supply - visit at- https://www.robomart.com/12-volt-2a-smps-adaptor
You don't have to use this one, any 12 volt supply will do, as long as it fits in the project box and can provide 2 amps or so.
5V Power supply - visit at -  https://www.robomart.com/5-volt-1-amp-smps-adaptor
This is used to lower the 12 volt supply to the 5 volts needed to run the arduino and the arduino relay.

GSM based Arduino Relay

GSM based Arduino Relay
GSM based Arduino Relay
GSM based Arduino Relay
GSM based Arduino Relay



 The Plan

The photo shows the insides of the project.
GSM based Arduino Relay

Wiring Diagram

This wiring diagram shows how I connected everything together to make the project work. Follow this and you should be fine
This diagram show that how can we connect the all parts with the help of wires and you can follow this and make the project good.


GSM based Arduino Relay


 Mobile Phone Hacking

We are able to interface the mobile phone with the Arduino so for this we are going to hack the way by its own hardware wise.
So for this purpose we need to the vibratos motor and battery.

GSM based Arduino Relay



GSM based Arduino Relay

Vibrator Motor

On The LG side I have a vibrator motor which is connected to the phone’s motherboard with the help of wires. Then I cut off the motor because many wiring are used inside this and then I solder the longer wires to the to this wiring  and then covered the area for the help of cable strain and to hold my hack in place.
Nokia mobile phones, which are what I would personally recommend for this task are slightly harder though. You will need to remove the back plastic panel. This contains the vibrator motor. Remove the motor and solder wires carefully to the pads on the phone motherboard.
After this I have finding the image of Nokia3310 and this image connect to the vibrator contacts.
When the phone receives an incoming call, voltages appears on the wires and what the maximum voltage that appears is and the polarity of the wires and connect the negative to ground.
When incoming call received by the phone then the voltage appear on the wires and then its show that what the maximum voltage and the polarity of the wires and then we connect the negative to the ground terminal.

Battery Contacts

In which we provide the power to the phone in place of give the power to the mobile phone with the help of charging socket and leave the battery. 
I found that the easiest option is to remove the battery and connect power straight to the phone itself. However, some phone batteries have on board components which mean the phone will not start without the battery.
The LG required just 4 volts across its battery terminals to start up, all that was needed was a diode to drop the voltage only one volt or so from the 5 volt supply.
 Nokia, however are more tricky, they require some extra work.

Arduino Code

Coding is the toughest part of the project so we are going to show how to get work with this and those coding attached in that.


GSM based Arduino Relay


int relaypin = 13;                // relay is connected to pin 5
int phonepin = 8;                 // phone output is on 13
boolean relayon = false;          // set up the variable. 
void setup()
{
  pinMode(relaypin, OUTPUT);        // The relay pin is a output from the arduino.
  pinMode(phonepin, INPUT);         // The phone pin is a input to the arduino. 
  digitalWrite(phonepin, LOW);      // when project is turned on, relay must start off. 
}
void loop()
{
  if (digitalRead(phonepin))       // when the phone pin is high, when voltage is present, when the phone rings.
  {  
                             relayon = !relayon;            // change the state of the variable. 
    delay(1000);                       // Delay 1 second
    digitalWrite(relaypin, relayon);   // Change the state of the output pin depending on the variable
    delay(5000);                       // Delay 5 seconds
  }
}

Adjustments:-

There are many thing that is very useful and it depend how the phone is working.
Firstly we do first thing we are going to add the additional resistor across the vibrator motor output and it’s this dissipated the voltage and it confuses the arduino that in which states it should be.

Finishing of the Project:-

Now the project has been finished and you can now see the video and know about that very easily.

GSM based Arduino Relay

 

Afterthoughts & Version 2

Afterthoughts

So when we plugged the relay then there is needs to turned on the phone.
The phone may vibrate for things other than an incoming call, and this will be seen as an input to the Arduino.

Ideas for Version 2

When we plugged the relay then the phone automatically turned on


GSM based Arduino Relay



Friday, November 27, 2015

Fire Alarm System GSM based using Arduino

You know that 90% fire damage occur due to the lack of early detection but now we are going to solve these problem. With the help of these technology we can reduce this problem. So in this system we can use a GSM module in which when fire occurred then the sms send to the users mobile no or you can replace the sms  with your own string.


GSM based Arduino

Components:-

  • Arduino Uno
  • LCD 16X2
  • LM35 Temp Sensor
  • GSM MODULE
  • 5v Power Supply for Arduino
  • 12v Power supply for GSM MODULE
  • 10k Potential Meter

Demo on Proteus:-

In this system we can set the threshold value in the code if (temp>45).when the temp reaches the 45 C then SMS send to the user mobile no. When fire occurred you can replace this value by your own but we know that very well that the room temp is 25 C. So when we are going to set the value we know that what the room temp. So we can change our value according to the room temp..
You can change the mobile no of a person with the cell phone no. to receive the fire alert SMS.  

GSM based Arduino
GSM based Arduino





















Download the Code:-

In this system coding is very simple you can easily know about that. You cannot face any problem to make this project.
#include <SoftwareSerial.h>
#include<LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 
SoftwareSerial mySerial(9, 10);
int sensor=A1;
float temp_read,Temp_alert_val,Temp_shut_val;
int sms_count=0,Fire_Set;
void setup()
{
  pinMode(sensor,INPUT);
  mySerial.begin(9600);   
  Serial.begin(9600);    
  lcd.begin(16,2);  
  delay(500);
}
void loop()
{
CheckFire();
CheckShutDown();
}
void CheckFire()
{
lcd.setCursor(0,0);
lcd.print("Fire Scan - ON");
Temp_alert_val=CheckTemp();
if(Temp_alert_val>45)
{
  Fire_Set=1; 
lcd.setCursor(0,1);
lcd.print("Fire Alert! SMS Sent!");
while(sms_count<3) //Number of SMS Alerts to be sent
{  
SendTextMessage(); // Function to send AT Commands to GSM module
}
}
}
float CheckTemp()
{
temp_read=analogRead(sensor); // reads the sensor output (Vout of LM35)
temp_read=temp_read*5;    // converts the sensor reading to temperature
temp_read=temp_read/10;  // adds the decimal point
return temp_read; // returns temperature value in degree celsius
}
void CheckShutDown()
{
if(Fire_Set==1)
{
Temp_shut_val=CheckTemp();
if(Temp_shut_val<28)
{
lcd.setCursor(0,1);
lcd.print("Fire Shut! SAFE NOW");
sms_count=0;
Fire_Set=0;
}}}
void SendTextMessage()
{
  mySerial.println("AT+CMGF=1");    //To send SMS in Text Mode
  delay(2000);
  mySerial.println("AT+CMGS=\"+929542xxxxxx\"\r"); // change to the phone number you using 
  delay(2000);
  mySerial.println("Fire in NEW ROOM!");//the content of the message
  delay(200);
  mySerial.println((char)26);//the stopping character
  delay(5000);
   mySerial.println("AT+CMGS=\"+929847xxxxxx\"\r"); // change to the phone number you using 
  delay(2000);
  mySerial.println("Fire in NEW ROOM!");//the content of the message
  delay(200);
  mySerial.println((char)26);//the message stopping character
  delay(5000);
  sms_count++;
}
So this was all, assemble your own alarm, test it and if you like the project, reflect it in the comments section below!!

Thursday, November 26, 2015

Arduino Uno Atmega328

To make this system I have a old arduino diecimila and some new Atmega328p-pu chips and I bought it without boot loader to save the money.
  
Then we are going to search the blog to see if I can burn the boot loader to the chips but it’s not work.   
To solder the pins with Arduino diecimila we have many ways to do this but there is problem that I have only one Arduino so I don’t want to change my board.


Arduino uno Atmega328

Open sketch ArduinoISP and setup wires

Firstly I open the Arduino SP sketch so that I can check it.then we found some blogs which have missed one link connecting pin 10 of arduino to pin 1 of atmega328P.When I connect this that everything work perfectly.

 First column refers to Arduino Diecimila, second column refers to pin of Atmega328p
Pin 10 -> pin 1 
Pins 13, 12, 11 -> pins 19, 18, 17
Pins 10 -> pin 1
Vcc -> pins 7, 20
Gnd -> pins 8, 22

And connecting crystal and capacitors to Atmega328p
Crystal 16Mhz -> pins 9, 10
Capacitor 22pf -> pins 8,9
Capacitor 22pf -> pins 8, 10

Arduino uno Atmega328
Arduino uno Atmega328

Arduino uno Atmega328



















How To  Upload ArduionISP program and start burnning bootloader.

We are going to know about the arduino diecimila with Atmega 168p and then we burn Arduino UNO to my atmega 328p.

First upload program to set my Diecimila as ArduioISP

1. Select Tools -> Board -> Arduion Diecimila

2. Select Tools -> Programmer -> AVR ISP

3. Compile then upload the ArduinoISP sketch. You should see "Done upload"

4. Now select Tools-> Board -> Arduino UNO

5. Select Tools -> Progammer -> Arduino as ISP

6. Click Burn Boot loader. In a minute you should see "Done burning bootloader"

If you are smart you can easily reached step 6 within 1 min. To burn a second Atmega328p, unplug USB cable, swap a new one in your breadboard after that plug the cable and run 6 step again.
If this process doesnot work properly then checks the wiring and follow all  steps again.

Arduino uno Atmega328
Arduino uno Atmega328



















Step 3: How to Test bootloaded Atmega328p


To test that Atmega 328p is working with boot loader or not, I simply swap  it with my at mega 168 on my ardino diecimila then follow some procedures:
 load the Blink program. Change the LED turn on and off duration so you know this is your unique program when running in atmega328p after upload.
From Arduino IDE, select Tools -> Board -> Arduino UNO

 Select Tools ->Programmer -> AVR ISP
Plug in a LED to GND and pin 13 of your Arduino  Swap Atemega168 with Atmega328p. Careful when you unplug the chip. More gentle less chance of damaging the chip. I used two needles to help unplug the chip :).

Plug the Arduino back to your computer. Make sure you hear a beep that computer confirms recognize you board
 Upload. Then you should see LED blink in the way you set in step 1.
If this process does not work properly to check the step 2.
To test the at mega 328p we can repeat the step5-8.
Arduino uno Atmega328
Arduino uno Atmega328
Arduino uno Atmega328