Arduino BT with Polar Heartrate

Hello,

I'm actually on a project with the arduino BT and a Polar bluetooth.

I would like to receive the data sent by the transmitter Bluetooth and use it with de arduino BT. I found on internet that the protocol of the polar bluetooth must be something like that :

fe 08 f7 02 d1 4b 03 2c

The BPM seems to be 4b for this example.

But I don't know how to receive this packet from the transmitter.

The transmitter always send data, so is it possible to always receive this data when I put the arduino BT ON ? And how can I initiate a communication between this 2 devices.

Thanks a lot

The Arduino BT supports AFAIK "only" the bluetooth serial profile. If the Polar device is using any other profile you might not have success with the Arduino. The easiest way to test that is by pairing it with your notebook. If you get a new serial device there (COM port for the windows world) it's probably using the serial profile and it worth investing more time to get your Arduino listen to the heart monitor.

Thank you for your answer.

You mean that if i can detect the polar sensor in windows it's ok, if not there is no way i can do this ?

Because i never detected it on windows before.

Ok, in fact the sensor is asleep until it detects a BPM.

So, now I can find it on my labtop with the name Polar iWL and default serial COM5.

How is it possible to make the arduino communicate with it ?

Thank you

I found something in this link.

Is it working for me AT+JDDS=0 ?

Is it working for me AT+JDDS=0 ?

Probably not. Bluetooth module X is not equal bluetooth module Y. The module on the referred page is a eUnistone 31308/2, on the Arduino BT is a Bluegiga WT11. That chip comes with different firmwares and unfortunately the hardware page of the Arduino BT (http://arduino.cc/en/Main/ArduinoBoardBluetooth) does not specify which version they use. I don't have the hardware so I cannot try myself (because of the rather inconvenient handling the Arduino BT is not used very often). The best link I found is this: http://www.glynstore.com/content/docs/bluegiga/iWRAP3_User_Guide.pdf

Try it with your board. First you have to establish a serial connection to your PC using SoftwareSerial, use a simple forwarding sketch to send your commands to the bluetooth module and try the commands in the user guide.

Thank you for your help.

For example I upload this basic serial code to my arduino BT :

void setup(){
  Serial.begin(115200);
  delay(1500);
  Serial.print("$$");
  delay(1000);

}

void loop(){
    delay(1000);
    Serial.print("READY\n");
    delay(1000);
    Serial.print("NAME 00:22:d0:00:85:87\n");
}

As I can find on the user guide :

Command NAME is used to retrieve the friendly name of the device. Syntax NAME {address}

But when I open the serial monitor of the arduino software, I just obtain :

READY NAME 00:22:d0:00:85:87 READY NAME 00:22:d0:00:85:87 READY NAME 00:22:d0:00:85:87

So I suppose I'm not in "command mode" of the iWrap ? How can I enter in ?

Thank you

I find in the user guide the escape sequence to enter in command mode :

The escape sequence:
The escape sequence causes the iWRAP firmware to go to the command mode from the
data mode or vice versa. The escape sequence consists of three (3) escape characters that
are defined by SET CONTROL ESCAPE command. By default the escape character is ‘+’.

Do not enter any character before and/or after the escape sequence for a guard time
which is 1 second. Also send the escape characters individually, not as a string.
With default settings the escape sequence is:

< 1 second sleep> +++ < 1 second sleep>

When a successful state transition from data mode to command mode is made, iWRAP
sends a “READY.” event to indicate that it’s ready to receive commands.

The same escape sequence or the SELECT command can be used to return to data mode.

I tried multiple time but none of them works :

delay(1000);
Serial.print("+++\n");
delay(1000);
delay(1000);
Serial.print("+");
Serial.print("+");
Serial.print("+");
delay(1000);
delay(1000);
Serial.print("SELECT\n");
delay(1000);

As I wrote before, I'd try to do that interactively. That means using a TTL serial like the USB2Serial Light adapter or a FTDI cable to establish a serial command channel from the PC to a SoftwareSerial instance. If you forward everything between this instance and the Serial (going to the BT module) transparently you'll be able to reconfigure the module with your serial terminal. Changing your sketch and uploading it constantly is a tedious and error prone way of exploring the capabilities of your hardware.

Ok I succeeded. I save the result on EEPROM then i display it after.

I am able to PAIR my arduino with my sensor and call it. When I do LIST after my call I can see 1 connection

Now i’m focusing on how retrieve informations send by the sensor, because i’m just connected right now.

Here is my code for now

#include <EEPROM.h>

char inByte = 0;                // incoming serial byte
int  infoSize = 0 ;
char c;

void setup(){                    // run once, when the sketch starts
  Serial.begin(115200);        // start serial at 115200 kbs
  Serial.println("SET CONTROL ESCAPE 43 00 0");    // set control escape 43->+ 00->bit mask 0->DTR disable
}

void loop(){
  
  // if we get a valid byte, read analog ins:
  if (Serial.available() > 0){    
    inByte = getbyte();  // get incoming byte
    
    if (inByte == '1' ){ // look for a 1
        Serial.println("Starting...");
        infoSize = getInfo();
        Serial.println("Done");
        
    }else if (inByte == '0' ){ // look for a 0
      Serial.print("Get string:  ");  
      for(int i=0;i<infoSize;i++){
        c=EEPROM.read(i);
        Serial.print(c);
      }
      Serial.println();
      Serial.print("Cleared string  size: ");
      Serial.println(infoSize);
    }    
  }
}

int getInfo(){
  int j=0;
  
  //Entering in command mode
  delay(2000);  
  Serial.print("+++");
  delay(2000);

  Serial.println("SET BT AUTH *");    //no pin code to pair with polar
  Serial.println("PAIR 00:22:d0:00:85:87");
  delay(4000);
  Serial.println("CALL 00:22:d0:00:85:87 1101 RFCOMM");
  Serial.println("LIST");
  
  for (int i=0; i <= 10; i++){
    delay(1000);
    
    while (Serial.available() > 0 && j <512) {    
      inByte = getbyte();  // get incoming byte    
      EEPROM.write(j, inByte); 
      j++;
    }
    delay(1000);
  } 
  
  //Exiting command mode
  delay(2000);
  Serial.print("+++");
  delay(2000);

  return j;
}

char getbyte(){
  while (Serial.available() == 0){ //look for aviable data
    // do nothing, wait for incoming data
  }
  return Serial.read(); //return data if available
}

READY.
LIST 1
LIST 0 CONNECTED RFCOMM 1007 0 0 17 8d 5 e0:b9:a5:2f:57:18 1 IN

If someone can confirm me if I'm right :

  • I have to connect my arduino with my sensor (command mode)
  • Switch to data mode to be able to listen on serial port
  • listen on serial port
  • Print directly data

Because nothing happen on the serial port when I'm in data mode

In data mode, if i use Serial.read() I'm supposed to listen what sensor is sending ?

When I do my CALL now I can see a RING event incoming.

I guess it's good because the sensor is trying to connect with the arduino but I don't know how to able it to send me data :cold_sweat: I have also 1 error now...

Get string: READY. PAIR 00:22:d0:00:85:87 OK CALL 1 LIST 1 LIST 0 CONNECTED RFCOMM 1007 0 0 20 8d 5 e0:b9:a5:2f:57:18 1 IN NO CARRIER 1 ERROR 403 RFC_CONNECTION_REJ_SECURITY UIRY 00:22*RING 0 52:fa:04:76:00:02 1 RFCOMM* NO CARRIER 0 ERROR 0 Cleared string size: 168

Hi,

I want to do the same thing than you so i want to know if your project works? And if it works, can you explain to me how have you do it ?

Sorry for my bad English :P

Thx for your reply

Hi guys, i m trying to pair arduino with bt module hc-05 but i can t succed!!! Could u please help.me?

I m using polar h7 bluetooth belt

Check what BT version your module uses - isn’t it BT2.0? And I think Polar is using BT4.0 (AKA BT Low Energy or BT Smart). You might need to buy a BT4.0 compatible module.