void Now()
{

   // Set device as a Wi-Fi Station and set channel
 //   WiFi.disconnect();

  WiFi.mode(WIFI_STA);

  int32_t channel = getWiFiChannel(WIFI_SSID);

  WiFi.printDiag(Serial); // Uncomment to verify channel number before
  esp_wifi_set_promiscuous(true);
  esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE);
  esp_wifi_set_promiscuous(false);
  WiFi.printDiag(Serial); // Uncomment to verify channel change after

  //Init ESP-NOW
   Serial.println("initializin ESP-NOW");
  if (esp_now_init() != ESP_OK) {
    Serial.println("Error initializing ESP-NOW");
    return;
  }

  // Once ESPNow is successfully Init, we will register for Send CB to
  // get the status of Trasnmitted packet
  esp_now_register_send_cb(OnDataSent);
   Serial.println("Register peer");
  //Register peer
//************************желтые ноги******************
   memcpy(peerInfo.peer_addr, broadcastAddress1, 6);
  if (esp_now_add_peer(&peerInfo) != ESP_OK){
    Serial.println("Failed to add peer");
    return;
  }
  // ************************самоделка************************************
  memcpy(peerInfo.peer_addr, broadcastAddress2, 6);
  if (esp_now_add_peer(&peerInfo) != ESP_OK){
    Serial.println("Failed to add peer");
    return;
  }
  //****************************************************************************
//   memcpy(peerInfo.peer_addr, broadcastAddress3, 6);
//  if (esp_now_add_peer(&peerInfo) != ESP_OK){
 //   Serial.println("Failed to add peer");
 //   return;
 // }
 //*********************************************************************************************** 
readingId = tHour*100+tMin;
Serial.println("DATA");

    myData.id = BOARD_ID;
    myData.temp = htu.readTemperature();
    myData.hum = htu.readHumidity();
    myData.readingId = readingId;
    myData.bat = volt;
     
    //Send message via ESP-NOW
  //  esp_err_t result = esp_now_send(broadcastAddress2, (uint8_t *) &myData, sizeof(myData));//отправка по конкретному адр
   esp_err_t result = esp_now_send(0, (uint8_t *) &myData, sizeof(myData));//отправка по всем адресам
    if (result == ESP_OK) {
      Serial.println("Sent with success");
    }
    else {
      Serial.println("Error sending the data");
    }
  

  
  
}





void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
  Serial.print("\r\nLast Packet Send Status:\t");
  Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail");
}




int32_t getWiFiChannel(const char *ssid) {
  if (int32_t n = WiFi.scanNetworks()) {
      for (uint8_t i=0; i<n; i++) {
          if (!strcmp(ssid, WiFi.SSID(i).c_str())) {
              return WiFi.channel(i);
          }
      }
  }
  return 0;
}
