Radio Thermostat Project - Communication issues...

This is something I had been working on a few months back and have just found the time to return to.
Basically, it will be a simple wireless sensor which uses the Radiohead library to send an ‘on’ or ‘off’ signal to another Arduino connected to a relay then heating system.
Temp stats will be sent for storage elsewhere also.
Once a command is received, a confirmation will be sent back for power saving options etc.

I did have the communication working at some point but it looks like I must have changed something stupid.

Any comment appreciated; thanks for looking.

Here is the code:

Transmitter:

#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile
#include "DHT.h"

#define DHTPIN 2     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)

DHT dht(DHTPIN, DHTTYPE);
RH_ASK driver;

struct dataStruct{
  float hum; 
  float temp;
  unsigned long counter;
}myData;

byte tx_buf[sizeof(myData)] = {0};


void setup()
{
    Serial.begin(9600);    // Debugging only
    if (!driver.init())
         Serial.println("init failed");
           dht.begin();
             pinMode(13, OUTPUT);           
}

void loop()
{

// Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius
  float t = dht.readTemperature();

  myData.hum=h;
    myData.temp=t; 

//   Serial.println(myData.temp);
//   Serial.println(myData.hum);
    
  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }


    byte on[] = {104, 189, 162};
   byte off[] = {140, 198, 126};
static unsigned long millisLast = millis();
      long interval = 10000; //send every 10 seconds

  if(millis() - millisLast > interval){

/*
  memcpy(tx_buf, &myData, sizeof(myData) );
  byte zize=sizeof(myData);

*/

 /* 

 driver.send((uint8_t *)tx_buf, zize);
  
  driver.waitPacketSent();
    myData.counter++;
    delay(2000);

*/

// Example commands to turn on or off the heating, either via relay or servo on existing thermostat...

    driver.send(on, sizeof(on));
    driver.waitPacketSent();
    Serial.print("On");
    digitalWrite(13, HIGH); 
    delay(800);

     driver.send(off, sizeof(off));
    driver.waitPacketSent();
    Serial.print("Off");
    digitalWrite(13, LOW);
    delay(800);
    
    millisLast = millis();
 /* 
    Serial.print("Humidity: "); 
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperature: "); 
  Serial.print(t);
  Serial.println(" *C ");
  */
  }
}

Receiver

#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile

RH_ASK driver;

void setup()
{
    Serial.begin(9600);  // Debugging only
    if (!driver.init())
         Serial.println("init failed");
         pinMode(13, OUTPUT);
}

void loop()
{
  
  byte Data[3] = {};
  uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
  uint8_t buflen = sizeof(buf);

  byte ok[] = {132, 173, 111};



    
    if (driver.recv(buf, &buflen)) // Non-blocking
    {
  //    int i;
      // Message with a good checksum received, dump it.
    //  Serial.println((char*)buf);         
   // }
   // if (((char*)buf) == "A") {
 //   if (((strcmp() == "A") {

// driver.printBuffer("Got:", buf, buflen);
    
  //  Serial.println("Received");
    
    memcpy (&Data, buf, buflen);
    
   for (int i=0; i<3; i++){
//    Serial.println(Data[i]);
int a = (Data[i]);
    if (a == (104, 189, 162)) {
        Serial.println("This would turn it on..."); 
        digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
        }

//confirmation message sent to master controller.
//Consider making two messages, on ok, off ok.

driver.send(ok, sizeof(ok));
    driver.waitPacketSent();
    delay(12000);


        if (a == (140, 198, 126)) {
        Serial.println("This would turn it off..."); 
          digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW        
        }

        driver.send(ok, sizeof(ok));
    driver.waitPacketSent();
    delay(12000);


 /*      else {
        Serial.println(a);
       }

       Serial.println(Data[0,2]);
   */    }

 /*      if (Data[2] == 162 || 126) {
        Serial.println("Even this works...");
       }
       else {
        Serial.println("Shit.");
       } */
       }
}
  //      else {
    //      Serial.println("Shit.");
   //

And now it’s working…
Looks like it was a bad connection…