Shop OBEX P1 Docs P2 Docs Learn Events
Adafuit's FONA with the Propeller — Parallax Forums

Adafuit's FONA with the Propeller

Duane DegnDuane Degn Posts: 10,588
edited 2015-06-19 07:25 in Propeller 1
I recently purchased one of Adafuit's FONA modules.

x1963-01.jpg.pagespeed.ic.p-SvRfOaHh.webp

Adafuit provides a nice little getting started tutorial but the tutorial assumes one wants to use the Arduino.

I've managed to translate Arduino code to Spin but the Fona code was very involved and it did not look like it would be fun or easy to translate the code to Spin. I initially thought I could just use the datasheet and make my own code from there. This turned out not to be as easy as I'd hoped. I would type in the various AT commands into a terminal window but I apparently didn't get my syntax correct on many of my attempted commands since the FONA module kept giving me error messages.

I finally decided I'd eavesdrop on the conversation between the Arduino and FONA. In order to provide context to the messages between the Arduino and the FONA, I also listened in on the exchange between the Arduino and terminal window.

The program "MonitorFona" uses five instances of Parallax Serial Terminal. Four of the instances are to listen in on the other lines and one instance is used to display the data to a second terminal window.

This program is in my GitHub repository. I've also added a text file "CapturedData150606a.txt" to the repository in case someone want to just read through the exchange without running the Propeller program.

Here's a link to the repository:

https://github.com/ddegn/FonaWithPropeller

Here's an example of the output of sending a text message:
FromTerm>s<$0D><$0A>
ToTerm>s<$0D><$0A>Send to #
FromTerm>2400000<$0D><$0A>
ToTerm>2400000<$0D><$0A>Type out one-line message (140 char):
FromTerm>Hi on June 6.<$0D><$0A>
ToTerm>Hi on June 6.<$0D><$0A>
Ard>AT+CMGF=1<$0D><$0A>
FONA><$0D><$0A>OK
<$0D><$0A>
Ard>AT+CMGS="2400000"<$0D><$0A>
FONA><$0D><$0A>>
Ard>Hi on June 6.<$0D><$0A>
<$0D><$0A><$1A>
FONA><$0D><$0A>+CMGS: 2
<$0D><$0A>
<$0D><$0A>OK
<$0D><$0A>
ToTerm>Sent!<$0D><$0A>FONA>

The source of the data is identified at the beginning of the line of text with one of four possible prefixes. "FONA>", "Ard>", "FromTerm>" and "ToTerm>" are used to identify the source of the text. In hindsight I should have used a different identifier for the FONA than what was used by the Arduino program. We both used "FONA>" to indicate the data is coming from the FONA. It's not too hard to tell which prefix is which since all the "FONA>" statements occurring at the beginning of a line are inserted by the Propeller program.

In order to reduce the number of lines in the output, The program doesn't move to a new line when the first carriage return is received within a message.

Hopefully the non-printable characters are obvious. For example a carriage return is shown as "<$0D>".

I plan to get the FONA working with a Propeller and one of these inexpensive ($5) OLED displays.

attachment.php?attachmentid=108626&d=1399775726

I'm not sure what I'll end up using as a keypad yet.

I think it should be fun to make a Propeller controlled cell phone. It should work better than my previous attempt using relays. Though the relay version sure sounded cool.

