Select only one output in a bluetooth connection

Hi!
I am new to arduino and I am developing a project that consists in connect two bluetooth modules (one hc-05 and the other hc-06). The hc-05 is attach with a arduino mega board and the hc-06 is connected with a bitalino (board with an mcu nano). I already made the connection between the two modules, but only gives me random numbers. The bitalino have 4 analog outputs and i just want data from one.
This is the code:

 #include <SoftwareSerial.h>  


int bluetoothTx = 10;  // TX-O pin of bluetooth mate, 
int bluetoothRx = 11;  // RX-I pin of bluetooth mate,

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

void setup()
{
  Serial.begin(9600);  // Begin the serial monitor at 9600bps

  bluetooth.begin(115200);  // The Bluetooth Mate defaults to 115200bps
  bluetooth.print("$$$");  // Enter command mode
  delay(100);  // Short delay, wait for the Mate to send back CMD
  bluetooth.println("U,9600,N");  // Temporarily Change the baudrate to 9600, no parity
  // 115200 can be too fast at times for NewSoftSerial to relay the data reliably
  bluetooth.begin(9600);  // Start bluetooth serial at 9600 
}

   void loop()
   { 
    if(bluetooth.available())  
  {
    Serial.print((byte)bluetooth.read();  
  }
  if(Serial.available())  
  {
    byte c = (byte) Serial.read();
    
    bluetooth.print(c); 
  }

}

I tried to put this but it doesn't work

((buffer[6] - 0) & 0x0f) +  ((buffer[5] - 0) & 0xfc) << 2)

Can someone please help me?
Thank you

Are they random numbers or are the the ASCII codes for characters ? Please post a small sample of what you receive.

What exactly are you expecting to receive ?

Kudos for using code tags, but this doesn't compile:

    Serial.print((byte)bluetooth.read();  

is missing a ")". A small detail, but it indicates you've edited since your last compile, which means we're not seeing the code that you feel isn't working.
C

This is a part of the sample


the board bitalino have 4 sensors integrated (EDA,EMG,ECG and EEG) and i want only EMG signal.

Oh that's right. I've already corrected. Thank you :).

I don't think that anybody ever has succeeded with SoftwareSerial at 115200.

For which of the two boards is the code that you posted? The Nano based one?

This prints the numeric value; if you are receiving ASCII, use write instead of print.

No, supposedly it's for the Arduino Mega.
I've changed the 115200 to 9600 and the print to write but still give me the same thing

The hc-05 is attach with a arduino mega board

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

There is no need to use software serial on the Mega which has 3 additional hardware serial ports.

Can you provide any documentation on the bitalino communication protocol?

Ok, so if i don't have to use the software serial what should i use?
I have this. Idk if it helps.
image

Depending on the pins you have available there are three additional serial ports. Using Serial1 is very common.

Serial1 19(RX), 18(TX)
Serial2 17(RX), 16(TX)
Serial3 15(RX), 14(TX)

The bitalino information is a start but I can't really make sense of it other than there are 8 bytes . It might help to understand the output better if you can set up to print each byte received in HEX with a space in between.

Do you have anything more on the bitalino?

Ok , so i replace the 10 and 11 to one of this right?

I just have the datasheets if that might help.
microcontroller-unit-mcu-block-data-sheet-bitalino.pdf (3.5 MB)
revolution-emg-sensor-datasheet-1.pdf (2.1 MB)

Yes. But you will use SerialX.begin(baudrate) like you use Serial.begin(baudrate).

EDIT: I misunderstood the question. @sterretje has given you the correct information

1 Like

No, just use Serial1 or Serial2 or Serial3; remove the SoftwareSerial completely from the code.

If you want to refer to the bluetooth connection by the name 'bluetooth', you can replace

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

by

#define bluetooth Serial1
1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.