Anyone awake in the early 2000’s knows the familiar shape of those candy bar style mobile phones. IMG_20150519_190929In the Shenzhen phone markets we see tons of them. Literally, there are tons of these phone passing through the markets every day. Some are resold while others are disassembled for parts and recycled. This is where all those cheap Nokia 3310/5110 LCD shields come from. It’s great to see so much reuse and recycling.

Having all these cheap LCDs is nice, but most of the interesting and useful parts are wasted. We saw a fantastic opportunity to save a heap of phones from the recycling bin and save people a pocket full of money. We can make a positive impact on the environment if we reuse some of these phones that we are literally tripping over in the streets. Let’s make an Arduino to GSM network bridge for just a few dollars.

TIMG_20150520_103214here are already a bunch of slick Arduino shields for getting your project connected:

The low cost of this technology is pretty amazing; for around $50 USD you can connect an Arduino to the world. The problem is not that this connection is expensive, but that perfectly usable alternatives are being tossed in the recycling bin every day.

Hardware

The cheapest and most common old phone we’ve seen is the Nokia 3100. There’s no camera, no Bluetooth, no WiFi, no frills at all. Perfect! We can pick it up in the market for just a few dollars.

This is a pretty old phone and there is no guarantee it will work on a modern mobile phone network. Our test phones are confirmed to send text messages on the China Mobile network in Shenzhen. We will have to do more tests around the world. If you have tested the Nokia 3100 or similar phone in your area, please post in the comments below.

IMG_20150519_191130Before we design a PCB we’ll have to determine how everything should be connected and slap it on a breadboard.

Connection

The Nokia 3100 sports a Nokia Pop-Port connector. We can use the Nokia CA-53 Pop-Port to USB cable for communications. This is also very inexpensive. The 3100 does not actually support USB communications. Some phone models do support USB, but we are only using the USB cable as a physical interface and communicating via Nokia’s own F-Bus.

The F-Bus is a bi-directional full-duplex serial type bus running at 115,200 bit/s, 8 data bits, no parity, one stop bit (8N1). Much like a standard RS-232 serial port, F-Bus connections use one pin for data transmit, one pin for data receive and one pin for ground…The Fastbus connection on a cell phone can be interfaced with an RS-232 serial port by building a custom cable. – Wikipedia

IMG_20150519_190733Pin one of the Pop-Port is the first pin next to the charging port on the phone. There are fourteen pins, but we’re only concerned with the four contacts that connect through our USB cable: F-Bus RX (pin 6), F-Bus TX (pin 7), and ground (pin 8). Vbus (pin 5) doesn’t seem to do anything in our application, but we’ll connect it anyway.

When you look at the USB cable connector pin one is to the right. Here’s is how the  CA-53 cable breaks out the Pop-Port pins.

  • Pop-Port Vbus (pin 5) | USB 5 V (pin 1)
  • Pop-Port F-Bus RX (pin 6) | USB D+ (pin 3)
  • Pop-Port F-Bus TX (pin 7) | USB D- (pin 2)
  • Pop-Port ground (pin 8) | USB ground (pin 4)

IMG_20150519_191019Unfortunately, the 5V USB supply does not charge the battery or provide power to the device, so we’ll have to connect power via the barrel connector or run off battery. For prototyping we can just run the phone off battery power. In the final product we’ll breakout the Arduino 5 V to a small connector on the shield and make a custom cable, which is surprisingly inexpensive.

Most Arduino boards operate at 5 V, but some operate a 3.3 V like the Nokia 3100. We will have to translate the 5 V logic level to 3.3 V to protect the phone’s circuitry. It would also be nice to use a proper level shifter like the TXB0104 in our Arduino Graphic LCD shield, which would allow us to use both 5 V and 3.3 V Arduino boards without any problems. However, for the proof of concept and prototyping stage we can hack it with a simple voltage divider with our 5 V Arduino Uno.

fbus-1We can use a voltage divider to convert from 5 V to 3.3 V. We could take the lazy route and just split it in half as 2.5 V is still logic high. With a voltage divider as shown in InsideGadgets: How to use Nokia F-But to send an SMS message we can safely connect our 5 V Arduino to the 3.3 V phone. The voltage divider outputs 2.5 V to the F-Bus RX line, which is logic HIGH even though it doesn’t reach the full 3.3 V. We could have used two different resistor values, but we are using two 330 Ohm resistors for convenience.

IMG_20150519_105948For our proof of concept use used a Pax Instruments Configuration Shield, which has a nice perfboard prototyping area. I mounted a USB socket and a four pin female header for interfacing it with a small breadboard on top breadboard.  Once this works we can make more permanent solder connections on the perfboard.

