1. Check out our companion app, Forums for Android! Download from Google Play

Bluetooth Receive message from BlueSmirf/Arduino

Discussion in 'Application Development' started by nanolab, Apr 19, 2010.

  1. nanolab

    nanolab New Member
    Thread Starter

    Apr 19, 2010
    I am new to coding but anxious to learn. I have been struggling for a while now trying to receive messages from an arduino board connected to a bluesmirf. The arduino board is simply outputting a byte over bluetooth and I'm trying to read it in the debug.

    Here is my android code:

    Code (Text):
    1. Log.i(TAG, "BEGIN run and receive message");
    2.        byte[] buffer = new byte[1024];
    3.        int bytes;
    5.        Log.i(TAG, "The original buffer string is " + buffer);
    7.        //Keep listening to the Input Stream while connected
    8.        while(true){
    9.            try{
    10.                //Read from the InputStream
    11.                bytes = inStream.read(buffer);
    12.                Log.i(TAG, "Message is: " + buffer);
    13.            }
    14.            catch(IOException e){
    15.                Log.e(TAG, "disconnected", e);
    16.                break;
    17.            }
    18.        }
    I know I am connecting to the device fine because the green light on the board lights up. The debug message that I am getting though is garbage:

    So as you can see, the buffer string isn't even changing (even though I have tried multiple types of strings from arduino code).

    But I know it is connected because the "Message is: ..." Dialog inputs every time a message should be coming.

    What is going on here? Does anyone have an idea? I might not be giving you enough code, let me know, I just don't want to overwhelm you.

    PS I have also tried transmitting "hello world" to the arduino board with success. It is receiving messages that I cannot do yet.


  2. RobotMan

    RobotMan New Member

    Jul 23, 2010
    I too am trying to learn how to program my android phone and the first app that i have in mind would communicate with my arduino. I have not purchased the blue smirf yet, but i am eager to pick one up one i have done a few android tutorials.

    i was wondering if you have been able to connect yet? i have a book that helped me out quite a bit with arduino development, Making Things Talk. This book goes into quite a bit of detail on bluetooth communication.
  3. driggs

    driggs New Member

    Is there a way to send a sms message from the droid where the data originates from the arduino?
  4. alostpacket

    alostpacket Over Macho Grande?

    Nov 29, 2009
    Android App Developer

Share This Page