Ben Heck’s DIY Cell Phone Part 1

rootF IMG 6344c3f1831e0

As an Amazon Associate I earn from qualifying purchases.

Woodworking Plans Banner

The Ben Heck show was brought to you by
element14, the electronic design community and online store built for
engineers and hobbyists alike join now & browse the store at element14.com Ben, we need to talk About what? Your smartphone addiction I actually googled it with my smartphone
I'm not addicted to them Well I can think of a few times recently, where it's become a problem [chuckles] Ooh, that's interesting Okay yeah [chuckles] Look Ben look! The truth is out
there! Oh! A new tweet! [chuckles] Those are isolated incidents I remember a time when cell phones were
about connecting with people, catching up with friends and family, but
now it's just removing you from the world and causing a lot of problems, starting fires! We need to do something
before someone gets hurt! You know Allison, you're right I think in today's episode we should
build a basic, bare bones cell phone that only makes calls, make it as small as
possible.

It could work as a backup emergency phone. You know,
bring us back to the basics of cell phones from the nineteen nineties. Let's get
started! Amazing builds, exclusive mods cutting-edge ideas, electronics,
engineering, and more every week on element14's The Ben Heck Show! Here are the parts for the DIY cell phone
that we're going to make we need a keyboard or a keypad of some kind to enter the numbers no fancy touchscreens for us,
microcontroller to scan the keypad and also drive a small display so you can see what
numbers you've typed also to get messages a cellphone module that can take a SIM card you can put in a SIM card from T Mobile for instance and it basically just works, so we're going to use one of those pay as you go cards then finally, a lithium-ion battery to power the whole thing I remember the good old days when cell
phones would actually last days and days if not a whole week between charges and now they don't.

We'll sandwich
everything together make it as small as we can, and then
hopefully come up with a nice little compact cellphone with a large battery so after your Android phone dies after
three hours of use you can use this one as a backup in a
pinch. That is, if you actually remember what your friends phone numbers are. I don't, I don't know any of my friends phone
numbers, iPhone does so, that's kind of, that's kinda bad isn't it? I know my phone number though… Let's
take a look at the parts in more detail. Here is a keypad matrix, that Felix wired
up 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, star, pound and then ABC we can use these buttons
for you know like hang up call backspace. We've got this little OLED
module from Adafruit it's a it's pretty cool, uses the I²C interface
and there's a library that we downloaded that makes it
pretty easy to run yeah so I can't fit a lot a text but I mostly wanted it to be small.

If we're gonna
make our own cell phone it has to have a gimmick my gimmick is that it's going to be
really small I have this Development Board hooked up to it we'll actually wire a new one, we'll probably
laser paint a custom PCB with switches on one side surface mount and the microcontroller on
the other but for now we just have this. I'll use this
for programming it. Here's a lithium-ion battery this is
actually, this is bigger than the battery in my cell phone so you know considering you're not running
a bunch of other crap this should actually last a pretty decent amount of time. This
is a "Fona" cellphone module, I think Felix got this from Adafruit and you stick a SIM card in
the back, let me show you, you put your SIM card in the back and then
we'll have our own custom headers for it basically send this commands using the
serial port AT commands like a modem, like call this
number or answer that phone call etcetera and then it just basically works
and you also can hook the battery right into it and it has a charging circuit as well and this port here allows you hook up, apple headphones you know that has like the microphone and the speakers we'll probably put our own microphone
and speaker onto this though and we'll probably use a smaller antenna
than this.

Okay so those are all the basic parts the first thing I need to do is program a user interface for the screen. So let's get started
with that. I'm walking off camera, like Allison likes. I wrote some code to scan the keyboard at all times and get keys from it, it works pretty much like the texting
radio that we built a few months ago so the system is going to continually scan the keyboard and then when you push buttons it will enter a number up to ten digits,
which is you know, a phone number, at least here in America
so yeah let's flash the code and take a look.
Flash! So I was going through this programmer here, into my AVR development board as far as connections, we have the five
rows, three columns two lines for I²C to the screen and then we'll also have our TX/RX
line going to the phone module.

Alright, lets plug in the
screen there we go, okay so I basically drew these graphics manually, I'm on a signal right now
I just have it at 5 so it will actually draw some signal
bars in and it will draw battery which becomes depleted and messages will be in the upper left corner so, an eight hundred 888 888 8 I don't know what phone number that would be and then you can also delete it, like that and if you try to send an incomplete
number it'll tell you so, yes so it basically is
a cursor driver I mean you know I actually did copy paste, oh I don't want to actually type my phone number there I actually did copy paste a lot of the key code from the texting
radio because it does basically the same thing.

It has a de-bounce actually lets just speed up a little bit, you know so you don't accidently hit the button more times than you want to. So if you hold the button it goes "do" "do" "do" but if you tap it, it goes fast alright looking pretty good. The next step will
be to put in the code so I can actually make a call on the phone I have this data sheet over here which
is basically all the commands for that phone module If you wanna make a call you basically send via serial characters ATD, then the phone number, and then a semi-colon so what I'll do is I'll take the string
of text that's on the screen, it's actually it's not numbers, it's actually ASCII
characters but then since you have to send serial data to the
phone you actually send it ASCII characters.

