msDroid - Android application for MegaSquirt

Discussion in 'Throttle bodies & non-OEM ECUs' started by Trev16v, Jun 15, 2011.

  1. RBPE Forum Member

    Joined:
    Sep 1, 2011
    Likes Received:
    18
    Location:
    Manchester, UK
    Kudos to you., now, just to work out how to use my phone ;)
     
  2. Trev16v

    Trev16v Paid Member Paid Member

    Joined:
    Oct 22, 2003
    Likes Received:
    451
    Location:
    Oxfordshireland
    This is now available on Google Play. It's best to enable automatic updates due to it being under active development.

    Clicky:

    [​IMG]


    Regarding the choice of Bluetooth module, I've had good results from this one. To use it, you need to provide a 5V power supply, which could be done by wiring from the 5V pin on the DB9 connector on the MegaSquirt unit. Or you can just connect it to a 2 x 1.5V AA battery holder. This is the simplest solution.

    http://www.ebay.co.uk/itm/Bluetooth...ting_Parallel_Serial_PS_2&hash=item3cca49ecee

    For the above, you also need a gender changer:

    http://www.ebay.co.uk/itm/SERIAL-CA...ting_Parallel_Serial_PS_2&hash=item1e702e7c56

    Set the little switch on the Bluetooth adapter to "DTE", and the other little switches to "S" and "N/G".


    I've also used some little Chinese Bluetooth modules that can be mounted inside the MegaSquirt unit but I will need to write a guide to using those.
     
  3. bizzle New Member

    Joined:
    Sep 16, 2012
    Likes Received:
    0
    Please write that guide to using internal BT modules as soon as you can. I have a variety of ICS (Captivate), Jelly Bean (HTC One S), and Honeycomb (Nook) devices to test this on but I'm having a devil of a time deciding which hardware to purchase with minimal modding to my MS1. So far it seems in order to work I want a connection that is rs232 but not TTL?
     
  4. Trev16v

    Trev16v Paid Member Paid Member

    Joined:
    Oct 22, 2003
    Likes Received:
    451
    Location:
    Oxfordshireland
    Hiya Bizzle,

    A complete Bluetooth to serial/RS232 adapter is an adapter that can plug directly into the MegaSquirt serial connector (possibly via a gender changer adapter, if you use the adapter I linked to above).

    A TTL Bluetooth board on the other hand is still essentially a Bluetooth to serial adapter, BUT its serial signals are not buffered and inverted; they're at TTL logic levels. The serial lines from one of these boards are suitable for direct connection to a microcontroller. So you would use one of these if you wanted to install the adapter actually inside the MegaSquirt unit. Or, you could connect one of these via serial port if you added an RS232 driver chip such as a MAX232 or similar.

    If you're not into electronics at all, don't worry about the second paragraph there at all. What you simply need to look for is a complete Bluetooth to serial adapter, in its own little plastic case, that has a serial connector on one side of it just like the one you see on your MegaSquirt unit. A suitable one is one like in the first eBay link I posted. Then, because MegaSquirt has a female serial port and because the adapter I linked to has a female port too, you also need a male/male gender changer (see second eBay link). Also, very important: The adapter may need setting up using Hyperterminal or similar to get it running on the correct baud rate for the MS version you're using. For MS1, you want 9600 baud. For MS2, 115200 baud. The adapter usually has Windows software supplied to do this.
     
  5. bizzle New Member

    Joined:
    Sep 16, 2012
    Likes Received:
    0
    Thank you very much for that description. It clarified a few of the issues I was struggling over. I've been reading for months it seems and I think I might simply have information overload making my eyes bleed!

    I'm interested in electronics *and* I'm fairly broke at the moment so I want to do it myself as well as buy the least expensive, workable option.
    The complete setups tend to be around $20-30 dollars over here in the States whereas the individual models can be purchased for between 1-3 dollars. Quite a difference...or at least too much for me!

    So if I'm getting this straight, if I want to connect a permanent BT module I should choose one that communicates via TTL and wire it straight to the MS1 module's pins? Will I be able to connect via serial port at will to do updates and such (well, I'm actually going to also solder a USB TTL cable in there so I can just use that instead) or do I need to make a switch (or possibly diode(s)) to change between the BT and serial port?
     
  6. Trev16v

    Trev16v Paid Member Paid Member

    Joined:
    Oct 22, 2003
    Likes Received:
    451
    Location:
    Oxfordshireland
    Hiya Bizzle,

    Actually just to clarify a bit more about RS232 / serial voltage levels, as it may be useful for anyone else needing to know about this, too:

    When you have a microcontroller or a Bluetooth module or any electronic part that has a UART inside it for serial communication, the transmit (Tx) and receive (Rx) connections to it operate at "TTL" levels, which means that a 'zero' is represented by 0V and a 'one' is represented by +3.3V or +5V (or whatever the positive supply is to the digital IO). So, in simple terms, for that chip to spit out a binary 'one', its transmit pin has positive voltage on it. To spit out a binary 'zero', its pin has zero volts on it. Now, when you talk about serial data that's transmitted over the serial cable you use to connect your MegaSquirt to your laptop, the voltages are different. When the serial data is transferred along the serial cable, the binary ones and zeros are at RS232 voltage levels. Here, a binary 'one' is represented by a negative voltage (-3V or more negative) and a binary 'zero' is +3V or higher. So, what this means is that for a microcontroller to talk over a serial port, the microcontroller needs to have another chip between it and the 'outside world' (the RS232 port) that translates between the internal TTL levels and the external RS232 levels. And, a very commonly used chip to do this is the famous MAX232 (of which there are now countless derivatives).

    The more expensive, complete Bluetooth dongles that you see, that already have a serial connector on them, are ready to connect directly to the serial connector on the front of your MegaSquirt unit.

    Those very cheap $5 "TTL" Bluetooth modules from China that are all over eBay at the moment can only be connected to your MegaSquirt unit if you also add another circuit to them with a MAX232 type chip. If you look at this photo here, you can see that I have assembled my own Bluetooth dongle, that can connect to the outside of MegaSquirt, by combining one of those little Chinese modules with a little MAX232 converter PCB I got off eBay. Now, if you would like a permanent solution by putting one of those Chinese modules inside the MegaSquirt unit, you can certainly do this by connecting the module directly to the microcontroller's UART lines inside. The only practical problem is that the Tx / Rx lines on those little modules are at 3.3V logic, not 5V. So you would need to do some level conversion (which can be achieved using a suitable IC, or instead slightly crudely using diodes / resistors). You would also need to have a switch that switches the microcontroller's UART Rx line between the Tx line form the Bluetooth module and the MAX232 pin that it used to connect directly to.

    The other awkward thing - especially so with those Chinese modules - is that most of these Bluetooth modules need to have their serial-side baud rate set up using a set of modem AT commands beforehand. This means it is best if you can find an eBay supplier who can sell you one already configured for the baudrate you need (9K6 for MS1, 115K2 for MS2). And also, of many that I tested, I did find one or two that I couldn't reliably open an RFCOMM connection to from Android. Even though they all look the same (same PCB), beware that they have all sorts of different software stacks on them from what I can tell and I had better results with some more than others.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice