arduino portable phone

Hello Friends.

Welcome. In this post, I will introduce you my Lightweight Arduino GSM Mobile phone. The lightweight mobile is capable of the following National/International features:

  • Make Calls
  • Receive Calls
  • Send SMS
  • Receive SMS

In this project, I used the GSM SIM900A module to connect to the mobile network. It is an adorable all-in-one cellular module that lets you add voice, SMS and data to your projects. It works on frequencies 900/1800MHz and comes with the friendly RS232 which can be easily interfaced with any MCUs, the baud rate is adjustable from 9600 – 115200 through AT Commands.

I also used a display to visualize GUI interfaces, I selected an LCD touch display by Nextion, trust me it is really an awesome display. Nextion adopts a new and easy way to interface any of your projects through UART. Its easy-to-use configuration software (Nextion Editor) allows you to design your own interfaces using GUI commands and makes the pieces of your development effortless, in turn you can save lots of program space in your MCUs. Thanks to Nextion!

On its own, the GSM module and the Nextion touch display can’t do anything. It requires a microcontroller to drive it. At the heart is an Arduino Uno to drive the lightweight GSM Mobile phone, which can send and receive commands over its RX/TX pins.

If you are interested making yours, this guide will show you how to build and upload the source codes to get your project up and running. This is a fairly straightforward project, but an intermediate one especially when you take into account the complexity of the codes.

This project is also a great example of how to use Arduino especially for string & character handling, as well as for you to get acquainted with the new Nextion TFT Intelligent LCD Touch Display and using AT commands for the GSM module. Hope you will enjoy and find my post interesting. Now let us make it.



Parts Required:

Here’s the needed parts for this example.

There’s also some optional accessories.

  • External Mic & Speaker.
  • Stylus.


Wiring:

Connect the GSM module and the Nextion Display to your Arduino by following the appropriate steps below.

  • Nextion +5V to Arduino VDD_5v.
  • Nextion RX to Arduino pin 11
  • Nextion Tx to Arduino pin 10
  • Nextion GND to Arduino GND_0v.
  • GSM Rx to Arduino pin 1
  • GSM TX to Arduino pin 0
  • GSM GND to Arduino GND_0v.

Schematic


Schematic

NOTE: If your SIM card is locked with a PIN code. You can either disable the PIN or enter the PIN via the ‘AT+CPIN’ command just before you can connect the network. Example: “AT+CPIN=1234”.

Setup:

Next, I will show you how to prepare the .HMI (Human Machine Interface) for the Nextion display, without forgetting the Arduino sketch.




Tools Required:


Program the Nextion display:

To make Nextion display the interfaces, the first thing to do is to design an HMI file in the Nextion Editor. This editor allow you to design your interfaces using plug-and-play components like (Text, button, progress bar, pictures, gauge, checkbox, radiobox and much more), for which you can set codes & properties for each of these components.


In this project, I used 8 pages to make the interactive GUI. Most of the icons which I used for the implementation are the freely available Android Icons and can be downloaded from this [link]. I used paint.net (Open Source editor) to edit/resize all the pictures and to create the invert of the icons, to give the feeling of touch when components like buttons are pressed. Touch events like (Press & Release) are also included when components are touched. If you are interested to acquire more about Nextion Instruction Set you can visit the wiki page here.



Programming the Nextion display is just as easy as abc but a time consuming process especially when implementing complex features like numpad & keyboards. However, I wish to mention that at the end you will really enjoy the outcomes, the end results are enormously awesome.



Steps:

  • Load the .HMI file into the editor. Scroll down to find my GitHub repository section of this page.
  • Compile the .HMI file (just under the menu bar).
  • Go to file > Open build folder > copy the .tft file > paste into SD card. Note: make sure the SD card is formatted to FAT32.
  • Once copied, insert the SD card into the Nextion and then power_on.
  • Wait for the .tft to upload.
  • Power_off the Nextion, securely remove the SD card and then again power_on.
  • Voila, you should see your new interfaces on the Nextion Display.


Simulation

Nexiton also provide a handy simulator to test/debug the .HMI files well beforehand you connect your display to your MCUs. The “Instruction Input Area”, allows you to insert commands such as change page, hide/show picture, enable/disable button, enable/disable/insert text & much more to the Nextion display. On the other side, the “Simulator Return Data” gives you the responses from touch events when components on the Nextion display are pressed or even for the commands triggered to the Nextion.



Program the Arduino:

The Ardiuno Uno is the brain of the whole mobile system, the Arduino acts as a middle-ware which interfaces the GSM Module and the Nextion display.

For this project, I did not used any Nextion libraries, as it seems difficult to understand and lack documentations and also my sketches does not compiled when using Nextion libraries, hope to get improvements soon. As such, I decided to move on without the use of libraries, seems to be difficult right? Believe me it’s not.