So if you are going to send a zero you don't send a zero, you send a 48 which is zero in ASCII so let's try that
part out next I'm going to attach the AVR board to the cell phone module we had this communication device hooked up to it before but it's gonna be talking to the module
using serial so we have ground voltage which is going to be 3.3V and we have RX/TX so I'm going to plug this in to line it up see that? When I push this off switch
button it should turn on the cell phone and the microcontroller.

pexels photo 5691612

I'm
going to give it a few seconds to connect to a network and then I'll try
to make a call so what I was gonna do is, I'm gonna type in a number and then when I push the button the AVR is going to send a serial
string to the cell phone module with a command in front of it and the module will be like "Oh! I'm gonna call that number" here I go. Okay I'm gonna type in my phone
number Uh! someone's calling me! Hello? Oh that's right, you don't have a microphone
hooked up do you? It's like I'm talking to a robot Uh they hung up on me! What a jerk! It's pretty easy to make a
call, but getting data back from the cellphone module is a little bit more
complicated the kinda data I wanna get is you know, is the phone ringing? What's the battery level? What's the
cell signal strength? Let me show you what kind response that gives us Now it's time for a tech timeout for today's tech timeout, I thought I
would show you our attempts at double-sided PCB making using laser
paint on the computer here I've drawn a jig that will fit into the laser and I've
also built it kinda looks like a film production
slate a little bit so the thought here is, instead of taking just a square PCB and sticking it into the
corner of the laser that's a little inaccurate.

You take the
jig, you stick that into the corner of the laser 00 then you tape it down so it doesn't move and then you put your square PCB, the PCB has to be cut with a CNC machine so that its
perfectly square when you flip it and the idea with that is, it will stay in
the same position when you double side laser it.

So on the
screen here take a look, I'll let it render. So first
you laser the front of it and then you laser the back, and if I make this
transparent actually the holes won't line up but you'll
see what it looks like so yeah the reason it doesn't line up is
because this distance here is different from
this distance but it'll still work so yeah, my first tasks with this
method I didn't etch this yet but I drilled a hole through the pad and it looks like it lined
up pretty good if anything I drilled the hole little bit too low so we're gonna
perfect this method therefore we can have a laser painted PCB
double-sided in time for part deux of the phone episode I've hooked up the cellphone module to my computer using the serial adapter the connections are ground, TX/RX and voltage reference. On my computer
here, I have opened terminal program. I like
this one because it shows you everything you might possibly want to know and then I also have a list of the AT
commands which I can use to talk to this module alright, so let's just see if we get some sort of response, I'm gonna type AT which basically means nothing alright so it says okay.

Over here now this
is the important thing I can see the list what I'm getting back in decimal, hex
and binary and if you look at these commands here,
this is an echo it's basically sending back what I typed
so I if I type AT it'll send back AT to me and then
its response so we see that it says AT then it has two carriage returns for some reason, a
line feed and then, letters ok, and then
another carriage return line feed when you push enter like in a text
program or whatever it always puts in a carriage return and line feed sometimes it only puts in a line feed or a carriage return but that's what these 13 10 characters mean.

Now, the reason all this is important is because I want to be able to parse the data I get back from the module and obviously I'm a human, I can read this but microcontrollers are dumb so for instance if I want to get the battery level there's a different command for that, let me try and remember what it is it's AT+CBC I think yes okay so it gives me back the command I typed and then it gives
me back the data I want in this case the one we really want
here's is the percentage, we have 93 percent of the battery left and the battery has three thousand nine hundred and thirty one (3931) millivolts and then again okay now the reason that
I have to analyze this is because I have to write a parser that goes past this data then goes past
this data and just picks up the relevant element
which is the percentage of power left the other one that we can look at is
collector signal quality okay this command tells us the
strength of the cell phone signal and since we're in this building that's
not very good it's gonna be a basic number from 0 to 31 right now it's 10 can you hear me now…

Again when the cellphone module sends that back to the microcontroller we have to parse
it so it's like okay we see this alright so if we see +CSQ twice we go over a few character spaces and we take this number and turn it into an actual number not a string of ASCII and then we
can use that to relay hey this is how much cell signal
strength we have or how much battery signal we have the other thing that we might get is a
ring signal let me show you what that looks like,
so I'm gonna call this phone come on wake up you piece a crap.

Call it! Okay I'm gonna call the module and watch the screen. Okay so it's saying
that it's ringing and even that so it's the word ring, carriage return line feed and, oh wait, actually I think I can
answer this by typing something oh who cares? I'm just going to abort it. Alright, so the three things that we want to look for from the module are battery level, signal strength, and
the ring you know string so now it's time for the
real slog writing a parser to pull that data out
of the data stream That's all the time we have for today, I'm
not gonna make you sit and watch as I write the boring parser code but in
the next episode I'll show you how it works and Felix will
also stuff the double-sided PCB and we'll make an enclosure for the phone we'll see you then.

Cut Cut Cut! What the
hell is that‽ Were you working in a barn? Get outta here toots so now, when I push this button
it's gonna toggle on everything unless it doesn't… we need to do
something before someone gets hurt you know Allison you're right that is music to my ears of course it is, you're a woman Oh no you got that on camera! ♫ If you leave me now, take away the Super burny Nintendooo ♫ and that was how we burned down the shed! Finally! the Ben Heck show was brought to you by
element14 electronic design community and online
store built for engineers and hobbyists alike join now and browse the store at element14.com

As an Amazon Associate I earn from qualifying purchases.

You May Also Like

About the Author: tech