HC-05 library to send sensor data for board with SAMD architecture

I would like to send ad8232 sensor data to android and I'm using an adafruit father m0 but suddenly its BLE is undiscoverable so I decided to use an HC-05. The problem is I need to use SoftwareSerial library which is not compatible with my board. Is there any alternative for this?

SoftwareSerial can be used with many pins on many boards, all you need do is nominate them and connect accordingly. You might even use hardware serial. A better explanation of what you think the problem really might be in order, and that might include identifying your board.

Thanks for your answer, since I'm new to this I don't really know how to do as your reply has stated also I tried to browse about this and I can't find any resource about using hardware serial to send data through bluetooth to android or how to configure and identify my board, below is the error message I got.

Arduino: 1.8.2 (Mac OS X), Board: "Arduino M0"

/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:260:2: error: #error This version of SoftwareSerial supports only 20, 16 and 8MHz processors
#error This version of SoftwareSerial supports only 20, 16 and 8MHz processors
^
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp: In member function 'bool SoftwareSerial::listen()':
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:316:23: error: 'SREG' was not declared in this scope
uint8_t oldSREG = SREG;
^
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:317:9: error: 'cli' was not declared in this scope
cli();
^
In file included from /Users/calista/Library/Arduino15/packages/arduino/hardware/samd/1.6.17/cores/arduino/delay.h:27:0,
from /Users/calista/Library/Arduino15/packages/arduino/hardware/samd/1.6.17/cores/arduino/Arduino.h:81,
from /Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:43:
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp: In member function 'void SoftwareSerial::setTX(uint8_t)':
/Users/calista/Library/Arduino15/packages/arduino/hardware/samd/1.6.17/variants/arduino_mzero/variant.h:62:82: error: invalid conversion from 'PortGroup*' to 'uint8_t {aka unsigned char}' [-fpermissive]
#define digitalPinToPort(P) ( &(PORT->Group[g_APinDescription[P].ulPort]) )
^
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:492:18: note: in expansion of macro 'digitalPinToPort'
uint8_t port = digitalPinToPort(tx);
^
/Users/calista/Library/Arduino15/packages/arduino/hardware/samd/1.6.17/variants/arduino_mzero/variant.h:65:44: error: base operand of '->' is not a pointer
#define portOutputRegister(port) ( &(port->OUT.reg) )
^
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:493:27: note: in expansion of macro 'portOutputRegister'
_transmitPortRegister = portOutputRegister(port);
^
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp: In member function 'void SoftwareSerial::setRX(uint8_t)':
/Users/calista/Library/Arduino15/packages/arduino/hardware/samd/1.6.17/variants/arduino_mzero/variant.h:62:82: error: invalid conversion from 'PortGroup*' to 'uint8_t {aka unsigned char}' [-fpermissive]
#define digitalPinToPort(P) ( &(PORT->Group[g_APinDescription[P].ulPort]) )
^
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:503:18: note: in expansion of macro 'digitalPinToPort'
uint8_t port = digitalPinToPort(rx);
^
/Users/calista/Library/Arduino15/packages/arduino/hardware/samd/1.6.17/variants/arduino_mzero/variant.h:66:44: error: base operand of '->' is not a pointer
#define portInputRegister(port) ( &(port->IN.reg) )
^
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:504:26: note: in expansion of macro 'portInputRegister'
_receivePortRegister = portInputRegister(port);
^
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp: In member function 'void SoftwareSerial::begin(long int)':
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:515:31: error: 'table' was not declared in this scope
for (unsigned i=0; i<sizeof(table)/sizeof(table[0]); ++i)
^
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:531:38: error: 'digitalPinToPCICR' was not declared in this scope
if (digitalPinToPCICR(_receivePin))
^
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:533:78: error: 'digitalPinToPCICRbit' was not declared in this scope
*digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));
^
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:533:79: error: '_BV' was not declared in this scope
*digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));
^
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:534:37: error: 'digitalPinToPCMSK' was not declared in this scope
*digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin));
^
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:534:78: error: 'digitalPinToPCMSKbit' was not declared in this scope
*digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin));
^
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp: In member function 'void SoftwareSerial::end()':
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:549:36: error: 'digitalPinToPCMSK' was not declared in this scope
if (digitalPinToPCMSK(_receivePin))
^
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:550:77: error: 'digitalPinToPCMSKbit' was not declared in this scope
*digitalPinToPCMSK(_receivePin) &= ~_BV(digitalPinToPCMSKbit(_receivePin));
^
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:550:78: error: '_BV' was not declared in this scope
*digitalPinToPCMSK(_receivePin) &= ~_BV(digitalPinToPCMSKbit(_receivePin));
^
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp: In member function 'virtual size_t SoftwareSerial::write(uint8_t)':
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:585:21: error: 'SREG' was not declared in this scope
uint8_t oldSREG = SREG;
^
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:586:7: error: 'cli' was not declared in this scope
cli(); // turn off interrupts for a clean txmit
^
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:590:26: error: 'XMIT_START_ADJUSTMENT' was not declared in this scope
tunedDelay(_tx_delay + XMIT_START_ADJUSTMENT);
^
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp: In member function 'virtual void SoftwareSerial::flush()':
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:633:21: error: 'SREG' was not declared in this scope
uint8_t oldSREG = SREG;
^
/Users/calista/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:634:7: error: 'cli' was not declared in this scope
cli();
^
exit status 1
Error compiling for board Arduino M0.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

