Go Down

Topic: Arduino BT serial communication problem (Read 766 times) previous topic - next topic

rui

May 28, 2007, 10:32 am Last Edit: May 28, 2007, 04:14 pm by rui Reason: 1
Hi,

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

Code: [Select]

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:
Code: [Select]

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


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


yerg2k

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

rui

#2
Jun 04, 2007, 11:53 am Last Edit: Jun 04, 2007, 12:07 pm by rui Reason: 1
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:

Code: [Select]
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);
     }
}


Daniel

#3
Jun 04, 2007, 09:32 pm Last Edit: Jun 04, 2007, 09:33 pm by Daniel Reason: 1
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  

rui

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

Daniel

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

rui

Hi Daniel,

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

rui

Daniel

hi

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

D

Go Up