MKRZero and Bluetooth connection help

Hi,

I am using an MKRZero to read sensor data on PC. This is done using an USB. I now need to communicate using Bluetooth. I am able to pair my bluetooth module (HC-06) to my PC but when I open a serial port no data is seen. The module LED stops flashing which I assume is an indication for the connection made but no data is seen. I really need to get this working. Any help is appreciated. Thanks!

Pairing doesn't have much to do with any data transfers themselves as its just a connection.

What sketch are you using ?
Please use code tags ( </> ) to post it unless its on CREATE then the shared link will do as well.

What pins are you connecting?

I am connecting to Pins 13 and 14

void setup() 
{
  
  Serial1.begin(9600);
  while(!Serial1);
    delay(1000);
  }
void loop() 
{

  
  checkBTForData();
  
  
  if(btrt)
{ 
      logOverBT();
  } 

void logOverBT(void)
{
  float accelX = imu.calcAccel(imu.ax);
  float accelY = imu.calcAccel(imu.ay);
  float accelZ = imu.calcAccel(imu.az);
  float gyroX = imu.calcGyro(imu.gx);
  float gyroY = imu.calcGyro(imu.gy);
  float gyroZ = imu.calcGyro(imu.gz);
  
  p1 = calcPressureData(analogRead(A1));
  p2 = calcPressureData(analogRead(A2));
  p3 = calcPressureData(analogRead(A3));
  p4 = calcPressureData(analogRead(A4));
  p5 = calcPressureData(analogRead(A5));
  p6 = calcPressureData(analogRead(A6));
  
  timeStamp = getTimeFromRTC();
  
  String dataString = timeStamp+String(accelX)+delim+String(accelY)+delim+String(accelZ)+delim+String(gyroX)+delim+String(gyroY)+delim+String(gyroZ)+delim+String(p1)+delim+String(p2)+delim+String(p3)+delim+String(p4)+delim+String(p5)+delim+String(p6);

  Serial1.println(dataString);
}

int calcPressureData(int analog){
  return 1023 - analog;
}
void checkBTForData(void)
{
  if(Serial1.available()){ 
      byteRead = Serial1.read();
       if(byteRead == BTRT_ENABLE)
{
        btrt = true;
         byteRead = 0;
        Serial1.write(BTRT_ENABLE_OK);
       }
 else if(byteRead == BTRT_DISABLE)
{
        btrt = false;
         byteRead = 0;
        Serial1.write(BTRT_DISABLE_OK);
       }
    }
}

You may want to remove the while serial as it isnt really needed for most boards anymore.

There also appears to be some missing sketch at the beginning for defines etc.

EDIT

This link may well be of use to you as it covers the basics of the BT units and is the home page of one of the long standing members of this forum.

Ok, I will try once more. Thank You for the help!

I tried to program the module using AT commands but there is no OK response on the terminal. Also, another thing I noticed is that the bluetooth and Arduino on connecting using bluetooth turn off after a while. Any help?

Are you using a serial terminal on your computer to try AT commands ?

Don't try AT commands from your BT connected device until you know you can communicate via the computer that is connected to the board via USB first. (baby steps)

The IDE serial terminal is your first place to try but make sure the baud rates match your sketch.

It communicates when connected using an USB. But not with bluetooth

Exactly which BT module are you using (link preferable) ?

Then what terminal program are you using on the other BT enabled device ?

Just to see if I can replicate in some way.

I am using an HC-06 module (v1.06). On the PC I am using Putty to view the data or Arduino Serial Monitor. I even tried with TeraTerm.

That's great as I have some HC05 here (similar but a bit better than the 6)

If you could link or post the WHOLE sketch I might be able to replicate.