Pages: [1]   Go Down
Author Topic: Arduino pro mini + bluesmirf + digital compass  (Read 1270 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 36
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

Just want to make sure I am headed down the right path here. I have my arduino pro mini working well with my bluesmirf gold. I also have my digital compass (an ocean-server OS4000T) speaking nicely to a different bluesmirf. All the data gets sent to my mac (MaxMSP) for processing...listening on two different serial ports. However everything (arduino, compass, and 2 bluesmirfs) are in the same tiny space, and therefore seems awfully silly to have 2 bluesmirfs. I've been poking around the forum all morning and it seems like connecting the compass to the arduino, and using AFSoftSerial or SoftSerial is the way to go to get data from both the compass and the arduino via a single bluesmirf. Does this sound like a logical path to head down?

Thanks!
David

Logged

USA, IN
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

What you can do with AFSoftSerial, is to connect your BlueSMiRF and your compass to the Arduino, and receive data via bluetooth on your pc. I think that you can connect up to 2 serial devices, using AFSoftSerial: one to pin 0 and 1 (this is hw), and one to any other two digital pins.
My point is that you will not be able to use the USB to receive data. If that is fine with you, then just go ahead!
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 36
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

well...it should work, yes? I've been hacking away at this all day and can't even get the simple test code to work:

Code:
#include <AFSoftSerial.h>

AFSoftSerial mySerial =  AFSoftSerial(3, 2);

void setup()  {
  pinMode(13, OUTPUT);
  Serial.begin(9600);
  Serial.println("Goodnight moon!");
  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop()                     // run over and over again
{
  if (mySerial.available()) {
      Serial.print((char)mySerial.read());
  }
  if (Serial.available()) {
      mySerial.print((char)Serial.read());
  }
}

I get "Goodnight moon!" (a lovely book, btw), but no "Hello world?". This example should give me that, right? Figure if I can't get this to work, I'm not going to be a happy camper. Again, this is for an Arduino Pro Mini:
http://www.sparkfun.com/commerce/product_info.php?products_id=8991

Perhaps AFSoftSerial can't run on this board?

Any ideas on what to try next?

Thanks!!
David



Logged

USA, IN
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

David,
Your code does not do what you expect: setup() will be executed before loop(), so you send "Goodnight moon!" and "Hello, world?" before you echo one received character on the other serial line.

What you should do is run
Code:
#include <AFSoftSerial.h>

AFSoftSerial mySerial =  AFSoftSerial(3, 2);

void setup()  {
  pinMode(13, OUTPUT);
  Serial.begin(9600);
  mySerial.begin(9600);
}

void loop()                     // run over and over again
{
  if (mySerial.available()) {
      Serial.print((char)mySerial.read());
  }
  if (Serial.available()) {
      mySerial.print((char)Serial.read());
  }
}
and when your Arduino is running listen to the incoming data on the BT and send something to the USB.

I'm not familiar with how to do it on Mac, but maybe you can figure it out based on what I do on GNU/Linux: I have /dev/ttyUSB0 as the serial line to the Arduino and /dev/rfcomm0 as a serial device to the BlueSMiRF (see [1]). Now I open two terminals, one will listen to the BT module with tail -f /dev/rfcomm0, and in the other I send something to the Arduino, like echo "foo" > /dev/ttyUSB0.

I hope this helps.
« Last Edit: January 19, 2009, 12:34:42 pm by peter.vizi » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 36
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thought I'd might resurrect this post!

After a few weeks of trying to get AFSoftserial to work, I gave up...horribly defeated smiley-sad And after doing more research it seems like this path wasn't a good one given the characteristics of the compass.

My work around since my last post has been 2 bluesmirf modems...one connected to an arduino pro mini, the other to the digital compass, but am now revisiting this problem, and wanted to solicit any advice. The arduino and the compass do NOT need to talk to each other...really my only goal is to have both connect to the bluesmirf modem, then pass the info along to my mac. Everything talks TTL. It just seems such a waste to have 2 modems in the same space.

Thanks in advance for any nugget of wisdom!

Best,
David

P.S. Over the past couple days I've also revisited the softSerial idea using "newSoftSerial", but still haven't had any luck.
Logged

Pages: [1]   Go Up
Jump to: