Q2406,Q2303 Similar wavecom GSM Modem Interfacing with Arduino: (Syed Razwanul Haque Nabil )
www.fb.com/Nabilphysics www.fb.com/OishiElectronicsSylhetThis is a very simple way to interface Q2303 or similar wavecom module with Arduino. Connect Tx of Modem with Arduino Rx and Rx of Modem with Arduino Tx pin (Software Rx, Tx). Power up Modem with Adapter(5V, 1A). Insert SIM. Make sure modem switch is on. Modem GND must be connected with Arduino GND. I draw a picture for Interfacing with Arduino. I tested it. Code is below.
//OISHI electronics sylhet,Bangladesh. www.fb.com/OishiElectronicsSylhet
//Syed Razwanul haque(Nabil) and Robi Kormoker www.fb.com/Nabilphysics +8801717973140
//Shahjalal University of Science and Technology (www.sust.edu)
//Department of Physics
// Code for Arduino 0023
// Download NewSoftSerial library from www.arduino.cc
#include <NewSoftSerial.h> //Include the NewSoftSerial library to send serial commands to the cellular module.
char r=13; //return character
NewSoftSerial cell(2,3); //Create a 'fake' serial port. Pin 4 is the Rx pin, pin 3 is the Tx pin.
String cellContent=""; //string we're sending
String ctlZ="\x1A"; //the code for Ctrl-Z
String content="Test Massage"; //The text I'm sending
void setup() {
// start the serial library:
Serial.begin(9600);
cell.begin(9600);
}
void loop()
{
//add our message to the CellContent string
cellContent+=content;
//add the Crtl-Z hex character
cellContent+=ctlZ;
//put the modem into text mode
textMode();
//wait for a moment
delay(50);
//send message
sendMsg();
cellContent="";
delay(60000);
}
void textMode()
{
//init text mode
cell.print("AT+CMGF=1");
cell.print(r);
}
void sendMsg(){
//This number needs to be replaced with the number you are sending to
cell.print("AT+CMGS=\"01717973140\"");
cell.print(r);
cell.print(cellContent);
cell.print(r);
}
Just to clarify, when declaring the 'fake' serial port, you said pin4 for rx and pin3 for tx...should it not be pin4 for rx and pin5 for tx as those are the corresponding pins for those digital inputs declared.
ReplyDelete