In this article, we will build an Arduino cell phone (GSM mobile phone) that you can use as the foundation to add more complex features to make an advanced smartphone.
Cell phones have four primary functions: to make calls, receive calls, send SMSs and receive SMSs.
If you want to develop a feature phone with these basic features, you can build the project using Arduino.
Let’s begin by looking at what you need to build the project.
Table of Contents
- Required Components
- Hardware Connections
- Nextion Display Setup
- Arduino Programming
- Wrap Up
- Arduino UNO
- GSM module (SIM900A)
- SIM card
- Touch LCD (Nextion TFT intelligent display)
- Jumper wires
The phone has three primary components.
The SIM900A is an all-in-one GSM module that avails data, SMS, and voice services to your project.
It features an RS232 for easy interfacing with any microcontroller and operates on the 900/1800 MHz frequencies.
Also, it features speaker & mic ports and an adjustable baud rate, which you can set from 9600-115200 using AT commands.
A GSM module for Arduino microcontrollers
Nextion Touch LCD
This touch LCD features a UART interface for connecting to your Arduino board and enables you to control/visualize GUIs after easy configuration using the Nextion Editor.
The editor software configuration simplifies mobile phone development and frees up tons of space in the Arduino UNO board to store other programs.
A Nextion touch display
The GSM module and touch LCD need some brains to coordinate their operations, which is where the Arduino board comes in.
This Arduino UNO microcontroller drives the SIM900A by sending and receiving its commands via the module’s TX and RX pins.
An Arduino UNO R3
If you want a more compact setup, you can use an Arduino Nano board for this project, but we’ll stick with the UNO.
Connect these three components as shown below.
|Nextion TFT Board||Arduino UNO|
|5V (red)||5V (Vdd)|
|GSM Module||Arduino UNO|
The GSM module has a DC power input jack, so you don’t need to power it using the Arduino board.
Nextion Display Setup
Before writing the sketch to run the system via the Arduino board, we should set up the Nextion display first.
You’ll need the following tools to set up the components.
- Nextion editor
- SD card
Begin the process by launching the Nextion editor, then create a Human Machine Interface (HMI) file as the control and visualization interface.
The editor simplifies this process with its development environment, which lets you drop plug-and-play components like buttons, text boxes, gauges, pictures, progress bars, etc.
After dropping each component, you can set its properties and write code to tell it how to react when the user touches or activates it.
Also, ensure you have a make-call, receive-call, send-message, and receive-message page.
A feature phone
And each page should have its function.
For instance, when you start the phone, you should have an initialization page where the phone searches for the SIM card cellular network.
Visualize what you want the phone to do, then create the appropriate pages to form the user interface.
Since Android is an open-source platform, it has several icons available for free, and we recommend using them to create an intuitive interface.
But calling and messaging icons are universal, so you can use any that suits your preference. You can always come back to this editor to make changes later.
We recommend using paint.net to resize or edit the icons and create their inverts to make the touch events on the screen more realistic.
Nextion editor includes touch (press and release) events, so you only have to attach the actual and inverted icons to match them.
After creating the interface pages, the next step is to program the components.
The process might take some time when coding the keyboards and num pads, but it is not difficult.
Like any programming project, you have to compile the project once you complete the development process.
Do so by pressing the compile button under the menu bar.
If you want a complete sample to act as a template for this project, download this HMI file and load it into the editor.
Navigate the pages to make the required changes or leave it as it is.
After compiling the project, the editor will create a TFT file that you can find under File>Open Build Folder.
You will get something similar to this TFT file.
Format your SD card and set it to have a FAT32 file system.
After that, copy this TFT file and paste it into the card.
Insert this card in the TFT display’s port and power it on by connecting the DC jack to a power adapter.
An SD card is plugged into a computer
The TFT file should load on the component automatically, so give it time.
After that, turn off the display, remove the SD card, then power the TFT back on.
The new interface you created will show on the screen.
Coding errors are common in programming so that you might have some on the compiled TFT file.
If you carry these errors forward to Arduino, it might be challenging to troubleshoot the issue.
Luckily, Nextion has a simulation tool for testing and debugging the HMI files before interfacing the display with your microcontroller board.
So before compiling the code to get your TFT file, you can use the simulator, which has an “instruction Input Area” and a “Simulator Return Data” feedback box.
You can insert commands to test all the display’s functions on the instruction input area, such as show pictures, change page, insert text, etc., then get a touch event response on the return data box.
These commands simulate the operations of the Nextion display and will assist in early bug detection.
The GSM module does not need any configuration, so you should head over to the Arduino IDE after you’re through with the display.
It is vital to note that the SIM900A has a GSM buffer size that can hold 20 SMSs, but the Nextion display is not large enough to display all 20.
So to avoid SMS buffer overflow errors, we have included a limit in the Nextion TFT code to show only ten SMSs.
A SIM800L GSM module
Therefore, you will receive a low memory capacity warning on the LCD if the GSM buffer has ten or more SMSs.
This warning will prompt you to delete old SMSs to view the new ones incrementally.
The last step is to program the Arduino board, which acts as the brains and motherboard to connect the TFT display and GSM module.
Connect your board to your computer via USB, launch the Arduino IDE, then paste this code.
Source Code Explanation
The program begins by importing the software serial library to enable serial communication with other digital pins on the Arduino board (in this case, pins 10 and 11).
From there, the code is self-explanatory.
We’ve defined all the functions outside the void setup and void loop functions to make the program look neat and readable.
The first one (power_on) handles the device initialization when you turn it on.
Please ensure you have the SIM card inserted into the GSM module with the PIN disabled using another phone.
Alternatively, you can use this AT command to unlock it within the code.
For instance, if the pin is 0000, use AT+CPIN=0000
After that, “search network” does as the function name implies, and so does the rest.
With all the functions defined, we only have to call them into action.
First is “power_on” in the setup function to launch the phone when you turn it on.
The others come into play in the void loop function because the board must run them indefinitely until you switch off the phone.
Most functions define the actions that should occur in the pages created earlier when programming the display using the Nextion editor.
After compiling the code in your IDE, your feature phone should connect to the mobile network automatically using the GSM module.
And if you open the serial monitor, you should see a log of the AT commands for events triggered when interacting with the TFT display.
As you can see, building an Arduino mobile phone is as simple as connecting three components and writing short lines of code with few display configurations to get the device running.
And we’ve done the heavy lifting for you.
All the required code and display configuration links are available above.
So assemble the hardware, compile the code, and build your first phone.
And don’t forget to plug in the mic and speaker to the GSM module for calls.
If you encounter any challenges, contact us or comment below to ask for assistance.