Pages: [1]   Go Down
Author Topic: Arduino BT serial communication problem  (Read 636 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

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

Code:
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:
>>> import serial
>>> ser = serial.Serial('/dev/tty.ARDUINOBT-BluetoothSeri-1', 115200)
>>> while 1:
...     ser.readline()

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

« Last Edit: May 28, 2007, 09:14:00 am by rui » Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 81
everywhen
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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);
      }
}
« Last Edit: June 04, 2007, 05:07:12 am by rui » Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

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  
« Last Edit: June 04, 2007, 02:33:32 pm by Daniel » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Daniel,

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

rui
Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

hi

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

D
Logged

Pages: [1]   Go Up
Jump to: