1. Check out our app, Forums for Android! Download and leave feedback here!

Bluetooth Receive message from BlueSmirf/Arduino

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

  1. nanolab

    nanolab New Member
    Thread Starter
    5

    Apr 19, 2010
    1
    0
    5
    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;
    4.        
    5.        Log.i(TAG, "The original buffer string is " + buffer);
    6.        
    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.
     

    Advertisement

  2. RobotMan

    RobotMan New Member
    5

    Jul 23, 2010
    4
    0
    5
    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
    5

    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?
    513

    Nov 29, 2009
    7,978
    3,604
    513
    Android App Developer
    NY

Share This Page

Loading...