Shopping Cart

Posts

Interfacing Arduino to a Cellular Phone

Motorola RAZR talks to Arduino

Motorola RAZR talks to Arduino


One of the main motivations for adding asynchronous CDC support code to rev.2.0 of USB Host Library was to be able to use cell phones in Arduino projects – establish simple data exchange via SMS, take pictures or connect to the Internet. Second hand phones are inexpensive yet quite capable. Also, m2m (machine to machine) SIM cards start at $4-$6/mo, some even allow for free incoming SMS. All that makes a cell phone an attractive communication option for hobby projects. In this post, I will be talking about basics of cell phone control using data port and AT commands. I will also present simple terminal emulator sketch – to use the code you will need an Arduino board, USB Host Shield, as well as USB Host Shield 2.0 library.

Modern (<10 year old) phones have standard GSM chip interface implemented and accessible via so-called "data port". The oldest phones implement TTL level asynchronous serial interface by means of "custom" USB data cable, which is just proprietary connector on one end, standard USB connector on the other end, and USB-to-serial converter chip (almost always Prolific PL2303) between them. Newer cell phones have USB-to-serial converter built-in. Motorola phones usually terminate data port on standard mini-USB connector, others, like Samsung and Sony Ericsson, use proprietary cable. The USB-to-serial converter in these phones is almost always standard CDC ACM type.

Many functions of the phone can be accessed by AT commands, similar to commands used to control Hayes phone modems. Standard GSM commands are defined in 3GPP TS 07.07 (look for the latest version, which is 7.8.0). Cell phone manufacturers also define their own AT commands. In documentation AT commands are usually presented in uppercase, however, most phones accept lowercase just as well. A command shall be followed by CR,LF (usually Enter key). If a command is accepted, OK is returned, along with response. If command is not recognized, ERROR is returned. Some commands will be accepted in certain phone states and rejected in others.

There are several variants of invoking each command:

  1. Execute This variant is used for commands which require no parameters. The format is ATcommand. For example, the following command returns power source and battery charge level:

    AT+CBC

    +CBC: 2,66

    OK

    The response means that a phone is powered from external power supply (2) and battery level is 66 percent.

  2. Test This variant is used to query parameters and their values for the command. The format is ATcommand=?.

    AT+CIND=?
    +CIND: ("Voice Mail",(0,1)),("service",(0,1)),("call",(0,1)),("Roam",(0-2)),("signal",(0-5)),("callsetup",(0-3)),("smsfull",(0,1))

    OK

    This command outputs all indicators available on the phone screen, and their possible values.

  3. Get This variant is used to query current settings for the command. The format is ATcommand?.

    AT+CIND?
    +CIND: 0,1,0,0,4,0,0

    OK

    Comparing to output of previous “Test” variant of the same command we can see that “Service” indicator on the phone screen is on and “signal” indicator is at level 4.

  4. Set This variant is used to change settings for the command. The format is ATcommand=param,param....

    AT+CKPD="1"
    OK

    This command simulates a keypress on phone keypad. The key pressed is number “1″.

  5. Unsolicited response is output of some event other than command result. The format is +COMMAND:result. It is the same as command response sans command itself. Take a look at the following example:

    A +CMER command enables or disables sending of unsolicited result codes in the case of key pressings, display changes, and indicator state changes. The parameters for this command are as follows:

    AT+CMER=?
    +CMER: (0,3),(0,1,2),(0),(0,1,2),(0)
    OK

    First parameter sets output mode, next three parameters turn output on or off for keypad, display and indicator. Last parameter controls buffering. On Motorola RAZR, the default state of this command is as follows:

    AT+CMER?
    +CMER: 0,0,0,0,0
    OK

    which means all responses off. Now, if we turn reporting on and set keypad to on:

    AT+CMER=3,1,0,0,0
    OK

    and start pressing buttons on the phone, we will see the following:

    +CKEV: "E",1
    +CKEV: "E",0
    +CKEV: "1",1
    +CKEV: "1",0
    +CKEV: "2",1
    +CKEV: "2",0
    +CKEV: "3",1
    +CKEV: "3",0
    +CKEV: "E",1
    +CKEV: "E",0

    Here, “E” means “Red” button (the one used to turn phone on/off, terminate a call, abort an action and many other things), “1″, “2″, and “3″ are numerical buttons, and number after the comma means “press” if 1 and “release” if 0. It is now evident that I first pressed “Red” button to turn screen on, then pressed “123″ and then pressed “Red” button again to erase the digits.

The following sketch is a simple terminal program. Only main loop is shown, Full text is available in examples directory on gitHub. Compile it, load, attach your phone to the USB host shield and open the terminal window. If a phone is detected successfully, sketch outputs configuration descriptor and waits for keyboard input.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
void loop()
{
    Usb.Task();
 
    if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
    {
       uint8_t rcode;
 
       /* reading the keyboard */
       if(Serial.available()) {
         uint8_t data= Serial.read();
         /* sending to the phone */
         rcode = Acm.SndData(1, &data);
         if (rcode)
            ErrorMessage<uint8_t>(PSTR("SndData"), rcode);
       }//if(Serial.available()...
 
       delay(50);
 
        /* reading the phone */
        /* buffer size must be equal to max.packet size */
        uint8_t buf[32];
        uint16_t rcvd = 32;
        rcode = Acm.RcvData(&rcvd, buf);
         if (rcode && rcode != hrNAK)
            ErrorMessage<uint8_t>(PSTR("Ret"), rcode);
 
            if( rcvd ) { //more than zero bytes received
              for(uint16_t i=0; i < rcvd; i++ ) {
                Serial.print(buf[i]); //printing on the screen
              }
            }
        delay(10);
    }//if( Usb.getUsbTaskState() == USB_STATE_RUNNING..
}