zzzzz:
Board: "Arduino M0"

#error This version of SoftwareSerial supports only 20, 16 and 8MHz processors

Well I guess that says it all.

I have never heard of an Arduino M0, but I see it has a 5v pin so you can power a normal HC-05. You might find the following background notes useful. You will not need a voltage divider on Arduino Tx.

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf
http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

Sorry, the board is supposed to be adafruit feather m0 and it doesn't have a 5v pin, I use this wiring from this link : http://www.instructables.com/id/How-to-Receive-Arduino-Sensor-Data-on-Your-Android/

The error message is the same though and I don't know if it is even possible but I've tried to use this code without software serial and the data doesn't show up on the android bluetooth terminal when I tested it, here's the code :

void setup() {
  // initialize the serial communication:
  Serial.begin(9600);
  pinMode(10, INPUT); 
  pinMode(11, INPUT); 
  }

void loop() {
  // put your main code here, to run repeatedly:
    if((digitalRead(10) == 1)||(digitalRead(11) == 1)){
    Serial.println('!');
  }
  else{
    // send the value of analog input 0:
     Serial.println(analogRead(A0));
  }
  //Wait for a bit to keep serial data from saturating
  delay(10);
}

I also tried to use AltSoftSerial.h and here's the 'vital' error message I got :
WARNING: library AltSoftSerial-master claims to run on (avr) architecture(s) and may be incompatible with your current board which runs on (samd) architecture(s).

I need to send data from the micro controller to android wirelessly using HC-05. Most of the tutorial I found are using the software serial library which is not compatible with my board. I was wondering if it's possible to use hardware serial instead and how to do so

zzzzz:
Sorry, the board is supposed to be adafruit feather m0 and it doesn't have a 5v pin, I use this wiring from this link : http://www.instructables.com/id/How-to-Receive-Arduino-Sensor-Data-on-Your-Android/

Well you can take your chances with that, but start by reading what it says on the back of the HC-05 board, twice, and reflect on what feeding it from a 3.3v pin does for your confidence. Having said that, power supply, is not proven to be your problem.

IF you insist on using software serial, it will have to be a software serial library that is specifically written for SAMD architecture. If such software doesn't exist, that wouldn't surprise me.

The links above are for using hardware serial.

Yes you can do this.
Just use Serial.print or Serial.write.

Once the Bluetooth modules are paired together, they behave exactly as if a wire was connected between them. That is, data written/read from the TX/RX pins on one side is directly reflected on the other side. So yeah, just use Serial.print or Serial.write like you normally do.

@zzzzz, do not cross-post. Threads merged.

From the replies I assume the code that I posted on my previous reply could have worked, but in the bluetooth terminal application of my android phone the data is not printed although the data is printed on the serial monitor so I don't know if the data is received by the android. Is there any suggestion?

From the replies I assume the code that I posted on my previous reply could have worked,

No.
You had no code to put the Bluetooth module into the right mode to begin pairing. Are the two units paired?

I can pair and connect to the HC-05 from my phone

I just found out that HC 05 is in the slave mode by default, can it send data in this mode, if yes what code should I add, if no is it simpler to change the HC 05 into master mode or can I add code that can make it able to send the data in slave mode?

There is no need to "add any code", there is no need to make HC-05 master, indeed it is a seriously dumb idea, and there is no need to "put the module into the right mode". Being master or slave is only a matter of which establishes the connection. Android is the master. I don't suppose you have bothered to read the PDF I linked to before.

Hello, i am getting same error in the same reference. Can anybody guide me here

muskan002:
Hello, i am getting same error in the same reference. Can anybody guide me here

Best to start your own thread and explain the problems there.

This thread is over 2 years old so I doubt anyone remembers what it was about.