Food Living Outside Play Technology Workshop
Remote control via GPRS/GSM SMS.
by Elecrow on January 22, 2013
Table of Contents
Remote control via GPRS/GSM SMS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Intro: Remote control via GPRS/GSM SMS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Step 1: Prepare your tools and parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Step 2: Insert a SIM card to the GPRS shield. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Step 3: Communicate with Crowduino/Arduino by hardware serial. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Step 4: Upload the program. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Step 5: Plug shields to the Crowduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Step 6: Control the Relay shield by manually. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Step 7: Have a test for the manual control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Step 8: Control the LED via SMS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Step 9: Connect the lamp to the Relay shield. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Step 10: Control the lamp via SMS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
http://www.instructables.com/id/Control-the-relays-via-GPRS-SMS/
Author:Elecrow Elecrow
Elecrow is an open hardware facilitation company based in Shenzhen. We integrate resources to serve new era of innovation. To make your making and
innovation easier, we offer various development platform, modules, tools, electronics components,and other open source hardware.we also provide many
kinds of service ,include Fusion PCB service, manufacture service and buying service etc. No matter whether you're a curious student, a qualified engineer,
or a hobbyist who loves to create, there will always be something here to meet your needs.
Intro: Remote control via GPRS/GSM SMS.
Remote control, it has been a very profound things in the past. When I was a child, I always imagine that I have an equipment which can control all home appliances.
Now, this has become a reality, and it is quite easy. Then I will step by step to show you how to remote control your home appliances via the GPRS/GSM SMS and
relays.
At first, let me give a brief introduction about relay to you.
Relays are used where it is necessary to control a circuit by a low-power signal (with complete electrical isolation between control and controlled circuits), or where
several circuits must be controlled by one signal. It acts as a “low voltage controlled switch to control high voltage”, For example, if you want to control power of your
washer or air conditioner, which is oftern110v or 220v,by microchip, such as AVR or PIC, it is necessary and safe the make your microchip control the relay first, and
then control the power supply of those device with the relay.
With the GSM SMS, it is possible to control the relay remotely. You can send a message via phone to control the relay on&off. With this, it will convenient to control any
device wirelessly, especially helpfully on irrigation, smart home, outdoor remote control etc.
So, let’s make such a “SMS control relay” with Arduino, GPRS/GSM and a Relay module.
Image Notes
1. undefined
Image Notes
1. Please ignore this scissors.
http://www.instructables.com/id/Control-the-relays-via-GPRS-SMS/
Step 1: Prepare your tools and parts.
Select the module you need, a Xrduino, a GPRS/GSM module and relay module is essential. The GPRS/GSM and relay in “Shield” would be more Convenient if works
with Arduino. Notice that the Rated Current of the relay Is important, make sure it meets your requirements. Otherwise it maybe dangerous. Here, I use a 2A
rating current relay, which is enough for my application to control a lamp. Usually, home appliances consume currents as below:
Device Max current(A)
Electric Fan 1
Lamp 2
TV 2
Refrigerator 2
Microwave Oven 8
Air Conditioner Depends on the power, usually <20
The modules I used in this application are as below:
Crowduino
Elecrow GPRS/GSM Shield
Elecrow Relay Shield
Image Notes Image Notes
1. Crowduino 1. Tools
2. GPRS/GSM Shield
3. Relay Shield
Step 2: Insert a SIM card to the GPRS shield.
The gprs module needs a SIM card to work, just the same as a phone. Insert a SIM card to the SIM socket , make sure the SIM is unlocked. Record the number of SIM
Card, it will be used in programming for Arduino.
http://www.instructables.com/id/Control-the-relays-via-GPRS-SMS/
Step 3: Communicate with Crowduino/Arduino by hardware serial.
There are two methods for GPRS/GSM Shield to communicate with the micro controler, one is through the software serial port, another is hardware serial port. I will show
you the second method, communicate with the Crowduino/ Arduino by hardware serial port. There are three pins 2*3 pins in the GPRS shield. You can see the silk mark
in both side of pins, one side is Xduino(this is connect to the hardware serial port), and the other side is SWserial(this side is used as software serial port). Just as the
picture, plug the jumper caps to the Xduino side.
Step 4: Upload the program.
As the programming, you will need the Arduino IDE to compile and download the program to Arduino.
Download the code :
Using_SMS_to_Control_Relay_Hardware Serial.ino
Before the compiling, please Open the file: SoftwareSerial.h in arduino\libraries\SoftwareSerial, and modify the
#define _SS_MAX_RX_BUFF 64 // RX buffer size
To
#define _SS_MAX_RX_BUFF 128 // RX buffer size
With this modification, the Arduino would have more buffer for the received message to avoid any communication bugs.
If you have not got ready to comprehend the details, you can just copy the codes into your Arduino IDE and down it to Arduino to continue.
Then, open this file by Arduin IDE. Upload the program to the Crowduino, please note that don't connect the GPRS shield to Crowduino when uploading program,
very important!!!!
Image Notes
1. Crowduino use a ATmega328 chip.
http://www.instructables.com/id/Control-the-relays-via-GPRS-SMS/
Step 5: Plug shields to the Crowduino
Plug your shields to the Crowduino, you can put the GPRS Shield in the top or put the Relay Shield in the top. In here, because we need operating the Relay Shield later,
so I put the Relay Shield in the top.
Step 6: Control the Relay shield by manually.
Now, the hardware has been connected, the program has been uploaded, we can have a try to the Relay Shield, This Relay Shield is very interesting! There are 4
Independent relays on the relay shield, each one can be controlled by the Arduino or manually. Also, there are 4 LEDs to show user the working state of relays.
Image Notes
1. Control the Relay Shield manually.
Step 7: Have a test for the manual control.
Before remote control the lamp, we can make a test. Here, we need a breadboard , a LED, two AA battery and some breadboard cables .
Plug the anode wire(the red one) of power supply to the anode of LED via the breadboard, using the same method, plug the breadboard jumper wire to the cathode of
LED.
As we only need one relay here, we use the relay U3, which was controlled by the Arduino Pin5.
There are 3 terminals for U3 relay: COM3, NC3 and NO3. The COM3 is the common port, while the “NO” means “Normally Open” and NC means “Normally
Connected”. That’s to say, the logic between these 3 terminals is:
When the relay is not active:
COM3 connected to NC3 and disconnected to NO3;
When the relay is active:
COM3 disconnected to NC3, and connected to NO3;
Insert the cathode wire(black one) of power supply to NO3, insert the cathode wire(orange) of LED to COM3 and tighten the terminal with a screwdriver.
Now, you can control the LED on or off via button 3, it is funny, hah...
http://www.instructables.com/id/Control-the-relays-via-GPRS-SMS/
Image Notes Image Notes
1. Using 2 AA batteries 1. The length pin is anode pin.
Step 8: Control the LED via SMS.
It is time to take out your mobile phone, sent a text ”onb” to the number of the SIM card in GPRS module, the relay would be on , and the LED on!
It is necessary to explain the program, if you feel it is boring or it is too simple, just skip the following paragraph and remember there are 4 relays: U1, U2, U3, U4 each
corresponding to d, c, b, a, if you want to control U1 on or off, you can send 'ond' or 'offd' to the number of the SIM card in GPRS module, the relay U1 would be on or off.
If you want to control multiple relays in one SMS, just send the control commands in one SMS. For example, if I want to control U1, U2, U3 on and U4 off, sending 'ond
onc onb offa' would reach this purpose. In here, I was using U3 to control the LED, so after I send 'onb', the relay U3 would be on , and the LED on!
There are some important functions you need to learn if you want to learn more on the gprs shied:
void ProcessGprsMsg()
Function: process the data Arduino get from the GPRS shield. If there is a string “+CMGR:” in the received data, theArduino will get to know: “I have received a short
message, I need to analyze the message to know what to do next!”
Parameter: none
Return: none;
void ProcessSms( String sms )
Function: Arduinoanalyze the short message received. As received a string: ”ona”, it will pull up the related pin to active the relay, making the terminal COM4 connected
NO4; while received a string “offa”, it will pull down the pin to make the COM4 and NO4 disconnected.
Parameter: the received message;
Return : none
In this program, once the Arduino receive the command ”offa”, which means “off the a” it will pull download the Arduno pin4, which change the relay U4 from inactive to
active state. You will hear some noise like “bang..bang”, and also the LED would blinks.
http://www.instructables.com/id/Control-the-relays-via-GPRS-SMS/
Step 9: Connect the lamp to the Relay shield.
Finally to the another leading role to play, do you still remember the lamp at the begining? This step I will show you how to 'destroy' this nice and cute lamp.
Cut off the power supply wire of the lamp(as the picture), and insert one end to COM3,tighten the terminal with a screwdriver, and the other end to NO3 with the same
method.
Make sure the Crowduino and Shields are connected to the power and the program was run normally.
Give the power to the lamp, push the switch of lamp to on, and stay away from it...
http://www.instructables.com/id/Control-the-relays-via-GPRS-SMS/
Image Notes
Image Notes 1. insert one end to COM3, another one end to NO3.
1. Be careful to avoid scald your hand!
http://www.instructables.com/id/Control-the-relays-via-GPRS-SMS/
Step 10: Control the lamp via SMS.
Everything is ok, but the SMS. Take out your phone again, sent a text ”onb” to the number of the SIM card in GPRS module. The lamp was finally lit...
You can control all the device you want via this method. and, you can even control 4 relays simultaneously to control 4 device by modifying the program in Arduino. But
again, notice the Potential danger especially for the high voltage and big current decice . Good luck…
Related Instructables
Real Time GPS
Tracker with
Arduino GSM Integrated 432 MHz
wireless
shield by Smart home Google Maps by IP controlled sensors and
technolando automation jayeshsukumaran power outlets
Remotely power outlets
Controlled VGA webserver on with Arduino for home
Camera - OpenWRT Webserver. Part automation
router WR703N II. GSM phone using Arduino
Overview by interfaced to controlled reset (Photos) by
dmitryp Arduino, outlet. (Photos)
compared to janisalnis
by janisalnis
Raspberry Pi
and Ubuntu
(Photos) by
janisalnis
http://www.instructables.com/id/Control-the-relays-via-GPRS-SMS/
Advertisements
http://www.instructables.com/id/Control-the-relays-via-GPRS-SMS/