Motorola c168i Cell Phone and Propeller
Jay Kickliter
Posts: 446
I've been trying to get the propeller to interface with a Motorola c168i phone, but just can't get it to work. Using an Arduino, and this code, I can get it to send text messages. Here's my Spin code, does anyone see any glaring problems? I'd really like this to work so I can use it as a backup telemetry transmitter for my balloon project.
[url=http://][/url][url=http://][/url]
[b]CON[/b] [b]_CLKMODE[/b] = [b]xtal[/b]1 + [b]pll[/b]4x [b]_XINFREQ[/b] = 5_000_000 PHONE_TX_PROP_RCV_PIN = 14 ' Connect to ring on 2.5 mm phone connector PHONE_RCV_PROP_TX_PIN = 15 ' Connect to tip on 2.5 mm phone connector DELAY = 0.5 CONTROL_Z = 26 QUOTATION_MARK = 34 PLUS_SYMBOL = 43 [b]OBJ[/b] serial : "Simple_Serial" [b]VAR[/b] [b]long[/b] stack[noparse][[/noparse]10] [b]DAT[/b] phone_set_text_mode_command [b]byte[/b] "AT+CMGF=1", 0 ' Puts the phone in text mode phone_send_sms_command [b]byte[/b] "AT+CMGS=", 0 ' First part of command, the rest is phone number in quotes phone_shutdown_command [b]byte[/b] "AT+CFUN=0", 0 ' Turn off transmitter or phone, not quite sure phone_reset_command [b]byte[/b] "AT*SWRESET", 0 ' Resets phone and/or turns the transmitter back on at_command [b]byte[/b] "AT", 0 ' Phone should return "OK" att_internet_gateway [b]byte[/b] "121", 0 ' The phone number to send emails through cr_nl [b]byte[/b] 13, 10, 0 ' Carrige return + newline phone_number [b]byte[/b] "17576306194", 0 message [b]byte[/b] "[b]Test[/b] [b]Test[/b] 1 2 1 2", 0 [b]PUB[/b] Main Init SendSMS(@phone_number, @message) [b]PUB[/b] Init serial.init(PHONE_TX_PROP_RCV_PIN, PHONE_RCV_PROP_TX_PIN, 4800) ' Init simple_serial object serial.[b]str[/b](@at_command) ' Send an AT so phone knows what baud rate we're operating at serial.[b]str[/b](@cr_nl) ' Send carrige return, newline control characters [b]waitcnt[/b](clkfreq/2 + [b]cnt[/b]) ' Wait for phone to process command serial.[b]str[/b](@at_command) ' Send an AT again so phone knows what baud rate we're operating at serial.[b]str[/b](@cr_nl) ' Send carrige return, newline control characters [b]waitcnt[/b](clkfreq/2 + [b]cnt[/b]) ' Wait for phone to process command [b]PUB[/b] SendSMS(recipient_phone_number, message_text) serial.[b]str[/b](@phone_set_text_mode_command) ' Make sure phone is in text mode, not PDU mode serial.[b]str[/b](@cr_nl) ' Send carrige return and newline [b]waitcnt[/b](clkfreq/2 + [b]cnt[/b]) ' Pause for phone to process command serial.[b]str[/b](@phone_send_sms_command) ' Send sms preamble, AT+CMGS= serial.tx(QUOTATION_MARK) ' Send a " serial.tx(PLUS_SYMBOL) ' Send a + serial.[b]str[/b](recipient_phone_number) ' Send phone number string, eg. 15551236789 serial.tx(QUOTATION_MARK) ' Send a " serial.[b]str[/b](@cr_nl) ' Send carrige return and newline control characters [b]waitcnt[/b](clkfreq/2 + [b]cnt[/b]) ' Wait for phone to process command serial.[b]str[/b](message_text) ' Send message string serial.tx(CONTROL_Z) ' Send Control-Z character serial.[b]str[/b](@cr_nl) ' Send carrige return and newline control characters [b]waitcnt[/b](clkfreq/2 + [b]cnt[/b]) ' Make sure phone has enough time to process command before next serial.[b]str[/b](@at_command) ' Send another AT for good measure serial.[b]str[/b](@cr_nl) ' Send carrige return, and newline control characters [b]waitcnt[/b](clkfreq/2 + [b]cnt[/b]) ' Wait for phone to process command
[url=http://][/url][url=http://][/url]
Comments
The other question I have is hardware related, do you have a pull-up on the tx pin, and is the c168i 5V (inline resistor). Its not obvious from the phone library code what the pinmode sets pull-ups to, etc. simple-serial floats the tx line at the end of every char, which probably goes low, the c168i probably sees that as a start bit which may confuse it.
Thanks for the advice. If I can get this to work predictably it could be of use to a number of propeller projects. The c168i only costs $15 and you can use pre-paid cards. The OpenGPS Tracker folks use it with a PIC, and they don't appear to have any problems at all.
The rx pin, I would use 2 resistors, 1st a 4.7K resistor to 3.3V and 2nd a 1K resistor to the c168i tx
A pullup pulls the pin to +ve voltage - 3.3V for the prop, pulldown pulls to GND, both are normally 4.7K-10K range. An inline is used with the prop as a quick way to interface to 5V, often 1K is used. An inline is used when the prop is an input, in this case for the c186i tx to prop rx.
If you have a meter you could measure the voltage on the c168i rx input, just in case it has a pullup to 5v. If it is at 5v you could try a 1K inline from the prop tx to the c168i rx but I haven't had much success doing that.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my
I just took a quick look at the opengpstracker software, the way I read it says you will need the pullups.
Post Edited (Timmoore) : 8/23/2008 12:51:37 AM GMT
Being a newbie, I didn't know that such a thing was even possible. This is totally interesting. Where did you learn about this? When you get it to work, please give us an update on how you did it. I'm blown away.
Mark
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
It might be the Information Age but the Eon of Ignorance has yet to end.
I'm new myself, and just learned about this by accident. I'll post something when I get it to work with the Propeller. Right now I'm just trying to get it to send text messages, but it could also be used for receiving them. I'm just going to use it as a backup to my balloons primary location transmitter.
This looks very good! It is odd that the phone's web site does not mention the interfacing aspects.
Do you have any idea of the maximum altitude for which the cell phone will maintain a connection? The 9-11 conspiracy theory folks made quite a bit of fuss over this at one point ...
Cheers!
.. off to the shops to see if I can get one locally!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pull my finger!
Brad, please get one and try it. I know it will work, I'm just stuck. Maybe you can figure it out.
It just occurred to me that I was one able to get the phone to send a text message by hooking it up to the prop plug directly, and manually entering the command strings. Does anyone know the electrical characteristics of the signal leaving the prop plug?
What does " Start bit low, data true (0 volts = 0) and stop bit/idle high" mean? I'm away from my setup right now to test it but does this confirm Tim's suggestion that I need to putt a pull up resistor between the Propeller's transmit and the phone's receive pin? Can this be mimicked with software?
1 Add a cog that receives from the phone and outputs to debug serial port (pin30/31) and see if you are getting any response from the phone.
i.e. a cog that just does
repeat
debug.tx(serial.tx)
2. Simple serial doesn't take the tx line high until it sends the first character. I would expect the phone to get confused with the first character because of this. Either a pullup between the prop tx and +3.3V or try sending AT<cr> a third time in case the first AT is getting lost. In fact I would just send AT several more times in your init routine to see what happens and reduce the number once you have it working.
3. Getting the debug serial port going is going to help if it is working to the phone but the sms commands are not working - I noticed in the opengpstracker website you have to put the phone in a special mode for this to work - did you do that?
I tried the attached code on my 168i, and I got the "AT" echoed, plus an "OK" from the phone. I think one problem is that you didn't terminate your AT commands with a carriage return. Another issue is the phone going to sleep after a few seconds of no communication (as evidenced on my scope). When this happens, you need to get its attention again before sending anything. I use the "+++" preceded and followed by a one-second delay. This is the standard attention signal for the AT command set to put the device into command mode and seems to work here as well. The phone will not echo the "+++", but if it is already awake when it receives the attention signal, it will reply "OK".
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!
Jay
Jay, any success yet? Even without the balloon aspect, it's an interesting project. Fill us in!
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!
Thanks for asking. No, I still think I killed the phone somehow. I started my fall semester on Tuesday, so haven't had time to buy a new one, but I'm actually out the door to head to Radio Shack to get a new one. I'll let you know.
Jay
If you want 'play' with this phone via a terminal program it's pretty simple to connect this phone to a USB2SER adapter that Parallax sells, could possibly also use a PropPlug or just build a MAX3232 interface. Connections below for USB2SER:
Looks like the phone will 'auto baud' I've used 19200 in ProComm. AT+CLAC will list off all AT-Commands that this phone will respond to.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
I still wonder if anybody was ever able to interface any other cellphone from the same manufacturers named·C257, C261, V175, V176, V177, W375, C168, and W220.
Post Edited (john_s) : 11/27/2008 11:48:50 PM GMT
Finally got a tracphone that will work in my area, but I ma having trouble finding much hack type information on it. It is a Kyocera K126C. Any pointers on finding out some info on this one? All I want to do is send text using a Prop with it, as part of a remote alarm system. I suppose if nothing else I can pull it apart and tap into the buttons, but something a little more elegant would be prefered.
Thanks!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
www.smart-clip.com/news.php
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH - Electronics: Engineer - Programming: Professional
Took a look, but didn't see any info about this phone. I'm not looking for hack info, just want to send text messages as above in this thread. The battery is charged, so I'm going to start but just seeing if it will respond as above.
Thanks!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
Been playing with the Kyocera K126C today. Using Phil's code, both pins show the AT commands etc, at exactly the same time, regardless of which pin is RX or TX. The start routine returns a -1. If I unplug the phone, the Prop endlessly restarts. With Jay's code (which I had downloaded previously and can't see in this thread now) it returns a -1, again regardless of which pins I us as TX/RX.
Does this provide any clues? I don't even know if this phone has a comm port connected to the headphone jack.
The dang thing has weird screws, so I am having a tough time taking it apart to hack into the keypad. Might have to drill them out...
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
Can you connect a HYDRA board directly to it for wireless data connections?
Thanks,
gonzobrains
Have you made any progress with the motorola c168i interface?
This seems like to very promising project.
Regards
If that was the case I would make one right away and start tinkering.
Phil-
I tried modifying the code you provided to work with the pins 30/31 on the proto board since I don't have a TV out (or TV for that matter). I've included it below. I'm not sure my version does the same thing. I AM sure that my phone doesn't respond, but I can't figure out if it's because the code isn't modified correctly, or because the phone isn't wired correctly.
Looks to me like "+++" needs to get passed to the phone then wait the correct amount of time and then send AT. Phone should respond with "OK". It does not. Does the display on your phone do anything when your code is executed? My does not turn on the backlight up when "asleep" even if I run this code and if my phone is "awake" and I run the code, the backlight goes out when the 10 sec timer expires. It really acts like my proto board isn't speaking to the phone. Is there any other way to force the phone to spit out anything over this port?
I've checked continuity in my cable (between proto board and tip of 2.5mm plug) and that's fine. I've spent most of the day working this problem and I'm not sure I'd see a glaring error right in front of me at this hour. Can anyone provide a sanity check?
In desperation, I tried flipping the PHONE_TX and PHONE_RX lines. Same (nil) response from phone. Did I fry the phone's serial port by doing that?
Thanks,
Peter
PHIL'S VERSION
MY VERSION
I'm up and texting! Thankfully no blown serial port. I simply followed the setup instructions Jay posted from opentracker. They had to do with backlight and going to sleep so I don't think it had anything to do with the serial port. It's a bit disconcerting that the phone doesn't give any indication that it's sending a message. The display remains dark, but it is in fact sending messages.
Thanks again Jay for bringing this to our attention.
Happy New Year.
Peter