Sim Card Reader

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
arno_nym
 
Posts: 6
Joined: Mon Oct 20, 2014 7:55 pm

Sim Card Reader

Post by arno_nym »

Hi there,
I built the Sim Card Reader, and it doesn't seem to work.

With the battery unattached, nothing happens, and with a sim card and a battery, it always gives "Unable to connect to reader: /dev/ttyS0" at first try, and the second time it does connect, but gives "Unable to gather information about your card". It shows that the card is connected, but I can't access anything.

The terminal keeps posting stuff like

ySIMserial.py", line 239, in sendAPDU
if (ord(rep) == int(command[2]+ command[3], 16)):
TypeError: ord() expected a character, but string of length 0 found

What could be the problem?
Also, since I didn't have any spare 74HC04 around, I used a CD4049. Could that be causing trouble? Are the old 4000s too slow?

Thanks!

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Sim Card Reader

Post by adafruit_support_mike »

Post a photo of the hardware and we'll see what we can find.

User avatar
arno_nym
 
Posts: 6
Joined: Mon Oct 20, 2014 7:55 pm

Re: Sim Card Reader

Post by arno_nym »

Hmmm, I attached a photo, but I'm pretty sure this won't be of much help, since the components are really squeezed together on the board... sorry.
However, I checked for shorts numerous times, and checked all the connections.
I wasn't sure if the pull-up of IC1E/R4 is any important, so I wired R4 to the output of an unused gate. Also, is there a specific reason why IC1A is connected to VCC? To minimize noise?

I didn't - my IC socket doesn't have the following pins: 5, 9, 10, 13, 16 (latter two are No Connect pins)

Could it be that I have to lower the baud rate for a 4000 series CMOS chip? Or is the IC definitely suitable?

Here's the complete output when it tries to connect, ending up with "Unable to gather information about your card":

Code: Select all

$ python pySimReader.py
TS: 0x3b Direct convention
T0: 0x9f
TAi = 95
TDi = 80
Historical: 1f
Historical: 47
Historical: 80
Historical: 31
Historical: e0
Historical: 73
Historical: 36
Historical: 21
Historical: 13
Historical: 57
Historical: 4a
Historical: 33
Historical: e
Historical: 10
Historical: 31
read: 41
read: 0
read: b4
In:  A0A40000023F00
Traceback (most recent call last):
  File "/media/user/F000-2CF3/pySimReader-Serial-src-v2/pySIMserial.py", line 300, in gatherInfo
    self.gotoFile(["3F00"])
  File "/media/user/F000-2CF3/pySimReader-Serial-src-v2/pySIMserial.py", line 332, in gotoFile
    data, sw = self.sendAPDU("A0A4000002%s" % i)
  File "/media/user/F000-2CF3/pySimReader-Serial-src-v2/pySIMserial.py", line 239, in sendAPDU
    if (ord(rep) == int(command[2]+ command[3], 16)):
TypeError: ord() expected a character, but string of length 0 found
Attachments
sim_reader.jpg
sim_reader.jpg (196.97 KiB) Viewed 1051 times

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Sim Card Reader

Post by adafruit_support_mike »

The soldering looks okay, but I can't trace a circuit diagram from the layout on sight.

One thing to check: are you sure you mapped the inputs and outputs properly? The CD4049 and 74HC04 have different pinouts.

User avatar
arno_nym
 
Posts: 6
Joined: Mon Oct 20, 2014 7:55 pm

Re: Sim Card Reader

Post by arno_nym »

I'm pretty sure about the inputs and outputs. Here's the original schematic: http://www.ladyada.net/make/simreader/simreaderv1_0.png

The pins of the 4049 are wired as follows:

Pin 1 to 5V
Pin 2 to DB9-2
Pin 3 to 2N2222 collector / R3 / Sim pin 7
Pin 4 to R4/R7/D3
Pin 5 unconnected
Pin 6 to R6
Pin 7 to R5/D2
Pin 8 to GND
Pin 9 unconnected
Pin 10 unconnected
Pin 11 to C3/X1/R1
Pin 12 to R2/X1/R1
Pin 13 unconnected
Pin 14 to C2/R2
Pin 15 Sim pin 3
Pin 16 unconnected

Clock pulse looks fine on an oscilloscope, and the voltages at the 4049 outputs make sense.

Also, the output of the console is different with different sim cards, so apparently SOME data is being exchanged... any ideas?

Thanks a million!

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Sim Card Reader

Post by adafruit_support_mike »

From the schematic, it looks like pin 5 should be connected to the FTDI cable's TX line. Without that connection you won't be able to send any commands into the SIM card.

User avatar
arno_nym
 
Posts: 6
Joined: Mon Oct 20, 2014 7:55 pm

Re: Sim Card Reader

Post by arno_nym »

Well, I'm not using FTDI, just the serial port! Sorry, I assumed that was clear from my post...

User avatar
Franklin97355
 
Posts: 23939
Joined: Mon Apr 21, 2008 2:33 pm

Re: Sim Card Reader

Post by Franklin97355 »

Could you create a schematic of the circuit you are using?

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Sim Card Reader

Post by adafruit_support_mike »

Hi Franklin - the schematic is linked a couple of posts up.

@arno_nym: You probably did mention the Serial connection, but it's easy to get lost in details during the debugging process.

If you aren't using the FTDI TX signal, remove R4 and disconnect pin 4 on the CD4049. As it stands now, you have the output of that inverter connected while the input is floating. That almost always causes pain.

While you're at it, connect pins 5 and 9 to GND, and make sure pins 4 and 10 are open. The older logic families are notorious for misbehaving if the unused gates aren't battened down properly.

User avatar
arno_nym
 
Posts: 6
Joined: Mon Oct 20, 2014 7:55 pm

Re: Sim Card Reader

Post by arno_nym »

Oh boy...

I grounded all open inputs, which changed nothing, then I bought the 74HC04 and rebuilt the circuit which... didn't change anything!

Then I figured out in a last desperate attempt that it DOES work on windows with the executable package! So it's a software issue, which for some reason never crossed my mind. (i.e. the circuit probably also works with a CD4049...)

Now, what's going wrong?
I'm using Linux Mint 16 Mate and have the following installed:
python-serial 2.6-1
python-wxgtk2.8
python-wxtools
wx2.8-i18n

I changed line 74 in pySIMserial.py from

Code: Select all

s = "/dev/cu.PL2303-3B1\t"
to my actual serial port

Code: Select all

s = "/dev/ttyS5\t"
I'm also in the dialout group.

The behaviour and error output is still the same as the above posted.
Am I missing something?

User avatar
arno_nym
 
Posts: 6
Joined: Mon Oct 20, 2014 7:55 pm

Re: Sim Card Reader

Post by arno_nym »

And, apart from that: Is there any possibility to access the SMS messages from the sent and/or drafts folder? I can only see the inbox...

Thanks a million

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Sim Card Reader

Post by adafruit_support_mike »

I'm afraid we're beyond the limits of what I know about the software.

If the Windows version works, we can assume your hardware is okay.

Try opening a connection to the serial port from the command line with `screen` to make sure that works, and try doing a loopback test from a script.. put a jumper between the TX and RX lines, write output, and check to see if it returns on the input.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”