2

I am attempting to connect an Arduino Uno to a Modern Device RBB Arduino. One is the base and the other the remote. They need to set up a simple handshake to communicate an on and off condition from the remote.The hardware and software work for both the base and remote using Tera Term to simulate the opposite node. I am running Tera Term on a notebook connecting to the node through a BT dongle. In other words if I manually respond to the opposite node on the Tera Term they both operate as they should individually. When I try to get them to interact autonomously they will not handshake. The HC05s are paired and connected but the handshake data will not flow back and forth.

Remote Code:

 int pinInt =2; //interrupt pin

 int ack = 2; //acknowledge

 void setup() {

  pinMode(3,OUTPUT); //power to bluetooth

  pinMode(pinInt,INPUT); //interrupt pin mode

}
// Still needs sleep and interrupt processing

  void loop() {

  delay(5000);//sim sleep remove or adjust for wake up delay


  digitalWrite(3,HIGH);//switches power to bluetooth

  delay(10000);//BT active adjust as necessary

  Serial.begin(9600); 

  Serial.print('?');//send am I connected

   while(Serial.available()==0){}//idle until incoming serial

     int heatCall=digitalRead(pinInt);//read interrupt pin

     if (Serial.available() > 0) {ack = Serial.read();}//read ack

     if (ack=='1'){Serial.print(heatCall);}//send state of heatCall

  while(Serial.available()==0){}//idle until incoming serial

    if (Serial.available() > 0) {ack = Serial.read();}//read ack

    if (ack=='0'){Serial.end();digitalWrite(3,LOW);}//BT off 

   //sleepNow();//put back to sleep


}

Base Code:

int relayPin =13; //relay pin

 char itsOn = 0; //remote calling variable

 int heatCall = 0; //state of TH135

 int ack = 2; //hand shake

  void setup() {

  pinMode(relayPin,OUTPUT); //power to relay
  Serial.begin(9600);
}

  void loop() {

  while (Serial.available()==0);{}//idle until incoming serial

  if (Serial.available() > 0) {itsOn = Serial.read();//remote calling

    if (itsOn=='?')ack=1;Serial.print(ack);}//send connected ack

  while (Serial.available()==0);{}//idle until incoming serial

  if (Serial.available() > 0) {heatCall = Serial.read();}//incoming heatCall

    if (heatCall=='1'){digitalWrite(relayPin,HIGH);}//turn zone relay ON

     else {digitalWrite(relayPin,LOW);}//turn zone relay OFF

  delay(5000);
  ack=0;
  Serial.print(ack);//turn remote BT OFF
  }

Is there some BT protocol that I am missing?

UPDATE: I have determined that data is being transferred from remote to base and back. The data is not the expected values.

VE7JRO
  • 2,515
  • 19
  • 27
  • 29
Alan
  • 21
  • 4

0 Answers0