NewSoftSerial and KVH compass

The compass:
Model C100 (kvh.com)
RS 232 or 0 to +5V data in/out
Receives/Transmits ASCII
Message rate 10Hz
“d1” gets data once. Responds with > and data

#include <NewSoftSerial.h>
NewSoftSerial kSerial (4, 5 , true);

void setup() 
{
  Serial.begin(19200);
  kSerial.begin(9600);
}

void loop() 
{
  Serial.println("M"); 
  kSerial.println("d1"); 
  delay(75);
  while (kSerial.available() ) 
  {
    char c = kSerial.read();
    Serial.print(c); 
  }
}

Output:

M
M
!Not ImplementedM

$015.1,D,OK6BM
$015.1,D,OK
6BM
$015.1,D,OK*6BM
It seems, the first time through the loop , d1 is not sent. The 2nd time something other than d1 is sent
and the 3rd and subsequent times are fine (with delay >73).
Is this normal (just a case of the software serial not being fast enough)?
It would be nice if I just asked for the data and was given it 1st time around or am I asking too much?
Would inserting more delay elsewhere help or would I be best to just have it spitting out data constantly and grab it when I need it?
Regards
Rob

It seems, the first time through the loop , d1 is not sent. The 2nd time something other than d1 is sent
and the 3rd and subsequent times are fine (with delay >73).
Is this normal (just a case of the software serial not being fast enough)?

adapt your code with a delay so the compass can startup.

(code not tested)

#include <NewSoftSerial.h>
NewSoftSerial compass(4, 5 , true);

void setup() 
{
  Serial.begin(19200);

  compass.begin(9600);
  delay(300);       // give compass some time to start
}

void loop() 
{
  compass.println("d1"); 
  delay(75);
  while (compass.available() ) 
  {
    char c = compass.read();

    if (c == '>') Serial.println(millis());
    Serial.print(c); 
    
  }
}

Thanks for your reply. With delay= 300 Output: M M !Not ImplementedM 548

$009.3,D,OK*64M

No, change with delay increased to 1000 (except millis = 1250) Perhaps I should just switch the compass to output continuously.

Maybe the compass need a command and then a delay for 300? "a kickstart"?

The answer "!Not ImplementedM" indicates that the compass did not receive the "d1" command correctly. So it needs some time to adapt.

According to the datasheet the responsetime is 0.1 - 24 seconds so increase the delay from 75 -> 100?

compass.begin(9600); delay(1000);} void loop() { Serial.println("M"); compass.println("d1"); delay(1000); while (compass.available() ) { delay(1000); char c = compass.read();

Tried with 300, increased to 1000, and then tried again with 1000 in the while loop. No change in output (except millis).