Lines 10-16 contain sending part of the terminal. Keyboard buffer is checked and if not empty, a character is read and sent to the phone ( line 13, Acm.SndData()). The rest of the loop() is reading the phone and it is a little more complicated.

When USB host sends IN transfer request to the phone, it doesn’t know how much data will be received. It could be one byte or it could be a big packet. That’s why the buffer allocated in line 22 must be equal to the maximum possible chunk of data, i.e. endpoint’s Max.packet size. Most phones have Max.packet size of 32 bytes, one notable exception being Samsung (64 bytes). If you see strange symbols and occasional Arduino resets while outputting large chunks of data, check Max.packet sizes of bulk endpoints and increase buffer size accordingly.

The request is sent in line 24. One important property of Acm.RcvData() function is that it returns actual number of bytes received from endpoint. The loop in lines 28-32 uses rcvd as a loop counter; this way, only part of the buffer filled during the transfer will be printed.

Now let’s start our terminal. Once a terminal session is open, commands can be entered from the keyboard. To check if connection is live, type at and press Enter. If phone is alive, you should see it replying with OK. The next command to try is AT+CLAC. This command outputs all supported commands. Other commands can be tried “by hand”; also, it is possible to get key codes with AT+CMER, as was described earlier.

As cool as it may look, entering commands from the keyboard is not very useful for automation. It is desirable to have functions to call numbers, send and receive SMSes and browse the Internet. Luckily for us, such software has already being developed. There are several GSM shields on the market, and GSM/GPRS modules these shields are based on are almost identical to GSM phones. For example, I was able to follow most part of this tutorial using Motorola RAZR phone. Some commands are different but most work. Many commands described on this page also work. Finally, there is very well written GSM Playground Arduino Library, which can easily be modified to use USB methods to send/receive data to the phone. I’m planning on looking into it after finalizing new USB Host library.

Finally, I want to talk a little about compatibility. I checked this sketch with Motorola RAZR, Motorola V220 and Samsung A-777. Motorola phones work out of the box, Samsung requires changing buffer size. I also tried Sony Ericsson TM-506 and TM-717 – the configuration descriptor in these phones is very complex and the Init() method won’t initialize them correctly. This will be fixed in the future. I’m also curious about other phones – please let me know if your phone worked with this sketch.

Oleg.

No related posts.

