1

Topic: HC-05 and arduino mega 2650 (Device not reply. Receive time out error)

No compiling errors, it worked 2 times and then it did'nt. I'm connected via Hardware serial (Serial1,pins 19 and 18). I have the baud rate to 9600.

Here is my code:


//////////////////////////////////////////////
//        RemoteXY include library          //
//////////////////////////////////////////////

// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__HARDSERIAL
#include <SPI.h>
#include <RemoteXY.h>

// RemoteXY connection settings
#define REMOTEXY_SERIAL Serial1
#define REMOTEXY_SERIAL_SPEED 9600


// RemoteXY configurate 
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,3,0,0,0,31,0,8,13,0,
  3,131,28,5,45,17,2,26,1,1,
  25,33,19,20,2,31,45,0,1,1,
  58,33,19,20,2,31,43,0 };
 
// this structure defines all the variables of your control interface
struct {

    // input variable
  uint8_t select_1; // =0 if select position A, =1 if position B, =2 if position C, ...
  uint8_t button_1; // =1 if button pressed, else =0
  uint8_t button_2; // =1 if button pressed, else =0

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0

} RemoteXY;
#pragma pack(pop)

/////////////////////////////////////////////
//           END RemoteXY include          //
/////////////////////////////////////////////

#define PIN_BUTTON_1 26
#define PIN_BUTTON_2 24

int ssd = 53;     
int ssg = 47;
int UP = 36;
int DOWN= 34;
int i = 0;
int D = 32;
int G = 30;
int j = 0;

void setup()
{
  RemoteXY_Init ();
 
  pinMode (PIN_BUTTON_1, OUTPUT);
  pinMode (PIN_BUTTON_2, OUTPUT);
  pinMode(ssd, OUTPUT);     
  pinMode(ssg, OUTPUT);
  pinMode(UP, INPUT_PULLUP);     
  pinMode(DOWN, INPUT_PULLUP);
  pinMode(D, INPUT_PULLUP);
  pinMode(G, INPUT_PULLUP);

  SPI.begin();                 
  Serial.begin(9600);
}
void mastervolume()   
{
  while (RemoteXY.button_1!=1)
{
   j++;
   if(j>127) j=127;
   i++;
   if(i>127) i=127;
   delay(50);
}
while (RemoteXY.button_2!=1)
{
   j--;
   if(j<0) j=0;
   i--;
   if(i<0) i=0;
   delay(50);
}
digitalWrite(ssd,LOW);
SPI.transfer(0);
SPI.transfer(j);
digitalWrite(ssd,HIGH);
digitalWrite(ssg,LOW);
SPI.transfer(0);
SPI.transfer(i);
digitalWrite(ssg,HIGH);
}

void volumespeakerdroit (){

  while (RemoteXY.button_1!=1)
  {
    i++;
    if(i>127) i=127;
    delay(50);
  }
  while (RemoteXY.button_2!=1)
  {
    i--;
    if(i<0) i=0;
    delay(50);
  }

digitalWrite(ssg,LOW);

  SPI.transfer(0);
  SPI.transfer(i);

  digitalWrite(ssg,HIGH);
}

void volumespeakergauche()
{
    while (RemoteXY.button_1!=1)
  {
    j++;
    if(j>127) j=127;
    delay(50);
  }
 
  while (RemoteXY.button_2!=1)
  {
    j--;
    if(j<0) j=0;
    delay(50);
  }
 
    digitalWrite(ssd,LOW);

  SPI.transfer(0);
  SPI.transfer(j);

  digitalWrite(ssd,HIGH);
 
 
}

void loop()
{
  RemoteXY_Handler ();
 
   if (RemoteXY.select_1==2)
{
  volumespeakerdroit();
  }
  else if (RemoteXY.select_1==0)
  {
  volumespeakergauche();
  }
  else if (RemoteXY.select_1==1)
  {
    mastervolume();
  }
{
  Serial.println(j);
  Serial.println(" ");
  Serial.println(i);
  Serial.println(" ");

}
digitalWrite(PIN_BUTTON_1, (RemoteXY.button_1==0)?LOW:HIGH);
digitalWrite(PIN_BUTTON_2, (RemoteXY.button_2==0)?LOW:HIGH);
}


Thank you in advance for the help.

2

Re: HC-05 and arduino mega 2650 (Device not reply. Receive time out error)

I was getting the same sort of error and another with connections.  I dug through the forums and really didn't find the answer I was looking for.

In truth I was torn between posting here, or just giving up and admitting buying the pro version was a wast of money.  Then I decided to just get really basic.  I started a new sketch and just made a small interface in the WEB GUI.  I didn't add any functionality to the buttons, and just loaded that onto an arduino.  I connected successfully with my phone and tablet several times.

After that I slowly started building in functionality to the buttons, testing as I went for connection.  I'm not even sure what in my first code cause the connection hick ups, but I did figure out that it wasn't RemoteXY causing the connection issues, but rather my own code.

Honestly I have less than a year of self taught c++ I'm working with here, so I doubt I'd see anything in your code.  But if you start with the basics and build a little at a time checking the connection as you go...

3

Re: HC-05 and arduino mega 2650 (Device not reply. Receive time out error)

It seems to be as soon as i call multiple things in the void loop(), as soon as i have an else IF or multiple cases in my switch statement. If nayone could help me base on that new information it would be greatly appreciated.

4

Re: HC-05 and arduino mega 2650 (Device not reply. Receive time out error)

Try remove all delay(), replace with the method demonstrated in BlinkWithoutDelay example.