Go Down

Topic: Can anyone help me? (Read 114 times) previous topic - next topic

Ard666

How to automaticly switch off relay when bluetooth module not connected with android?


Robin2

The simplest way is to send a message at regular intervals (perhaps 5 per second) and when the Arduino fails to get a message in time it will know that there has been a communication failure.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Ard666

The simplest way is to send a message at regular intervals (perhaps 5 per second) and when the Arduino fails to get a message in time it will know that there has been a communication failure.

...R
could you give me example code please sir..

Robin2

#3
Aug 13, 2017, 08:20 pm Last Edit: Aug 13, 2017, 08:21 pm by Robin2
I am guessing, from your Original Post, that you already have a program that sends data using Buetooth so please post that program.

You need to add some code on the receiving side something like this

Code: [Select]
if (newData == true) {    // when a new message arrives
   lastestMessageMillis = millis();
}

if (millis() - lastestMessageMillis >= maxIntervalMillis) {
  // the next message has failed to arrive
}



...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up