To get the complete code, simply scroll down to find my GitHub repository section of this page. Copy the code, and paste it into a new sketch in the Arduino IDE. Save it, upload it to your Arduino.


That’s all for the software part! Compile the code. If there are no errors, congratulations your devices is now configured to automatically connect to the cellular Network through the GSM module. Open the Serial monitor, you should see the AT command logs for each events triggered from the Nextion Display.



this project value is $40 dolors but with the help of pcb way i am going to make this project at only cost of $ 30

because i am going to order arduino uno in pcb along with some pcbs and wanted to make some more projects soon. and the code below please check it out friends.




{


#include <SoftwareSerial.h>

SoftwareSerial nextionSerial(10, 11); //Rx, Txchar msisdn[30], ATcomm[30];String rawMsg, pageNum, msg, pls;

void setup(){//Initialize HardwareSerial|SoftwareSerial|GSM module|Nextion display. Perform GSM Location Update. Serial.begin(9600);nextionSerial.begin(9600); while(!Serial){;}power_on();delay(3000);}

void loop(){ while(nextionSerial.available()){rawMsg.concat(char(nextionSerial.read()));}delay(10); //Read the SoftwareSerial. if(!nextionSerial.available()){ if(rawMsg.length()){ pageNum = rawMsg[rawMsg.length()-4]; //Read Nextion: get the page number. msg = rawMsg.substring(1, rawMsg.length()-4); //Read Nextion: get the Raw Msges from Nextion. if((pageNum == "0") && (msg.length() != 0)){querySMS(msg);} //Read Nextion: page0, Query all SMS from the GSM Buffer. if((pageNum == "1") && (msg.length() != 0)){connectCall(msg);} //Read Nextion: page1, Dial and Call the B-number. if((pageNum == "2") && (msg.length() != 0)){releaseCall(msg);} //Read Nextion: page2, Release the call. if((pageNum == "3") && (msg.length() != 0)){sendSMS(msg);} //Read Nextion: Page3, Get the content typed in page 3 and send SMS. if((pageNum == "5") && (msg.length() != 0)){answerCall(msg);} //Read Nextion: page5, Answer Incoming calls. if((pageNum == "6") && (msg.length() != 0)){delReadSMS(msg);} //Read Nextion: page6, Delete read SMS. if((pageNum == "7") && (msg.length() != 0)){delSMS(msg);} //Read Nextion: page7, Delete all SMS (incl unread) from the GSM Buffer. rawMsg="";pageNum="";msg=""; } } while(Serial.available()){pls=Serial.readString();} //Read the HardwareSerial. if(!Serial.available() && pls.length()){ if(pls.indexOf("NO CARRIER") != -1){ //Goto to page0, if B-party Hang up. String nextionCallStr = "page page0";writeString(nextionCallStr); sendATcommand("AT", "OK", 2000); } if(pls.indexOf("BUSY") != -1){ //Goto to page0, if B-Number rejects incoming calls. String nextionCallStr = "page page0";writeString(nextionCallStr); sendATcommand("AT", "OK", 2000); } if(pls.indexOf("NO ANSWER") != -1){ //Goto to page0, if B-Number does not answer incoming calls. String nextionCallStr = "page page0";writeString(nextionCallStr); sendATcommand("AT", "OK", 2000); } if(pls.indexOf("+CLIP") != -1){ //Goto to page5, for any incoming calls. int msisdnFirstDelim = pls.indexOf("\""); int msisdnSeconddDelim = pls.indexOf("\"", msisdnFirstDelim+1); String mobNum = pls.substring(msisdnFirstDelim+1, msisdnSeconddDelim); String nextionCallStr = "page page5";writeString(nextionCallStr); nextionCallStr = "page5.t1.txt=\""+mobNum+"\"";writeString(nextionCallStr); nextionCallStr = "page5.t0.txt=\"Incoming Call\"";writeString(nextionCallStr); nextionCallStr = "page5.p0.pic=20";writeString(nextionCallStr); sendATcommand("AT", "OK", 2000); } if(pls.indexOf("+CMTI") != -1){ //If new Msges|Query Msges|Display star picture. smsComputation(); String nextionCallStr = "vis p2,1";writeString(nextionCallStr); }pls=""; }}

void power_on(){ //Initialize GSM module, perform Location Update, latch to cellular network, read GSM SMS buffer. uint8_t answer = 0; while(answer == 0){answer = sendATcommand("AT", "OK", 2000);} while((sendATcommand("AT+CREG?", "+CREG: 0,1", 500) || sendATcommand("AT+CREG?", "+CREG: 0,5", 500)) == 0); writeString("page0.t0.txt=\"Searching...\"");delay(2000);searchNetwork(); delay(2000);smsComputation(); }

int8_t sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout){//Function to send AT commands and read responses to/from the GSM module. uint8_t x=0, answer=0; char GSMreponse[100]; unsigned long previous; memset(GSMreponse, '\0', 100); delay(100); while(Serial.available()>0) Serial.read(); Serial.println(ATcommand); previous = millis(); do{if(Serial.available() != 0){GSMreponse[x] = Serial.read(); x++; if(strstr(GSMreponse, expected_answer) != NULL){answer = 1;} }}while((answer == 0) &&((millis() - previous) < timeout)); return answer;}

void searchNetwork(){//Function to search for available cellular networks|Get network registration|Send attched network to Nextion display. String sendCOPScommand, readCOPScommad, networkOperator, sendNetOperator; int startCOPS=-1, copsFirstcomma, copsSecondcomma, copsNL; while(Serial.available())(Serial.read()); sendCOPScommand="AT+COPS?"; Serial.println(sendCOPScommand); while(!Serial.available()); while(Serial.available()){readCOPScommad=Serial.readString();} if(readCOPScommad.indexOf("+COPS:") != -1){ copsFirstcomma=readCOPScommad.indexOf(",", startCOPS+1); copsSecondcomma=readCOPScommad.indexOf(",", copsFirstcomma+2); copsNL=readCOPScommad.indexOf("\n", copsSecondcomma+1); networkOperator=readCOPScommad.substring(copsSecondcomma+2, copsNL-2); sendNetOperator="page0.t0.txt=\""+networkOperator+"\"";writeString(sendNetOperator); }sendCOPScommand=readCOPScommad=networkOperator="";copsFirstcomma=copsNL=0;}

void querySMS(String querySMSContent){//Function to query all SMS from the GSM buffer. Serial.println(querySMSContent);}

void connectCall(String conCallContent){//Function to Initiate Mobile Originated Call To Dial B-Number. String nextionCallStr = "page2.t0.txt=\"Connecting\"";writeString(nextionCallStr); while((sendATcommand("AT+CREG?", "+CREG: 0,1", 500) || //0,1: User registered, home network. sendATcommand("AT+CREG?", "+CREG: 0,5", 500)) == 0); //0,5: User registered, roaming. conCallContent.toCharArray(msisdn, rawMsg.length()); sprintf(ATcomm, "ATD%s;", msisdn);sendATcommand(ATcomm, "OK", 10000); nextionCallStr = "page2.t0.txt=\"Calling\"";writeString(nextionCallStr); memset(msisdn, '\0', 30);memset(ATcomm, '\0', 30);}

void releaseCall(String relCallContent){//Function to Hang up a call. Serial.println(relCallContent); }

void sendSMS(String sendSMSContent){//Function to get content typed from Nextion|select SMS Message Format|Send SMS Message to B-number. int firstDelim = sendSMSContent.indexOf(byte(189)); int secondDelim = sendSMSContent.indexOf(byte(189), firstDelim+1); String smsContent = sendSMSContent.substring(0, firstDelim); String phoneNumber = sendSMSContent.substring(firstDelim+1, secondDelim); while((sendATcommand("AT+CREG?", "+CREG: 0,1", 500) || sendATcommand("AT+CREG?", "+CREG: 0,5", 500)) == 0); if(sendATcommand("AT+CMGF=1", "OK", 2500)){phoneNumber.toCharArray(msisdn, msg.length());sprintf(ATcomm, "AT+CMGS=\"%s\"", msisdn); if(sendATcommand(ATcomm, ">", 2000)){Serial.println(smsContent);Serial.write(0x1A); if(sendATcommand("", "OK", 20000)){Serial.println("message sent");} else{Serial.println("error sending");}} else{Serial.println("not found >");} }smsContent=""; phoneNumber="";memset(msisdn, '\0', 30);memset(ATcomm, '\0', 30);}

void answerCall(String ansCallContent){//Function to change Nextion text and picture, if Incoming call is accepted. Serial.println(ansCallContent); String nextionCallStr = "page5.t0.txt=\"Connected\"";writeString(nextionCallStr); nextionCallStr = "page5.p0.pic=21";writeString(nextionCallStr);}

void smsComputation(){//Function to Read SMS from GSM buffer. Normally, SMS buffer size=20 & select only 10 SMS. int startCPMS=-1, CPMS1comma, CPMS2comma, msgCount=0; int startCMGR=-1, cmgrIndex, cmgrNLindex, smsNLindex; String sendCPMScommand, readCPMScommand, CPMSMsgCount; String sendCMGRcommand, readCMGRcommand, inCMGR, inSMS, dspCount; sendCPMScommand = "AT+CPMS?"; Serial.println(sendCPMScommand); while(!Serial.available()); while(Serial.available()){readCPMScommand=Serial.readString();} if(readCPMScommand.indexOf("+CPMS:") != -1){ CPMS1comma = readCPMScommand.indexOf(",", startCPMS+1); CPMS2comma = readCPMScommand.indexOf(",", CPMS1comma+1); CPMSMsgCount = readCPMScommand.substring(CPMS1comma+1, CPMS2comma);msgCount = CPMSMsgCount.toInt(); dspCount="page6.t51.txt=\""+CPMSMsgCount+"\"";writeString(dspCount); if((msgCount > 0) && (msgCount <= 10)){writeString("page6.p1.pic=35");} if(msgCount > 10){writeString("page6.p1.pic=34");}int spotSelect = 0; while(Serial.available())(Serial.read()); if(msgCount != 0){ for(int iSMS=20; iSMS>0; iSMS--){ sendCMGRcommand="AT+CMGR="+String(iSMS, DEC); Serial.println(sendCMGRcommand); while(!Serial.available()); while(Serial.available()){readCMGRcommand=Serial.readString();} if((readCMGRcommand.indexOf("+CMGR:")!=-1) && (spotSelect<(50))){ cmgrIndex = readCMGRcommand.indexOf("+CMGR:", startCMGR+1); cmgrNLindex = readCMGRcommand.indexOf("\n", cmgrIndex+1); inCMGR = readCMGRcommand.substring(cmgrIndex, cmgrNLindex-1); smsNLindex = readCMGRcommand.indexOf("\n", cmgrNLindex+1); inSMS = readCMGRcommand.substring(cmgrNLindex+1, smsNLindex-1); readSMS(inCMGR, inSMS, iSMS, spotSelect); spotSelect=spotSelect+5; }startCMGR=-1;cmgrIndex=cmgrNLindex=smsNLindex=0;inCMGR=inSMS=readCMGRcommand=""; } } }readCPMScommand=CPMSMsgCount="";startCPMS=-1;CPMS1comma=CPMS2comma=msgCount=0;}

void readSMS(String readinCMGR, String readinSMS, int readiSMS ,int readinspotSelect){//Function to parse the loaded SMS from GSM module and present to Nextion display. int startComma=-1, firstColon, firstComma, secondComma, thirdComma; String smsSeqNum, smsStatus, smsBNumber, smsDateTime, actualSMS; String startOfPage="page6.t", middleOfPage=".txt=\"", pageContent; firstColon = readinCMGR.indexOf(":", startComma+1);firstComma = readinCMGR.indexOf(",", startComma+1); secondComma = readinCMGR.indexOf(",", firstComma+1);thirdComma = readinCMGR.indexOf(",", secondComma+1);smsSeqNum = String(readiSMS); smsStatus = readinCMGR.substring(firstColon+7, firstComma-1); smsBNumber = readinCMGR.substring(firstComma+2, secondComma-1); smsDateTime = readinCMGR.substring(thirdComma+2, readinCMGR.length()-1);actualSMS = readinSMS.substring(0, readinSMS.length()); pageContent = startOfPage + readinspotSelect + middleOfPage + smsStatus+"\"";writeString(pageContent);readinspotSelect++; pageContent = startOfPage + readinspotSelect + middleOfPage + smsBNumber+"\"";writeString(pageContent);readinspotSelect++; pageContent = startOfPage + readinspotSelect + middleOfPage + smsSeqNum+"\"";writeString(pageContent);readinspotSelect++; pageContent = startOfPage + readinspotSelect + middleOfPage + smsDateTime+"\"";writeString(pageContent);readinspotSelect++; pageContent = startOfPage + readinspotSelect + middleOfPage + actualSMS+"\"";writeString(pageContent); smsSeqNum=smsStatus=smsBNumber=smsDateTime=actualSMS=pageContent="";firstColon=firstComma=secondComma=thirdComma=readinspotSelect=0;}

void delReadSMS(String inDelReadSMS){//Function to delete only read SMS from the GSM Buffer. Serial.println(inDelReadSMS);}

void delSMS(String indelSMS){//Function to delete all (Read/Unread) SMS from the GSM Buffer. Serial.println(indelSMS);}

void writeString(String stringData){//Function to send commands to the Nextion display. for(int i=0; i < stringData.length(); i++){nextionSerial.write(stringData[i]);} nextionSerial.write(0xff);nextionSerial.write(0xff);nextionSerial.write(0xff);}



this is the code which u can upload and and complete this project. please like my project guys and i am going create a youtube and i want you to support me there. thank u pcb way.

Apply for sponsorship >>
1600+ Projects Sponsored
Nov 20,2020
2,856 viewsReport item
  • Comments(2)
  • Likes(3)
You can only upload 1 files in total. Each file cannot exceed 2MB. Supports JPG, JPEG, GIF, PNG, BMP
0 / 10000