I'm not a smartphone user, and I rarely carry my little feature phone. But since Telstra shut down the 3G network, my perfect little flip-phone from 2010 gave me a big hug and moved away.
You'd think in the 14 years since that we'd have an assortment of superior options, but in reality we don't. If they have the features, the buttons are clunky. If it's a beautiful build, it lacks features.
Life's like that sometimes. First world problems.
But what if you could build your own, the way you wanted it? That would be pretty cool.
The last few days I've been like a pig in mud working through the T-A7670SA's feature set evaluating it for a project. I discovered that all the required hardware is present to build a working mobile phone. So of course, I went on a little tangent. This board has Bluetooth, WIFI, LTE, GPS, USB, solar charging, condenser mic input, speaker output, 18650 Battery Holder, TF Card slot, SIM slot and plenty of GPIO.
I'll walk you through how to work with the board, what to solder, how to send/receive SMS and how to send/receive calls using just the stock firmware. No code required.
As there is no keypad or display, all interactions are done via USB/serial interface. Without adding interface and display hardware with our own firmware, there's only so far we can go. But we can do quite a lot as a first step.
The microcontroller on board is the ESP32, so when it comes time to implement new hardware, I'll be using the command line ESP-IDF for development, but we won't be using it for this article.
For communicating with the A7670SA LTE modem via the ESP32, I'll be using Putty.
The A7670SA 4G supported bands are: B1-B5, B7-B8, B28, B66.
So all good for Telstra and Optus.
Before switching it on, it's worth putting your nano SIM card into the slot, and connecting the LTE antenna. You can start it without these, but with your SIM inserted all the auto configuration will connect up to your provider for you, and you'll get good results when testing the signal quality.
Once you have the nano SIM and LTE antenna connected, plug the USB-C cable from the board to your computer. The blue LED will turn on.
Load up Putty. Connect to the active COM port and you'll get some of the following output. Feel free to press the reset button to see the entire startup output. For example:
Modem starting... Modem started! IMEI:862092069729162 [INFO]:SIM Card is ready! Manufacturer: SIMCOM INCORPORATED Model: A7670SA-FASE Revision: A7670M7_V1.11.1 IMEI: 862092069729162
At this point the two red LEDs should light up. If Modem starting…
stays on for more than a minute, press the reset button.
Many LTE modems use the AT Command format from the days of Hayes compatible modems in the 1990s. What a pleasure that became an official standard, though the command set is greatly expanded from the days we typed our dialling commands to reach our Bulletin Board Systems.
Let's try a few commands out to get some information from the modem. It's not required to do these in order to perform communication functions, but it's handy for knowing what is going on.
One final thing before we start typing commands. It's worth making a quick change to Putty so that backspace is treated as Control-H. If I made a mistake typing a command and needed to use the backspace, an invisible character would remain as part of the command and would result in an error.
Fix this in Putty with Settings > Terminal > Keyboard > Backspace = Control-H.
ATE1
will turn on the terminal echo so that you can see the commands you type.
AT+CGMI
gives you the modem manufacturer details: SIMCOM INCORPORATED
.
AT+CSQ
to query the signal strength. If you get +CSQ: 99,99
the first number is RSSI and 99 is unknown or not detectable
. 99 probably means your LTE antenna isn't connected. But if you get something like +CSQ: 28,99
, the 28 indicates around -56dbm.
AT+CPAS
to check the Phone Activity status which gives: 0 which means Ready
.
AT+CPOL?
to get the preferred operator list. In my case it is:
+CPOL: 1,2,"50501",0,0,0,1 +CPOL: 2,2,"50501",0,0,1,0 +CPOL: 3,2,"50501",1,0,0,0
Note the 50501
. If you were to do: AT+CPON
it would return all known mobile operators across the globe. I filtered down to just the Australian operators:
+COPN: "50501","Telstra Mobile" +COPN: "50502","YES OPTUS" +COPN: "50503","vodafone AU" +COPN: "50506","3TELSTRA" +COPN: "50571","Telstra Mobile" +COPN: "50572","Telstra Mobile"
There you see the 50501
for Telstra Mobile.
Point is that the network has been configured automatically for you. That doesn't mean you're guaranteed 100% smooth sailing (though I was), but the commands are all there to help analyse your current state.
AT+CREG?
gets your Network Registration
+CREG: 0,1
The 1 means that the network is registered, and is a home network.
You can list out all the Phonebook entries stored on your SIM or search for a number using a string.
AT+CPBR=1,500
will list all entries from 1 to 500 which, I believe, might be a SIM maximum. Even if you have less than 500, this will show all entries regardless.
AT+CPBR=2 +CPBR: 2,"0412345678",129,"Ralph Phillips"
This gives you they phonebook entry stored at index 2.
AT+CPBF="ralph" +CPBF: 2,"0412345678",129,"Ralph Phillips"
This search for all entries with the text of ralph
. Not case-sensitive.
Want to try sending a message to someone?
First thing is to change to Text Mode. There are two modes, PDU=0 or Text=1.
AT+CMGF?
will tell you what mode you're in.
AT+CMGF=1
sets to Text Mode.
Ok, have you got a friend? Let's say their number is 0412 345 678. Convert this into international format as: +61412345678.
To prepare an SMS:
AT+CMGS="+61412345678" >
At the >
prompt, you can type in your message:
> Look Ma, no phone! Love from Billy.
Do not press enter! Instead press Control-Z. Away your message goes and you'll get a code returned like:
+CMGS: 46
If you don't get a code, it hasn't gone. So in a moment or two some mobile phone somewhere will be buzzing away.
You can list all sent and received SMS messages that are stored on your SIM card.
AT+CMGL=“ALL”
You will get a list of messages like:
... +CMGL: 1,"REC READ","+61412345678","","25/01/30,16:59:03+40" Hello, clever husband. I am impressed that you can send a text. ...
What a lovely message from the wife.
There might be a limit of how many messages you can hold depending on your SIM card.
You will see this message appear in the terminal if you run out of room:
+SMS FULL
You can delete messages to make room by using the index number of a message.
AT+CMGD=1
1 is message index 1. This index will be taken up again when more messages come in.
You don't need to actually do anything to receive. The modem will attempt to bring a message in. And if you don't get an +SMS FULL
message, you'll get a:
+CMTI: “SM”,1
This means an SMS arrived.
We can check all the newly received and unread SMS messages using the specially named filters.
AT+CMGL=“REC UNREAD”
+CMGL: 7,"REC UNREAD","+61412345678","","23/01/30,11:59:03+40" The parcel will in be in the disclosed location. Ensure you arrive there alone.
This will show you all the received, but unread messages. By issuing this command, it means these messages are now considered “read”. So to see all your read messages: AT+CMGL=“REC READ”
or AT+CMGL=“ALL”
.
There is a pair of pads to connect a condenser mic and a pair of pads for connecting a speaker. For more details: https://github.com/Xinyuan-LilyGO/LilyGO-T-A76XX/issues/130
This opens the gateway for phone calls. It's important to be able to hear each other.
Take care with the connections. The pads are very small, especially the mic pair. After soldering the speaker and condenser mic, the following commands allow you to play with the mic gain and speaker volume:
AT+CSDVC=3
lets you set the mic gain to 3.
AT+COUTGAIN=7
sets the speaker volume to the highest level.
Might be time to get your friend to give you a call.
If you do receive a call, something like this will show in your terminal:
+CGEV: NW ACT 8,10 RING +CLCC: 1,1,4,0,0,"0412345678",129,"" RING RING
You can read up on CGEV in the AT Command Manual, but suffice to say, it means someone is trying to call you. RING
is also a pretty obvious indicator. +CLCC
lists current calls and the incoming phone number.
We better answer.
ATA
is the command to answer the call. If you wired up the speaker and mic properly, you should be able to hear them, and they can hear you!
If you didn't answer in time, or they hung up thinking you'd gone to the beach, you would see:
+CGEV: NW DEACT 8,10 +CLCC: 1,1,6,0,0,"0412345678",129,"" VOICE CALL: END NO CARRIER NO CARRIER: END0,"0412345678",129,""
That was fun to receive a call, now let's make one.
To dial a number, it's just a matter of using the ATD
command:
ATD+61423456789;
Some points to note. Again, international phone format is used here. The other significant point is that this command must end with a semicolon ;
. If you don't add one, you'll receive ERROR
.
During the dialling you will receive the following:
+CGEV: NW ACT 8,10 OK +CLCC: 1,0,2,0,0,"+61412345678",145,"" +CLCC: 1,0,3,0,0,"+61412345678",145,""
And when your friend picks up, you will receive:
VOICE CALL: BEGIN +CLCC: 1,0,0,0,0,"+61412345678",145,"" +COLP: "+61412345678",145
Remember to ask them how the kids are getting on.
When it's time to hang up, it's as simple as:
AT+CHUP
And you get the “deact” messages as outlined in the previous section.
There's so much more you can do. Experiments in MQTT and HTTPS for example. I'll cover some in another article. You can also use ESP-IDF to examine the firmware and partitions of the flash memory.
Of course to make a fully featured phone requires rolling up your sleeves and implementing display, input, full UX and adding the battery. Only then can you cut the umbilical USB-C to serial interface and make the phone truly mobile.