I am using the HC-05 with the Arduino Nano Every and with this Code:
const unsigned int MAX_MESSAGE_LENGHT=12;
#include <SoftwareSerial.h>
SoftwareSerial BT (2,3);
void setup() {
// put your setup code here to run once:
BT.begin(38400);
Serial.begin(38400);
Serial.println("Booted up");
}
void loop() {
// put your main code here, to run repeatedly:
while (BT.available()>0)
{
static char message[MAX_MESSAGE_LENGHT];
static int mymesssage_position=0;
char inByte=BT.read();
if (inByte!='\n'&&(mymesssage_position<MAX_MESSAGE_LENGHT-1))
{
message[mymesssage_position]=inByte;
mymesssage_position++;
}
else
{
message[mymesssage_position]='\0';
Serial.println(message);
mymesssage_position=0;
}
}
while (Serial.available()>0)
{
static char message[MAX_MESSAGE_LENGHT];
static int mymesssage_position=0;
char inByte=Serial.read();
if (inByte!='\n'&&(mymesssage_position<MAX_MESSAGE_LENGHT-1))
{
message[mymesssage_position]=inByte;
mymesssage_position++;
}
else
{
message[mymesssage_position]='\0';
BT.print(message);
Serial.println("Message received. Redirecting to HC-05");
mymesssage_position=0;
}
}
}
Im only getting something like this on the serial monitor:
?xxxxx??x
I tried to work with stop bits,parity,...
You get the point.
Can you help me with this?