1

Topic: Lost connection

Hi
Can you help me to solve a problem when the connection is lost.

I need a code to reboot Arduino when the connection between HC-05(06) Bluetooth module and android is lost.

2

Re: Lost connection

Hello,
try to use the variable 'connect_flag' in RemoteXY structure.

3

Re: Lost connection

Thanks

I am a beginner and I don't understand how to use 'connect_flag'.
Can you please explain me in more detail.

4

Re: Lost connection

same issue of lost connection. Not sure how to use connect flag either.

5

Re: Lost connection

Welcome,

Something like this:

void loop()
{
  RemoteXY_Handler ();

  static bool wasConnected = false;
  if ( wasConnected == false )
  {
    if ( RemoteXY.connect_flag == 1 )
    {
      wasConnected = true;
      Serial.println( "Connected..." );
    }
  }
  else if ( RemoteXY.connect_flag == 0 )
  {
    wasConnected = false;
    Serial.println( "Connection lost, rebooting..." );
    rebootArduino();
  }
}

6 (edited by hefest 2018-03-13 19:42:35)

Re: Lost connection

Suggested method are not working!!!

connect_flag always  has zero value and can not be used at all.

It could be even removed from the structure since it is defined only there.  It is dangerous to use use RemoteXY for anything else than toys. Just imagine electric motor remained engaged "forever" even if command link from the smartphone are broken.