Arduino BT serial communication problem

Hi,

I'm trying to communicate with a arduino bt (BT-V06) via serial port. I successfully upload this program to arduino:

int ledPin = 13;   // select the pin for the LED
int i=0;           // simple counter to show we're doing something

void setup() {
  pinMode(ledPin,OUTPUT);   // declare the LED's pin as output
  Serial.begin(115200);        // connect to the serial port
}

void loop () {
  Serial.print(i++);
  Serial.println(" Hello world!");  // print out a hello
  digitalWrite(ledPin, HIGH);
  delay(500);
  digitalWrite(ledPin, LOW);
  delay(500);
}

After installing pySerial, I try to read data using the following python code:

>>> import serial
>>> ser = serial.Serial('/dev/tty.ARDUINOBT-BluetoothSeri-1', 115200)
>>> while 1:
...     ser.readline()

However I do not get any answer... Any ideas?

I'm not sure, but this may work... try only transmitting once the PC has connected.

Hi,

I'm using a macBook to communicate with arduino. I can write via serial but get no response back. This is the code I'm using:

int incomingByte = 0;      // for incoming serial data
int ledPin = 13;   // select the pin for the LED

void setup() {
  Serial.begin(115200);      // opens serial port, sets data rate to 115200 bps
  pinMode(ledPin,OUTPUT);   // declare the LED's pin as output
}

void loop() {
      // send data only when you receive data:
      if (Serial.available() > 0) {
            // read the incoming byte:
            incomingByte = Serial.read();

            // say what you got:
            Serial.print("I received: ");
            Serial.println(incomingByte, DEC);
            // Blink led
            digitalWrite(ledPin, HIGH);
            delay(500);
            digitalWrite(ledPin, LOW);
            delay(500);
      }
}

hi

this is probably not going to help much, but during serial operations it's a good idea to keep an eye on the serial port as it can overflow after a certain number of bytes (128? Can't remember).

Anyway, I'd take out the one-second blink loop. The way you have it written now, it would take over two minutes to read the entire contents of the hardware serial buffer.

D

Hi,

I get an answer from the board but it is not encoded correctly. Same result when running the example program 'Serial Write Basic'.

Any ideas? rui

hi

what did you send and what did you get back? Try sending just one letter... "A" for example. Then see if the returend value is the Ascii value of A, or something similar.

D

Hi Daniel,

I send an 'A' and get a '??'.

rui

hi

what are you using to view the returned characters... the Arduino Serial monitor? Is it set to 115200?

D