Connect the voltage divider from Arduino TX (D1) to Arduino ground. Connect Vbus (USB 5 V,pin 1) to Arduino 5 V. Connect F-Bus TX (USB D-, pin 2) to Arduino RX (D0). Connect F-Bus RX (USB D+, pin 3) to the middle of the voltage divider. Connect F-Bus ground (USB ground, pin 4) to Arduino ground.

Communication

You may notice the strange signals on the oscilloscope in the photograph. We spent a while debugging this only to learn our cable had a broken ground connection. When debugging, always check your continuity and voltages.

In our first setup the phone’s F-Bus TX is connected to both the Arduino RX pin and the serial converter chip’s TX pin. Also, F-Bus RX is connected to both the Arduino TX and the serial converter chip’s RX pin. This means anything the Arduino transmits to the phone is viewed in the serial terminal. We will get some strange characters in our terminal, but everything should work okay.

We could run into some power and reliability issues when F-Bus is being pulled HIGH while the serial converter chip is trying to transmit and pull that same line LOW. From what we see on the oscilloscope there is an effect, but the system works anyway. Serial is pretty robust like that.

Using the following code from InsideGadget we can get the phone to return some information about its hardware and software. Just make sure the phone is disconnected or it will interfere with the flashing process.

byte msg[] = {
    0x1E, 0x00, 0x0C, 0xD1, 0x00, 0x07, 0x00, 0x01, 0x00, 
    0x03, 0x00, 0x01, 0x60, 0x00, 0x72, 0xD5 };
void setup() {
    Serial.begin(115200);
    delay(1000);
}

void loop() {
    // Initialise the F-bus
    for (int z = 0; z < 128; z++) {
    Serial.write(0x55);
    }
    Serial.println("");
    delay(100);
    // Send our command
    for (int x = 0; x < (sizeof(msg) / sizeof(byte)); x++) {
        Serial.write(msg[x]);
    }
    Serial.println("");
    // Wait for a reply
    while (1) {
        while (Serial.available() > 0) {
            int incomingByte = Serial.read();
            Serial.print(incomingByte, HEX);
            Serial.print(" ");
        }
    }
}

As expected we get:
1E C 0 7F 0 2 D1 0 CF 71
1E C 0 D2 0 3A 1 0 0 3 56 20 30 36 2E 31 31 20 20 20 20 20 A 31
37
2D 30 35 2D 30 35 A 52 48 2D 31 39 A 28 63 29 20 4E 6F 6B
69 61 2E 20 20 20 20 20 20 20 20 20 20 20 20 20 0 1 40 51 AB

You can past these HEX values into an HEX to ASCII converter to see what we get. Here is the breakdown:

56 20 30 36 2E 31 31 is the software version number “V 06.11”
31 37 2D 30 35 2D 30 35 20 is the date code “17-05-05”
52 48 2D 31 39 20 is the hardware revision “RH-19”
28 63 29 20 4E 6F 6B 69 61 2E is the copyright notice “(c) Nokia.”

IMG_20150519_191548Now that we can communicate with the phone we can improve the hardware setup by using a second serial port and soldering more permanent connections. The AltSoftwareSerial Library allows the Arduino to communicate with the phone over a second serial port. On the Arduino Uno this library always uses Arduino pin D8 for RX and D9 for TX. Since we used the Configuration Shield we can just desolder the jumpers on pins D0 and D1 and reroute them to D8 and D9. We flash the code below onto the Arduino with this new hardware configuration. Since the phone is no longer attached to the Arduino RX and TX pins we do not need to disconnect the phone.

// Notes
// China Mobile SMS Center: +86-13800100500
//
// AltSoftSerial always uses these pins:
//
// Board Transmit Receive PWM Unusable
// ---- ------- ------ ------------
// Arduino Uno 9 8 10
// Arduino Leonardo 5 13 (none)
// Arduino Mega 46 48 44, 45
// Wiring-S 5 6 4
// Sanguino 13 14 12
//
// For Uno connect Arduino pin D9 to F-Bus RX
// Connect Arduino D8 to F-Bus TX</code>

#include &lt;AltSoftSerial.h&gt;

AltSoftSerial altSerial;

// Message arrays
void setup() {
    Serial.begin(115200);
    delay(1000);

    altSerial.begin(115200);
    delay(1000);
}

void loop() {
    DEBUG_PRINTLN("&lt;loop()&gt;");
    prepare();
    delay(100);
    Serial.println("");
    printHWSW();
    Serial.println("");
    DEBUG_PRINTLN("&lt;/loop()&gt;");
    delay(4000);
}

void prepare() {
    for (int i = 0; i &lt; 128; i++) {
        altSerial.write(0x55);
    }
}

void send(byte message[], int sizeArray) {
    for (int i = 0; i &lt; sizeArray; i++) {
        altSerial.write(message[i]);
    }
}