222 comments to Interfacing Arduino to a Cellular Phone

  • taz

    helo oleg..
    thanks for ur respond..

    does the arduino and gsm modem can stand along?

  • reann

    hi oleg..
    yeah can we use this arduino board and usb host shield to interface it to our gsm modem(usb modem)?
    cause we have this usb modem and we would like it to be our transceiver and we wanted to interface it to microcontroller.And we are hardly find way to interface it since the modem is not serial.

  • reann

    actually we bought a Globe Tatoo broadband (a usb type modem) hence it is cheap and available in our place.

  • reann

    and may i know oleg of how can we identify the device if it is a CDC ACM type,
    thanks oleg
    hoping for your response

  • taz

    .hi oleg..
    can i ask again ..does the gsm modem and arduino works without PC..
    looking forward for your reponse

    • Peter

      @Taz
      From the moment you transfer your sketch (program) to arduino, it’s completely independent from the PC.
      For instance, transfer the example program Blink (the very basic) to arduino, then disconnect arduino from PC. The led (in the arduino board) still flashes which means the program you transferred is running.

  • Andy

    I don’t see any mention of iPhones. Does this work with iPhones or is there something making iPhone support difficult?

  • rej

    …Gud day
    .im having similar project with reann..
    I used the huawei E153 a usb modem.
    i already tested the modem in the hyper terminal and it can send and receive SMS message.
    i want to get rid of the pc instead I want to use the micro-controller!
    my problem is the interfacing between them.
    can i use this arduino to communicate between them via serial com..?
    and how about the programmer?

    • Don

      Rej, do u have AT commands for Huawei E153? Im interfacing E1762, probably you can share to me, i want to try if this modem can be hacked into arduino as well. thanks

  • PaulF

    Hi Oleg,

    I just wanted to let you know that I tried it on a Verizon razr v3m and it doesn’t recognize the device.
    As a test, I tried it with an older razr from T-Mobile and it did work. Linux works with both devices, but the v3m uses a vendor-specific class.
    I’ve copied the lsusb output here: http://pastebin.com/qnGpcfC8

    I don’t have time today, but I’m a programmer so I’ll likely fix it myself and get back to you some time soon.

    Thanks for the great work, this is truly amazing.
    Paul

  • TimS

    I too just tried it on my Verizon v3m and get an “OSCOKIRQ failed to assert” error. When someone figures this out, please post the fix.
    This looks like a great way to interface.

  • TimS

    I got the USB Host shield to initialize with the following output using acm_terminal:

    Start
    ACM Init
    Addr:1
    NC:1
    Conf.Val: 01
    Iface Num: 00
    Alt.Set: 00
    Endpoint descriptor:
    Length: 07
    Type: 05
    Address: 81
    Attributes: 03
    MaxPktSize: 0040
    Poll Intrv: 20
    Conf.Val: 01
    Iface Num: 01
    Alt.Set: 00
    Endpoint descriptor:
    Length: 07
    Type: 05
    Address: 82
    Attributes: 02
    MaxPktSize: 0040
    Poll Intrv: 00
    Conf.Val: 01
    Iface Num: 01
    Alt.Set: 00
    Endpoint descriptor:
    Length: 07
    Type: 05
    Address: 02
    Attributes: 02
    MaxPktSize: 0040
    Poll Intrv: 00
    Conf:1
    ACM configured
    Ret: FF
    Ret: FF
    Ret: FF
    Ret: FF
    Ret: FF
    Ret: FF
    Ret: FF

    But I can’t talk to the v3m. I am able to connect directly to the v3m and a terminal program and execute commands, so I feel that the phone is talking. But I am having trouble figuring out why the USB Host Shield won’t talk to the v3m. Any insight would be appreciated.

    • AaronM

      I have been able to connect my V3m and communicate. I used this guide(http://hacktherazr.com/guides/verizon/programming) to perform a seem edit and unlock some features on the phone(USB transfer and Dialup networking).I still get unauthorized charger, I am not sure if that can be disabled.

      Start
      ACM Init
      Addr:1
      NC:2
      Conf:1
      ACM configured
      AT
      OK
      AT+GMM
      +GMM: Motorola CDMA V3m Phone

      OK

  • TimS

    The shield I’m using is the Sparkfun. I jumpered output 7 to Rst per their tech support and acm term sees the board, but barely. Hub-demo does not see the board.When I try and type commands into acm-term they are echoed back very slowly and missing the last character, which is appended on the next command I enter. The board seems to pass the board-qc test. Anyone have any ideas? I want to get it working or send it back. BTW, I have ordered one of Oleg’s boards.

  • TimS

    OK, I purchased Oleg’s board and the results with the V3M are the same. It doesn’t want to respond to any commands, yet I can enter the commands directly through a terminal program connected to the V3m with a usb cable and it works fine. Anyone have any ideas?

  • TimS

    When I run hub demo I only get “Start”. When I run acm_terminal, I get

    Start
    ACM Init
    getDevDescr:D

    If I unplug and replug the V3m, sometimes I can get the output like in my Feb 8 posting. But that’s as far as I get. I can talk to the V3m directly with a terminal program over USB and it will even send an SMS message, so it seems to be alive.

    • D means device is not answering, which often indicates power issues. Which Arduino board are you using and how do you power it – external supply, USB? Do you have a multimeter – I’m wondering if you have 5V on VBUS?

      Hub_demo has very long wait time, use USB_Desc instead.

      • PaulF

        You’re definitely correct in saying the device is not answering.

        It turns out that the V3M is not an ACM device like the other razrs — it identifies as a moto-modem on linux.
        Linux driver source: http://lxr.linux.no/linux/drivers/usb/serial/moto_modem.c

        After being plugged in for a few seconds it says “Unauthorized Charger” on the phone screen. The supply voltage is 4.9 volts with the phone attached. It appears that if it doesn’t get initialized, it stops talking.

  • TimS

    I’m using a 328 Duemilanove with your USB hub. I measured the 5v output and it was 4.86v. I plugged in an external power supply to the Duemilanove and the voltage is now right at 5.01v.

    USB_Desc gives no response, just “Start”. I get the “Unauthorized Charger” on the phone screen, just like PaulF does. Like he says, this V3m seems to be a different bird from the other razrs. How can I troubleshoot this? I have a good cheap plan with Verizon on the V3m and would really like to use it.

  • Paul Furtado

    I was visiting a relative this weekend who told me they just got a new phone and they ended up giving me their old phone – a Motorola E815 which turns out to be an ACM device and runs the same firmware as the older Razr. I left a acm terminal sketch running for a long time and got a ton of errors
    Most errors are: Ret: FF
    Randomly a: Ret: 01
    Also, many: SndData: 04

    Also notable: when plugging it into a linux computer, it beeps and the screen lights up – this never happens on the host shield.

    The descriptors from the USB desc sketch: http://pastebin.com/GPWt3BXi
    The extended descriptors from “lsusb -v”: http://pastebin.com/KzpvYXuB

    My bet is that the problem is related to the resets indicated in this dmesg output:
    [3052040.360054] usb 7-2: new full speed USB device using ohci_hcd and address 108
    [3052040.576292] cdc_acm 7-2:1.0: ttyACM0: USB ACM device
    [3052041.351740] usb 7-2: reset full speed USB device using ohci_hcd and address 108
    [3052041.565227] cdc_acm 7-2:1.0: ttyACM0: USB ACM device
    [3052041.772705] usb 7-2: reset full speed USB device using ohci_hcd and address 108
    [3052041.957153] cdc_acm 7-2:1.0: ttyACM0: USB ACM device

    Any thoughts on this?

    Also, if I can get this E815 to work then I don’t need the V3M and will gladly ship it to you.

    • Can you talk to it at all? Or all you’re getting are errors? 04 is just NAK, you can simply repeat the transfer. You can also try and insert some delays after the transfer. I haven’t tried to run a phone for a long time, maybe it goes to sleep?

  • Max Nielsen

    I’m trying Huawei E180 works nice on XP Pincode off.
    On USB HOST with pl2303 i get Ret: 0D a lot off them.

  • Hanns

    Hi Oleg,

    I tried to run this sketch with an Arduino Uno and a Blackberry Pearl, but without success. The Serial Monitor only ever contains:

    Start
    ACM Init
    Addr:1
    NC:1

    If everything initializes correctly, what all should be seen in the Serial Monitor?

  • Mike

    Hey oleg,

    I’ve been working on automating the acm_terminal program so it will send and receive commands without keyboard input. Is there something about the methods SndData() and Rcvdata() that would prevent them from being used in sub functions? At the moment, I have a function for sending “at” and a function for listening for the response from my razr.

    thanks,

    Mike

  • Mike

    Ok sounds good. It seems now that when I receive data from the phone, it returns things from the last data transmission as well.

    pseduocode

    global array buf[]

    loop(){

    functionSendAT(){
    results:
    AT
    OK}

    unlockPin(){
    AT+CPIN=”0000″
    OK

    AT <- seems to be leftover from the first function
    OK}
    }

    When I monitor whats going via the serial monitor, it seems like when the phone is returning old information. Right before I use Acm.rcvdata(&rcvd,buf) I run the buf[] array through a loop to fill it with NULL's, but this doesn't not seem to fix the issue.

    thanks for everything

    -Mike

  • florent

    Hi!
    I’ve tried the code with my Sony Ericsson k810i and here is what I get in the serial monitor:

    Start
    ACM Init
    Addr:1
    NC:1
    Conf.Val: 03
    Iface Num: 01
    Alt.Set: 00
    Endpoint descriptor:
    Length: 07
    Type: 05
    Address: 81
    Attributes: 03
    MaxPktSize: 0010
    Poll Intrv: 10
    Conf.Val: 03
    Iface Num: 03
    Alt.Set: 00
    Endpoint descriptor:
    Length: 07
    Type: 05
    Address: 84
    Attributes: 03
    MaxPktSize: 0010
    Poll Intrv: 10
    Conf.Val: 03
    Iface Num: 02
    Alt.Set: 00
    Endpoint descriptor:
    Length: 07
    Type: 05
    Address: 02
    Attributes: 02
    MaxPktSize: 0040
    Poll Intrv: 00
    Conf.Val: 03
    Iface Num: 02
    Alt.Set: 00
    Endpoint descriptor:
    Length: 07
    Type: 05
    Address: 82
    Attributes: 02
    MaxPktSize: 0040
    Poll Intrv: 00
    Conf.Val: 03
    Iface Num: 04
    Alt.Set: 00
    Endpoint descriptor:
    Length: 07
    Type: 05
    Address: 05
    Attributes: 02
    MaxPktSize: 0040
    Poll Intrv: 00
    Conf.Val: 03
    Iface Num: 04
    Alt.Set: 00
    Endpoint descriptor:
    Length: 07
    Type: 05
    Address: 85
    Attributes: 02
    MaxPktSize: 0040
    Poll Intrv: 00
    Conf.Val: 03
    Iface Num: 06
    Alt.Set: 01
    Endpoint descriptor:
    Length: 07
    Type: 05
    Address: 06
    Attributes: 02
    MaxPktSize: 0040
    Poll Intrv: 00
    Conf.Val: 03
    Iface Num: 06
    Alt.Set: 01
    Endpoint descriptor:
    Length: 07
    Type: 05
    Address: 86
    Attributes: 02
    MaxPktSize: 0040
    Poll Intrv: 00
    Conf.Val: 03
    Iface Num: 09
    Alt.Set: 01
    Endpoint descriptor:
    Length: 07
    Type: 05
    Address: 09
    Attributes: 02
    MaxPktSize: 0040
    Poll Intrv: 00
    Conf.Val: 03
    Iface Num: 09
    Alt.Set: 01
    Endpoint descriptor:
    Length: 07
    Type: 05
    Address: 89
    Attributes: 02
    MaxPktSize: 0040
    Poll Intrv: 00
    Conf.Val: 03
    Iface Num: 09
    Alt.Set: 02
    Endpoint descriptor:
    Length: 07
    Type: 05
    Address: 09
    Attributes: 02
    MaxPktSize: 0040
    Poll Intrv: 00
    Conf.Val: 03
    Iface Num: 09
    Alt.Set: 02
    Endpoint descriptor:
    Length: 07
    Type: 05
    Address: 89
    Attributes: 02
    MaxPktSize: 0040
    Poll Intrv: 00
    Conf:3
    SetControlLineState: 05
    OnInit:5

    None of the comands work, and I don’t receive the “ACM configured”… Any idea?

  • Philipp

    Hi Oleg,

    is it possible to get this shield work with my nokia 6230i for AT Commands ?
    i have tried with the AC_Terminal and get this

    Start
    ACM Init
    Addr:1
    NC:1
    Conf:1
    SetControlLineState: 05
    OnInit:5

    on pc at commands works fine. is there any solution or make i something wrong ?

  • alkml

    Hi Oleg,

    I ‘ve recently purchased the shield. I connected everything, uploaded the acm code and read below lines nothing more from the serial monitor.

    Start
    ACM Init
    Addr:1
    NC:1
    Conf:1
    ACM configured

    When I enter AT+CBC, it returns below lines.

    SndData: 04
    SndData: 04
    SndData: 04

    What am I doing wrong? Thanks for the help.

    • Hi,

      Some phones want to be connected to the network in order to talk. Such phone would pass initialization but won’t respond to any commands. Check if your phone is indeed talking – the easiest way is to connect it to a PC and send commands via terminal.

      What kind of phone do you have?

      Oleg.

      • alkml

        Hi Oleg,

        Setup includes a network connected phone. After your reply I checked the phone via hyper terminal by pc. It seems that I can comminicate over the pc. My phone is LG KG 320.
        My primary goal is to use the board to send sms.

        • what happens when you send ‘at’ and press ‘Enter’ from Arduino? Also, try to call the phone with terminal open and see if you can get RING message from the phone.

          • alkml

            Hi again,

            When I connect the phone directly to pc via hyper terminal, I can call another phone which I’ve never tried before however I can’t achieve over arduino.

            Here what I observe, when I connect directly to the phone over Com3 which is the port I use to connect to arduino, I get the response the message that I wrote in my first message. I can call when I select the modem itself as a port. I’m curios if the problem is the port while using the arduino. I hope I was clear. Thanks for your time.

          • I’m trying to figure out if phone modem needs some commands sent to it before it starts talking. Windows is likely doing it automatically. What country are you in and which network are you using?

  • ganesh

    hi,
    I am creating a robot using the arduino mega and I would like to be able to control said robots movements using a cellphone. I was wondering if u could give me a quick run through of how it would be done.

    Here is the basic description of the robot:
    the robot is controlled by a mobile phone that makes a call to the mobile phone attached to the robot.
    The robot is a 2-wheel drive. The brains of the robot is the arduino mega board. I’d like the controller to be able to conrol the robots movements, forward, backward, left, and right and also control some autonomous routines.

    Thanks for the help!

  • alkml

    Hi Oleg,

    I’m from Turkey, Turkcell.

    • Try to find out if endpoints used by Windows are the same initialized by Arduino driver – there is a remote possibility that the phone has several interfaces and the driver initializes the wrong one.

  • alkml

    What is your suggestion?

    • Install USB analyzer on a PC and find out which endpoints are used for PC< ->phone communication. Then uncomment the diagnistic in Arduino ACM driver -> https://github.com/felis/USB_Host_Shield_2.0/blob/master/cdcacm.cpp#L236 , recompile, run and compare endpoint numbers with ones from a PC.

      • alkml

        Hi Oleg,

        Here what I found,

        USB analyzer gave two end points,
        1- Endpoint descripter 81 In, Bulk, 64 bytes, Endpoint address 81H 1 In
        2- Endpoint descripter 02 out, Bulk, 64 bytes, Endpoint address 02H 1 Out

        and from serial monitor

        Start
        ACM Init
        Addr:1
        NC:1
        Endpoint descriptor:
        Length: 07
        Type: 05
        Address: 81
        Attributes: 03
        MaxPktSize: 0020
        Poll Intrv: 80
        Endpoint descriptor:
        Length: 07
        Type: 05
        Address: 83
        Attributes: 02
        MaxPktSize: 0040
        Poll Intrv: 00
        Endpoint descriptor:
        Length: 07
        Type: 05
        Address: 02
        Attributes: 02
        MaxPktSize: 0040
        Poll Intrv: 00
        Conf:1
        ACM configured

        I hope these are what you are asking.

        Thanks.

  • alkml

    Nothing happened new. Still I get below response.

    SndData: 04
    SndData: 04
    SndData: 04

    Furthermore I tried to implement “at+cbc” command in to the code, then nothing comes up.

  • ledDiod

    Hi,
    I have arduino adk mega and I can’t connect it with my phone,when I plug in data cabel I recived:

    Start
    ACM Init
    Addr:1
    NC:1
    Conf:1
    ACM configured
    this output and when I try to send data from phone to arduino nothing happened, but when I try send from arduino to phone arduino returned:
    SndData: 04
    I try with nokia 3600slide and nokia 6500, and I recived the same results.

  • Mercado

    Oleg, good evening. I would say it is frustrating to have a board as interesting as it this in my hand and unfortunately having to spend 90% of my time trying to solve the secrets behind the library, this is because the code is functional just for the example, when we need to do something practical, it is necessary to remake a lot things and there is absolutely a single line of a basic documentation. I’m sorry for you, that have to answer so many questions here, which could be avoided by improving the documentation (or making one) or even better, perhaps thinking a little further, make a library more enhanced with functions leaner and practical for a use with less suffering. That could popularize the use of this shield. But who knows. Is must think big for this.

  • xpwithme

    Start
    ACM Init
    Addr:1
    NC:1
    Conf:1
    ACM configured
    SndData: 04
    SndData: 04
    SndData: 04
    SndData: 04
    SndData: 04
    SndData: 04
    SndData: 04
    SndData: 04
    SndData: 04
    SndData: 04
    SndData: 04
    SndData: 04
    SndData: 04
    SndData: 04
    SndData: 04
    could you like explain 04 meaning while I connected arduino UNO R3 with Nokia cell phone.I’ve try so many times but failed ,thanks a lot!

  • Saccomat

    Dear Oleg, I was trying to use the acm_terminal code with a Sony Ericcson V800, but the Init code fails for some reason with following output:

    Start
    ACM Init
    Addr:1
    NC:1
    Conf:1
    SetControlLineState: 05
    OnInit:5

    What should I check? Thanks

  • Kapil Saraswat

    Hello! How can I use this library for the interface with nokia C1-02?

    • xpwithme

      i was troulbe in connect nokia c1-02 phone to usb host shield also

      • xpwithme

        Start

        01

        Device descriptor:
        Descriptor Length: 12
        Descriptor type: 01
        USB version: 0200
        Device class: 02
        Device Subclass: 00
        Device Protocol: 00
        Max.packet size: 40
        Vendor ID: 0421
        Product ID: 0360
        Revision ID: 0540
        Mfg.string index: 01
        Prod.string index: 02
        Serial number index: 00
        Number of conf.: 01
        Total length truncated to 256 bytes
        Configuration descriptor:
        Total length: 0162
        Num.intf: 0B
        Conf.value: 01
        Conf.string: 00
        Attr.: C0
        Max.pwr: 04

        Interface descriptor:
        Intf.number: 00
        Alt.: 00
        Endpoints: 00
        Intf. Class: 02
        Intf. Subclass: 08
        Intf. Protocol: 00
        Intf.string: 00
        Unknown descriptor:
        Length: 05
        Type: 24
        Contents: 0010010524
        Unknown descriptor:
        Length: 05
        Type: 24
        Contents: 1100010E24
        Unknown descriptor:
        Length: 0E
        Type: 24
        Contents: 06000102030405060708090A0904

        Interface descriptor:
        Intf.number: 01
        Alt.: 00
        Endpoints: 00
        Intf. Class: 02
        Intf. Subclass: FE
        Intf. Protocol: 00
        Intf.string: 00
        Unknown descriptor:
        Length: 05
        Type: 24
        Contents: 0010010524
        Unknown descriptor:
        Length: 05
        Type: 24
        Contents: AB05710524
        Unknown descriptor:
        Length: 05
        Type: 24
        Contents: 0601020904

        Interface descriptor:
        Intf.number: 02
        Alt.: 00
        Endpoints: 00
        Intf. Class: 0A
        Intf. Subclass: 00
        Intf. Protocol: 00
        Intf.string: 00

        Interface descriptor:
        Intf.number: 02
        Alt.: 01
        Endpoints: 02
        Intf. Class: 0A
        Intf. Subclass: 00
        Intf. Protocol: 00
        Intf.string: 00
        Unknown descriptor:
        Length: 04
        Type: 24
        Contents: FD000705

        Endpoint descriptor:
        Endpoint address: 81
        Attr.: 02
        Max.pkt size: 0040
        Polling interval: 00

        Endpoint descriptor:
        Endpoint address: 01
        Attr.: 02
        Max.pkt size: 0040
        Polling interval: 00

        Interface descriptor:
        Intf.number: 03
        Alt.: 00
        Endpoints: 01
        Intf. Class: 02
        Intf. Subclass: 02
        Intf. Protocol: 01
        Intf.string: 00
        Unknown descriptor:
        Length: 05
        Type: 24
        Contents: 0010010424
        Unknown descriptor:
        Length: 04
        Type: 24
        Contents: 02060524
        Unknown descriptor:
        Length: 05
        Type: 24
        Contents: 0103040524
        Unknown descriptor:
        Length: 05
        Type: 24
        Contents: 0603040424
        Unknown descriptor:
        Length: 04
        Type: 24
        Contents: FD000705

        Endpoint descriptor:
        Endpoint address: 82
        Attr.: 03
        Max.pkt size: 0040
        Polling interval: 20

        Interface descriptor:
        Intf.number: 04
        Alt.: 00
        Endpoints: 02
        Intf. Class: 0A
        Intf. Subclass: 00
        Intf. Protocol: 00
        Intf.string: 00
        Unknown descriptor:
        Length: 04
        Type: 24
        Contents: FD000705

        Endpoint descriptor:
        Endpoint address: 83
        Attr.: 02
        Max.pkt size: 0040
        Polling interval: 00

        Endpoint descriptor:
        Endpoint address: 03
        Attr.: 02
        Max.pkt size: 0040
        Polling interval: 00

        Interface descriptor:
        Intf.number: 05
        Alt.: 00
        Endpoints: 00
        Intf. Class: 02
        Intf. Subclass: 0B
        Intf. Protocol: 00
        Intf.string: 00
        Unknown descriptor:
        Length: 05
        Type: 24
        Contents: 0010010524
        Unknown descriptor:
        Length: 05
        Type: 24
        Contents: 1500010524
        Unknown descriptor:
        Length: 05
        Type: 24
        Contents: 0605060904

        Interface descriptor:
        Intf.number: 06
        Alt.: 00
        Endpoints: 00
        Intf. Class: 0A
        Intf. Subclass: 00
        Intf. Protocol: 00
        Intf.string: 00

        Interface descriptor:
        Intf.number: 06
        Alt.: 01
        Endpoints: 02
        Intf. Class: 0A
        Intf. Subclass: 00
        Intf. Protocol: 00
        Intf.string: 00
        Unknown descriptor:
        Length: 04
        Type: 24
        Contents: FD010705

        Endpoint descriptor:
        Endpoint address: 84
        Attr.: 02
        Max.pkt size: 0040
        Polling interval: 00

        Endpoint descriptor:
        Endpoint address: 04
        Attr.: 02
        Max.pkt size: 0040
        Polling interval: 00

        Interface descriptor:
        Intf.number: 07
        Alt.: 00
        Endpoints: 01
        Intf. Class: 02
        Intf. Subclass: 02
        Intf. Protocol: FF
        Intf.string: 00
        Unknown descriptor:
        Length: 05
        Type: 24
        Contents: 0010010424
        Unknown descriptor:
        Length: 04
        Type: 24
        Contents: 02060524
        Unknown descriptor:
        Length: 05
        Type: 24
        Contents: 0103080524
        Unknown descriptor:
        Length: 05
        Type: 24
        Contents: 060708E608

        Addr:1(0.0.1)

  • John

    I am planning to use Motorola V220 with USB Host Shield, and I was wondering if it is possible to do MMS with it via Arduino. V220 has built in camera. Does anyone know if it can be instructed to take a picture and send it via MMS? Perhaps a tutorial/example link?

    Thank you
    John

  • Tom

    Would it be possible to adapt this code to work with an Ethernet adapter shield to dial modem commands over the Ethernet connection? What would be the best way to implement this?

  • iris

    Hi oleg…

    is 1280 nokia can interface to microcontroller…if possible..how?

    hope you can help me….

    iris

  • AJ

    Hi Oleg,

    You menton “m2m (machine to machine) SIM cards start at $4-$6/mo, some even allow for free incoming SMS”

    Could you please eleborate on which card you’re referring to?

    I have an Arduino project where I would like to send data remotely via SMS in the USA (say 5000-10000 messages per month, no data, no calls) and am looking for the cheapest solution.

    Thanks

    A

  • Jim

    Hi Oleg. I’m trying to use a Razr V3 to control a remote test device i’ve built. Previously I triggered the device simply by ringtone but this is crude, limited and unreliable. Ideally I’d like to use the V3 to recieve texts to trigger different test states. I tried acm terminal and get what looks like (to me) a good response back but after ‘ACM Configured’ all I get is ‘Ret: FF’ repeatedly and I’m unable to issue AT commands. I loaded USB desc and this is what’s returned:

    Start
    01

    Device descriptor:
    Descriptor Length: 12
    Descriptor type: 01
    USB version: 0110
    Device class: 02
    Device Subclass: 00
    Device Protocol: 00
    Max.packet size: 40
    Vendor ID: 22B8
    Product ID: 6402
    Revision ID: 0002
    Mfg.string index: 01
    Prod.string index: 02
    Serial number index: 03
    Number of conf.: 01

    Configuration descriptor:
    Total length: 0043
    Num.intf: 02
    Conf.value: 01
    Conf.string: 04
    Attr.: C0
    Max.pwr: FA

    Interface descriptor:
    Intf.number: 00
    Alt.: 00
    Endpoints: 01
    Intf. Class: 02
    Intf. Subclass: 02
    Intf. Protocol: 01
    Intf.string: 05
    Unknown descriptor:
    Length: 05
    Type: 24
    Contents: 0001010524
    Unknown descriptor:
    Length: 05
    Type: 24
    Contents: 0103010524
    Unknown descriptor:
    Length: 05
    Type: 24
    Contents: 0600010424
    Unknown descriptor:
    Length: 04
    Type: 24
    Contents: 02020705

    Endpoint descriptor:
    Endpoint address: 82
    Attr.: 03
    Max.pkt size: 0040
    Polling interval: 0A

    Interface descriptor:
    Intf.number: 01
    Alt.: 00
    Endpoints: 02
    Intf. Class: 0A
    Intf. Subclass: 00
    Intf. Protocol: 00
    Intf.string: 06

    Endpoint descriptor:
    Endpoint address: 81
    Attr.: 02
    Max.pkt size: 0040
    Polling interval: 00

    Endpoint descriptor:
    Endpoint address: 01
    Attr.: 02
    Max.pkt size: 0040
    Polling interval: 00

    Addr:1(0.0.1)

    I also have a Razr V3R and get the same response. Using an UNO with USB shield and a 12 v 3amp PSU for the UNO.

    Any help or pointer in the right direction will be very much appreciated.

    Regards Jim.

    • Do you have a valid SIM card in the phone? Many GPRS phones won’t open a terminal session if there is no SIM.

      • Jim

        I put. in the sim from my wife’s phone. It doesn’t seem to wait for input, so most of the time when I input a command only part of it prints then there is a long pause,then back to Ret:FF At one point it did actually dial out so I don’t think it’s a connectivity issue. Seems like I was lucky and it took the whole command that time.
        Thanks for taking the time to reply Oleg

      • Jim

        Could this be a buffer issue?

  • Vanessa

    Hi,

    I am using a 5V Arduino Pro Atmega328 and a USB Host Shield 2.0. I am trying to get descriptors from an android phone and to do this I used the “USB_desc” example sketch provided for the USB Host Shield 2.0 and it did not work. It uploads without any errors but the descriptors do no print out on the console, the only thing that does print out is “Start”. The android phone does not detect that it is connected to the USB Host Shield. I tried connecting a 4GB flash drive and that too does not work. Prior to using the 5V Arduino Pro I was using a 3.3V Arduino Pro and with that one I was able to get the descriptors from the flash drive to print out. I switched to a 5V Arduino because I thought the android might be expecting 5V and that’s why it was not working with the 3.3V.

    I saw that many people posted that the solution to most problems is having an external power supply so I have that too.

    Do you know what I could be doing wrong? I would really appreciate your help.

    Thank you

    • Can you print descriptors from any other USB device? Also, try it with a standard Arduino board – 5V Pro lacks 3.3V rail so you’re feeding USB Host Shield with 5V only; consequently, it is unable to detect attached device.

      • Vanessa

        I was able to print out descriptors from a 4gb flash drive using the 3.3V Pro but not with the 5V Pro. Eventually I want to get descriptors from a device that requires 5V which is why I bought the 5V Pro. But do you suggest I don’t use the Pro and use something like the 5V Arduino Uno?

        Also as I mentioned, the 4GB flash drive worked with the 3.3V Pro but not a 32GB one. Do you know why that could be?

        • By default 3.3V Pro puts 3.3V on VBUS. Some bus-powered USB devices work off of 3.3V, some others don’t. It is possible to have 5V on VBUS while using 3.3V Pro , see here under ‘Power Options’ -> https://www.circuitsathome.com/usb-host-shield-hardware-manual

          • Vanessa

            The USB device (cell phone)I am trying to get the descriptors from requires 5V on VBUS. I have the 5V USB Host Shield 2.0 and the 3.3V Arduino Pro. Would I still have to do the same modifications explained in the hardware manual since I already have a 5V shield?

          • No, you need to do different modifications. You need to provide 5V to VBUS and eliminate 3 to 5V conversion for MAX3421E output signals. The former can be done by opening 5V VBUS jumper on the shield and connecting 5V source to VBUS pad. The latter can be achieved by connecting the shield’s 5V input pad to 3.3V.

          • Vanessa

            I want to confirm that I understand correctly. Is it okay if I source 5V to VBUS from a %v regulator. The regulator is powered by an external supply. Is there any additional components I would need if I source 5v to VBUS from a 5V regulator?

          • Yes, this is the way to do it. Just make sure VBUS is disconnected from the 5V rail of the shield (there is a jumper for it).

  • Windows or Mac PC requires virtual port connection and nokia drivers or nokia pc suite to accept AT commands. wil it not require anything from arduino??? I’m just curious.

  • Ullas

    Hi Oleg, wonderful example codes. Do you have any sample codes for 3G USB dongle? Do you foresee it being a target for development?

  • vince

    Hi Oleg,

    I’am trying to use a 3G Modem (SIM5216E) with your USB stack.
    The Modem is correctly “seen” as USB_desc.ino show all correct USB infos.
    Unfortunately theses modems do not set CLASS_ID, SUBCLASS_ID and PROTOCOL correctly (set to 0xFF, ie. vendor specific).
    In cdcacm.cpp I’ve modified the initialization with : ConfigDescParser CdcControlParser(this);
    But the modem has 5 interfaces, and only the third one accept AT command.
    What is the correct API call to select the correct interface/EndPoint ?

    Thanks for your help,
    BR,
    V.

  • scottyjr

    Hello Oleg. Thank You for your contributions.

    Using an Arduino, USB Host Shield and RAZR V3, I am attempting a project to monitor my home and, if potentially hazardous conditions are detected, have a message sent to my personal cell phone.

    Using acm_terminal, I have not been successful in communicating to the Arduino terminal from the RAZR connected to the USB Host Shield.

    I do have a SIM card installed in the phone and the phone indicates that is an unregistered SIM card.

    When the phone is connected to the USB Host Shield, and the Arduino (with or without external power) to my computer, the following is displayed it the Arduino IDE terminal:

    Start
    0705890300100A0705010200200007058202002000

    When depressing keys on the phone, nothing new displays in the terminal window.

    I ran USB_desc, the following was displayed:

    RAZR PHONE

    Device descriptor:
    Descriptor Length: 12
    Descriptor type: 01
    USB version: 0110
    Device class: 02
    Device Subclass: 00
    Device Protocol: 00
    Max.packet size: 08
    Vendor ID: 22B8
    Product ID: 4902
    Revision ID: 0002
    Mfg.string index: 01
    Prod.string index: 02
    Serial number index: 00
    Number of conf.: 01

    Configuration descriptor:
    Total length: 0043
    Num.intf: 02
    Conf.value: 01
    Conf.string: 04
    Attr.: 80
    Max.pwr: FA

    Interface descriptor:
    Intf.number: 00
    Alt.: 00
    Endpoints: 01
    Intf. Class: 02
    Intf. Subclass: 02
    Intf. Protocol: 01
    Intf.string: 05
    Unknown descriptor:
    Length: 05
    Type: 24
    Contents: 0001010524
    Unknown descriptor:
    Length: 05
    Type: 24
    Contents: 0103010524
    Unknown descriptor:
    Length: 05
    Type: 24
    Contents: 0600010424
    Unknown descriptor:
    Length: 04
    Type: 24
    Contents: 02020705

    Endpoint descriptor:
    Endpoint address: 89
    Attr.: 03
    Max.pkt size: 0010
    Polling interval: 0A

    Interface descriptor:
    Intf.number: 01
    Alt.: 00
    Endpoints: 02
    Intf. Class: 0A
    Intf. Subclass: 00
    Intf. Protocol: 00
    Intf.string: 10

    Endpoint descriptor:
    Endpoint address: 01
    Attr.: 02
    Max.pkt size: 0020
    Polling interval: 00

    Endpoint descriptor:
    Endpoint address: 82
    Attr.: 02
    Max.pkt size: 0020
    Polling interval: 00

    Addr:1(0.0.1)

    I have searched the internet and have read many previous posts describing users having problems with phone – USB Shield projects. But, beyond what suggestions I have already tried, I have not been able to come upon anything to resolve the problem I am currently having. I would appreciate any assistance in pointing me in a direction to go. Thanks – Scotty

  • scottyjr

    Thanks for responding and so quickly. I did get a SIM card. However I cannot try it now. I recently purchased the phone on ebay and it powered up fine for a couple of days then started to act a bit funky charging the battery. Now the phone won’t turn on at all. A new battery is on the way . Anxious to try it. I will report back. – Scotty

  • scottyjr

    Hello Oleg. New battery installed. Running ACM_Terminal results in the same results as previously posted. No keypad entries on the phone show in the terminal window. I attempted to send commands (AT+CBC and AT+CIND?) to the phone via the serial monitor. The commands seem to have no results returned but only show up in the serial monitor as the commands I entered. I did call the RAZR from another phone and RING RING RING showed in the serial monitor. I did run hub_demo and the same data from running Usb_desc was returned to the serial monitor. I did notice that the partial sketch that is posted on your RAZR page is not the same as the sketch that you link to at Git-Hub. Am I running the right sketch (ACM_Terminal)? – Scotty

  • scottyjr

    Still no luck, Oleg. I did enter ATE1 and then tried many other commands (AT+GMM, AT+MODE?,AT+CMGS,AT+CNUM,and a few others but no data was returned from the phone. Am I correct that the commands are sent from the Arduino IDE using the send button at the top of the IDE? Have you got any other suggestions on what I might try? Thanks for your help. – Scotty

    • You should get OK in response to any command if echo is on. A command must be terminated with CR, in Arduino IDE you must press ‘Enter’ before clicking on ‘Send’ (or stop using it and get the generic terminal like putty).

  • scottyjr

    Hello Oleg. I am now able to have two way communication between the Arduino IDE terminal and the RAZR phone. It’s not consistent but I believe that the reason for that is the terminal software. At times the characters I enter on the computer keyboard may take up to 5 seconds to appear in the terminal. Sometimes some of the characters are lost. After sending AT+CMER=3,1,0,0,0 to the phone I was able to received button presses on the phone in the terminal window.

    Thank You very much for your help. I can now move on to seeking a sketch to send text messages and manipulate it to my intended use.

    - Scotty

  • Manny

    Hi Oleg, I have a project I am working on, that requires communication with android phones (samsung s3). Does S3 supports AT_commands ?

    Thanks,
    Manny

    • I’m not familiar with this phone, sorry.

    • brok

      Hi Manny,
      I am trying to do something similar too with the galaxy S3. I can send/receive AT commands connecting the device to the laptop and runnin an hyperterminal. However, I am having issues on doing the same through the arduino. It seems that the usb is never in running state…probably is matter of which library I am using. Right now I am including the cdcacm.h included in the USB_Host_Shield library, but since I am using the arduino mega adk, I am not sure that is the correct one.

      Could you solve your problems?

  • Carlos

    Hi Oleg,

    I see most GPRS shield modems now having built in TCP/IP stack.
    You mention using the phone as a modem, how would you aproach using a normal phone trough USB conectivity and standard AT commands/ PPT connection to arduino? Where could I get the PPP/TCP IP libraries?

  • JOana

    Just a stupid question because im new at this but the message appears on the sell phone or on serial monitor??

  • Ahmad

    Hi,

    I’m wodering if we can make the following connection:
    Router —> USB ethernet network lan adapter —> Arduino USB shield —> Arduino UNO.

    In this case we don’t need the usage of ethernet shield which is expensive.

    Thanks..Regards

Leave a Reply

  

  

  



You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">