I'll reserve a few posts in this thread for future updates.

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-06-06 20:23
    Reserved 1 of 3.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-06-06 20:24
    Reserved 2 of 3.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-06-06 20:24
    Reserved 3 of 3.

    Last one.
  • Mark_TMark_T Posts: 1,981
    edited 2015-06-07 13:15
    Why reverse-engineer when the code's here?: https://github.com/adafruit/Adafruit_FONA_Library
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-06-07 13:36
    Mark_T wrote: »
    Why reverse-engineer when the code's here?: https://github.com/adafruit/Adafruit_FONA_Library

    Because I didn't understand the C++ stuff in it.

    I've translated Arduino code to Spin before but this code looked too intimidating for my present ability to read C++.

    Using output from the (relatively simple) program "MonitorFona" seemed easier than trying to read the commands from the various functions in the Adafruit source code.

    If I had understood the datasheet properly I shouldn't need either of these techniques to figure out what commands to send to the FONA. Based on the few commands I tried on my own, I found I wasn't reading (or understanding) the datasheet correctly since the FONA kept replying with errors to my input.
  • dnalordnalor Posts: 222
    edited 2015-06-08 13:14
    Duane Degn wrote: »
    If I had understood the datasheet properly I shouldn't need either of these techniques to figure out what commands to send to the FONA. Based on the few commands I tried on my own, I found I wasn't reading (or understanding) the datasheet correctly since the FONA kept replying with errors to my input.

    You have to understand this: http://www.adafruit.com/datasheets/sim800_series_at_command_manual_v1.01.pdf
    Ok, not all commands. Wow! Quite a long list.

    Start slow and simple:
    At the beginning (to initalize the module) you send: AT <$0D>
    You should get <$0D><$0A> OK <$0D><$0A>
    See 1.4 at page 16 and 20.1 at page 297.

    Then try the other commands from page 297.

    If you always get errors, start with AT <$0D> again. To this command you must get an OK.

    Good success!
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-06-08 13:33
    dnalor wrote: »
    Start slow and simple:
    At the beginning (to initalize the module) you send: AT <$0D>
    You should get <$0D><$0A> OK <$0D><$0A>

    I had success with some of the commands but then others I must have used the wrong syntax and received errors. The code to listen in on the four serial channels was really simple and easy to write. I decided it would be easier for me to just see what characters the Arduino program used and copy those in my program.

    Thanks for the well wishes.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-06-18 10:39
    I received an email asking about connecting the FONA to a Propeller Activity Board.
    1 what Pin Outs you used and where you put them
    2. what program did you use to start sending AT commands and seeing the out come from the FONA board to the terminal screen

    In order to use the Propeller as a bridge between the terminal program and the FONA the following connections should be made.
    '' I/O pins
      TX_TO_FONA = 0                ' connects with RX on FONA
      RX_FROM_FONA = 1              ' connects with TX on FONA
    
      '' The FONA should be powered from a single cell LiPo battery. The ground
      '' of the FONA should be connected to the ground of the Propeller.
      '' 3.3V should be connected to the FONA's Vio pin.
    

    I just created a new repository named "SimpleFonaBridge."

    https://github.com/ddegn/FonaSimpleBridge

    The program pretty much just sends any characters received from the terminal on to the FONA. There are a couple of exceptions to this general rule. If the character "~" is received, the Propeller passes on a control-z character. A control-z character (and a carriage return) is required to indicate the end of a text message. I don't think a control-Z character can be sent from the Parallax Serial Terminal. I'm pretty sure there are terminal programs which allow control characters to be sent.

    Parallax Serial Terminal.exe is part of the Propeller Tool download but just about any terminal program should work. If the terminal sends both a carriage return and a line feed character then the following lines should be commented out.
    if inputCharacter == $0D ' Add a line feed character when a carriage return is received.
              Fona.Char($0A)         ' This step isn't really needed since the FONA will work fine
                                     ' with just a carriage return.
    

    By default Parallax Serial Terminal only sends a carriage return. I added the line feed character to make it consistent with the Arduino's terminal. I don't think a line feed character is required.

    I'm working on a more involved program to allow the Propeller to communicate with the FONA. A link to this repository was given in post #1. It will be a couple of weeks before I have time to spend on this project but the object "FonaMethods" has lots of methods which should make it easier to interface with the FONA. The top object is "FonaTest." The top object includes a menu similar to Adafruit's Arduino demo program. I have not tested "FonaTest" yet.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-06-18 14:56
    Here's a photo showing the connections between the Propeller Activity Board (PAB) and the FONA.

    attachment.php?attachmentid=114504&d=1434663541

    Here's a list of the wires and where each end of the wire is connected.

    Red - 3.3V PAB to Vio FONA
    Black - GND PAB to GND FONA
    Blue - P1 PAB to RX FONA
    Yellow - P0 PAB to TX FONA

    There is not a way to power the FONA from the PAB. I'm using one cell from a 2S LiPo to power my FONA. I'm using the balance port to access a single cell. The voltage from two cells in series would likely damage the FONA.

    Adafruit's example ties "Key" to ground. This keeps the FONA powered on. Without this extra wire, the FONA needs to be turned on and off using the little button.

    Adafruit has a nice tutorial about using the FONA.

    https://learn.adafruit.com/adafruit-fona-mini-gsm-gprs-cellular-phone-module/overview
    713 x 532 - 199K
  • dmkmediadmkmedia Posts: 9
    edited 2015-06-19 07:25
    this is great information and the only bit of available info about this subject .. i have searched everywhere and this was the only informative post thanks for this ..

    i know you have done a lot of work on this and your code is in spin.
    but a quick question did you manage to get anything in C at all ?
Sign In or Register to comment.