void printHWSW() {
    byte hwsw[] = { 0x1E, 0x00, 0x0C, 0xD1, 0x00, 0x07, 0x00, 
        0x01, 0x00, 0x03, 0x00, 0x01, 0x60, 0x00, 0x72, 0xD5 }; // get HW and SW info
    byte returnMessage[500];
    send(hwsw,sizeof(hwsw));
    delay(50);
    for (int i = 0; altSerial.available() &gt; 0; i++) {
        byte incomingByte = altSerial.read();
        returnMessage[i] = incomingByte;
    }
    Serial.println();
    Serial.print("Software: ");
    for (int j = 10; j &lt; 18; j++) {
        Serial.write(returnMessage[j]);
    }
    Serial.println();
    Serial.print("Date: ");
    for (int j = 23; j &lt; 31; j++) {
        Serial.write(returnMessage[j]);
    }
    Serial.println();
    Serial.print("Hardware: ");
    for (int j = 32; j &lt; 37; j++) {
        Serial.write(returnMessage[j]);
    }
    Serial.println();
    Serial.print("Copyright: ");
    for (int j = 38; j &lt; 48; j++) {
        Serial.write(returnMessage[j]);
    }
}

void testFun() {
    byte getVer[] = { 0x1F, 0x00, 0x04, 0x79, 0x00, 
        0x12, 0x02, 0x01, 0x02, 0x06, 0x00, 0x56, 0x20, 0x30, 0x36, 0x2E, 0x30, 0x30, 
        0x0A, 0x48, 0x46, 0x55, 0x32, 0x00 }; // get HW and SW info
    byte returnMessage[214];
    send(getVer,sizeof(getVer));
    for (int i = 0; Serial.available() &gt; 0; i++) {
        byte incomingByte = Serial.read();
        returnMessage[i] = incomingByte;
    }
    Serial.println();
    for (int j = 0; j &lt; sizeof(getVer); j++) {
        Serial.write(returnMessage[j]);
    }
}

For the first few iterations you’ll see a bit of junk in the serial terminal but then you should see something like this:

Software: V 06.11 
Date: 17-05-05
Hardware: RH-19
Copyright: (c) Nokia.

The sketch could be improved by searching through the byte stream and picking out the right section of bytes. The code above just assumes the hardware/software information begins at byte ten.

The next step is to send and SMS. I’ve tried the code in Ilias Giechaskiel’s post without success. I do not have an Arduino Mega, so I tried his code with the AltSoftwareSerial library. Here are my modifications with my phone number edited for privacy:

/* Phones should have the +XX country code*/
#define SMSC “8613800100500” // China Mobile SMSC according to Google
#define RECIPIENT “01973752YYYY” // YYYY replaces my actual phone number
#define TEXT “Sending texts from my Arduino is awesome!”
#include <AltSoftSerial.h>
AltSoftSerial phone;

This returns the following on one line. However, the phone does note send a SMS message.

1E 0 C 2 0 58 0 1 0 2 0 0 0 55 55 1 2 4C 
11 0 0 0 0 4 82 C 1 8 C 91 10 79 73 25 93 
74 82 C 2 7 6 91 68 31 8 10 0 0 80 28 24 
24 D3 B2 9B 9C 76 9F 41 F4 32 9E 3E 7 99 
E5 EF 36 A8 9D 7 5 E5 E4 7A DA FD 6 A5 E7 
A0 F0 BD 3C 7F B7 CB 21 8 4 1 A9 1 60 A5 90

This is an interesting project and I would like to learn more about controlling these phones. Form here I will have to dig deeper into other people’s code to figure this out. Any feedback or ideas are welcome.

How can I help?

If there is interest in making an Arduino shield for connecting with the Nokia 3100, I would like to make a small batch of kits including a Nokia 3100 phone, assembled shields, custom power cable, CA-53 data cable. It would probably be a developer kit for around $20 in our store’s developer section. If you are interested, please comment below, so I can get an approximate head count.

The current state of F-Bus Arduino software sucks. An easy to use Arduino library will be necessary to bring this to normal people. Please share this post with anyone you think may be interested in helping out. This is just something I’m doing for fun, so the software will likely take a very very long time if it’s only me.

Any feedback would be great. I could use some help specifying what should be on the shield. Here are some outstanding questions:

  • Should the shield be for a specific Arduino board or be configurable? The AltSoftwareSerial library uses specific pins for different Arduino boards.
  • Is it fine to have the phone and serial-to-USB chip both connected to the Arduino RX/TX lines?
  • Do we need the level shifters?
  • Is there a better Nokia cable that also provides power?
  • The Nokia 3100 needs a battery to run even with the power cable inserted. Is there a way around this?
  • Is there a better target phone?

Thanks for reading this far. I hope we can work together to make this a cheap product that everyone can have. See you in the forums.

Resources