Pages: [1]   Go Down
Author Topic: new software serial library problems  (Read 1392 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So I've been trying to use this new software serial software library but I'm getting the wrong output. I'm trying to connect an OS-5000S digital compass using the software serial port. I'm pretty sure my pin configuration is correct, and the compass outputs comma delimited data as a string of characters it seems: e.g. 192.6, 193.5, 196.4...
This is my current code:
#include <NewSoftSerial.h>

#define rxPin 4
#define txPin 5
NewSoftSerial CompassSerial(rxPin, txPin);
int compass;
int test;
int i = 0;
int j = 0;
void setup() {
  
  pinMode(txPin, OUTPUT);
  pinMode(rxPin, INPUT);
  CompassSerial.begin(4800);
  Serial.begin(38400);  
}

void loop() {
  if(CompassSerial.available()) {
    //if(CompassSerial.read()==46) {
    //for(i = 0; i<6; i++) {
    compass = CompassSerial.read();
    
    Serial.println(compass);
    //}
    //}
  }
//   if(CompassSerial.available()) {
//     Serial.println("Hello");
//     if(CompassSerial.read() == 10) {
//       Serial.println("Hello There");
//       while(1) {
//       compass = CompassSerial.read();
//       if(compass == ',') {
//         break;
//       }
//       i++;
//      }
//     }
//     Serial.println("Hello There2");
//   }
//   for(j = 0; j < 6; j++) {
//     Serial.println("Hello There3");
//     CompassSerial.print(compass[j]);
//   }
}
 
So basically I'm just printing out whatever I get, which is:

×
§
·
Û
×
«
¯
·
·
Û
ß
«
Ó
·
ß
ß
§
¯
÷
ï
Û
ß
×
«
×
·
·
Û
×
«
×
·
·
Û
ß
§
Ó
·
ß
ß
«
¯
÷
ï
Û
ß
×
«
ß
·
·
Û
×
§
×
·
·
ß
ß
«
Ó
·
Û
ß
«
¯
÷
ï
Û
ß
×
§
Ó
·
·
Û
×
«
×
·
·
Û
ß
«
×
·
Û
ß
«
¯
÷
ï
Û
¤
I
%
$
$
$
$
$
$
$
%
$
$
$
$
$
$
v


which seems to be junk....can anyone help??
Thanks in advnce
Logged

Middle of the Pacific
Offline Offline
Full Member
***
Karma: 0
Posts: 129
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

looks like a baud rate problem....
Logged

Middle of the Pacific
Offline Offline
Full Member
***
Karma: 0
Posts: 129
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

On page 11 of the manual I found here

http://www.oceanserver-store.com/compass.html

It states that the factory default baud rate is 19200.

In your code it looks like you set it to 4800.
Logged

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

Sorry I forgot to mention that I set the baud rate to 4800 connecting the compass directly to a computer and programming it from there. It should remember the settings even after the power is lost. Any other suggestions? Thnanks!
Logged

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


uploaded program on gps using the above code on duelmineuve
code says error
on uploading
27: error: NewSoftSerial.h: No such file or directory In function 'void setup()':
 In function 'void loop()':
Bad error line: -3
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's telling you that you need to install the NewSoftSerial library in the proper place. Have you done that, or tried to?
Logged

Sussex UK / CT USA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1028
Forums forever
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
That's telling you that you need to install the NewSoftSerial  library

If....

Code:
#include <NewSoftSerial>

... isn't enough, then you possibly need to install the library, too.

Details of that, admittedly in a different context, and related issues at....

http://sheepdogguides.com/arduino/ar3ne1libs.htm
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@tkbyd
I think you're missing something in your include statement. Like the .h...
Logged

Pages: [1]   Go Up
Jump to: