Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zigbee - Only Four of Six Temperature Sensors Appear as Bound Devices #11219

Open
1 task done
dosportsglobal opened this issue Apr 5, 2025 · 1 comment
Open
1 task done
Assignees
Labels
Area: Zigbee Issues and Feature Request about Zigbee Status: Awaiting triage Issue is waiting for triage

Comments

@dosportsglobal
Copy link

Board

ESP32-C6-WROOM 1

Device Description

DevKitC

Hardware Configuration

No.

Version

latest stable Release (if not listed below)

IDE Name

Arduino Ide

Operating System

Windows 10

Flash frequency

80Mhz

PSRAM enabled

yes

Upload speed

921600

Description

I am attempting to connect six temperature sensors to a thermostat using an ESP32-C6 with Zigbee configuration. However, when I print the list of bound devices, only the first four sensors appear. Could you please advise why the remaining two sensors are not being recognized?

Sketch

#ifndef ZIGBEE_MODE_ZCZR
#error "Zigbee coordinator mode is not selected in Tools->Zigbee mode"
#endif

#include <set>
#include "Zigbee.h"
#include <Adafruit_NeoPixel.h>

constexpr uint8_t LED_PIN = 8;
constexpr uint8_t NUM_LEDS = 1;
Adafruit_NeoPixel rgbLed(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);

struct RGB {
  uint8_t r, g, b;
};

constexpr RGB COLOR_OFF = { 0, 0, 0 };
constexpr RGB CUSTOM_COLOR = { 0, 255, 255 };
constexpr RGB CUSTOM_COLOR1 = { 255, 0, 0 };
constexpr RGB CUSTOM_COLOR2 = { 100, 100, 50 };

bool light = false;

/* Zigbee thermostat configuration */
#define THERMOSTAT_ENDPOINT_NUMBER 5
#define SWITCH_ENDPOINT_NUMBER 6
uint8_t button = BOOT_PIN;

ZigbeeThermostat zbThermostat = ZigbeeThermostat(THERMOSTAT_ENDPOINT_NUMBER);
ZigbeeColorDimmerSwitch zbSwitch = ZigbeeColorDimmerSwitch(SWITCH_ENDPOINT_NUMBER);
int rem = 40;
bool isOperational = true;
bool isBroadcasting = false;
bool recCon = false;
std::set<uint64_t> connectedDevices;
unsigned long currentmillis;
unsigned long previousmillis;
unsigned long previousmillis1 = 0;
unsigned long extramillis = 0;
const unsigned long period1 = 1000;
const unsigned long period2 = 10000;
const unsigned long period3 = 60000;
const unsigned long period5 = rem * 1000;
const unsigned long period4 = 100;

float manualMinTemp = 0.0;
float manualMaxTemp = 100.0;
float manualTolerance = 0.1;

void setColor(const RGB &color) {
  rgbLed.setPixelColor(0, rgbLed.Color(color.r, color.g, color.b));
  rgbLed.show();
}
/****************** Temperature sensor handling *******************/
void recieveSensorTemp(float temperature) {
  setColor(COLOR_OFF);
  delay(200);
  setColor(CUSTOM_COLOR);
}
/********************* Arduino functions **************************/

void manualConfigCallback(float minTemp, float maxTemp, float tolerance) {
  Serial.print("Setting manual config: ");
  Serial.print(minTemp);
  Serial.print(" - ");
  Serial.print(maxTemp);
  Serial.print(" (Tolerance: ");
  Serial.print(tolerance);
  Serial.println(")");

  // Store values (if needed for later use)
  manualMinTemp = minTemp;
  manualMaxTemp = maxTemp;
  manualTolerance = tolerance;
}


void setup() {
  Serial.begin(115200);
  setColor(CUSTOM_COLOR);

  // Init button switch
  pinMode(button, INPUT_PULLUP);

  // Set callback functions for temperature and configuration receive
  zbThermostat.onTempRecieve(recieveSensorTemp);
  zbThermostat.onConfigRecieve(manualConfigCallback);

  // Manually trigger the config callback


  //Optional: set Zigbee device name and model
  zbThermostat.setManufacturerAndModel("Espressif", "ZigbeeThermostat");
  zbSwitch.setManufacturerAndModel("Espressif", "ZigbeeSwitch");

  zbThermostat.allowMultipleBinding(true);
  zbSwitch.allowMultipleBinding(true);

  //Add endpoint to Zigbee Core
  Zigbee.addEndpoint(&zbThermostat);
  Zigbee.addEndpoint(&zbSwitch);

  // When all EPs are registered, start Zigbee with ZIGBEE_COORDINATOR mode
  if (!Zigbee.begin(ZIGBEE_COORDINATOR)) {
    Serial.println("Zigbee failed to start!");
    Serial.println("Rebooting...");
    ESP.restart();
  }

  if (zbThermostat.bound()) {
    Zigbee.factoryReset();
    delay(1000);
    ESP.restart();
  }

  Serial.println("Network Initialized");
  manualConfigCallback(manualMinTemp, manualMaxTemp, manualTolerance);
}

void loop() {

  if (Serial.available() > 0) {
    String input = Serial.readStringUntil('\n');
    input.trim();
    if (input == "PING") {
      recCon = true;
      Serial.println("PONG");
      delay(100);
    } else if (input.equalsIgnoreCase("change")) {
      rem = 40;
      if (isOperational) {
        isOperational = false;
        isBroadcasting = true;
        Zigbee.openNetwork(rem);
        previousmillis = millis();
        previousmillis1 = millis();
      } else if (isBroadcasting) {
        isOperational = true;
        isBroadcasting = false;
      }
    } else if (input.equalsIgnoreCase("s")) {
      zbSwitch.setLightLevel(2);
    } else if (input.equalsIgnoreCase("b")) {
      if (light) {
        zbSwitch.setLightLevel(3);
        light = false;
      } else {
        zbSwitch.setLightLevel(9);
        light = true;
      }
    } else if (input.equalsIgnoreCase("0")) {
      zbSwitch.setLightLevel(0);
    } else if (input.equalsIgnoreCase("1")) {
      zbSwitch.setLightLevel(1);
    } else if (input.equalsIgnoreCase("t")) {
      zbSwitch.setLightLevel(4);
    } else if (input.equalsIgnoreCase("c")) {
      zbSwitch.setLightLevel(5);
    } else if (input.startsWith("channel")) {
      zbSwitch.printBoundDevices(Serial);
      zbThermostat.printBoundDevices(Serial);
      int inputInt = input.substring(7).toInt();

      if (inputInt >= 1 && inputInt <= 14) {
        // Switch to the operational channel

      } else {
      }
    }
  }

  if (isBroadcasting) {
    currentmillis = millis();
    if (currentmillis - previousmillis >= period5) {
      isOperational = true;
      isBroadcasting = false;
    }
    if (currentmillis - previousmillis1 >= period1) {
      previousmillis1 = currentmillis;
      rem--;
      Serial.println("Time: " + String(rem));
    }
  }

  if (digitalRead(button) == LOW) {  // Push button pressed
    // Key debounce handling
    while (digitalRead(button) == LOW) {
      setColor(CUSTOM_COLOR2);
    }
    // Toggle light
    zbSwitch.lightToggle();
    setColor(CUSTOM_COLOR1);
    zbThermostat.printBoundDevices(Serial);
  }
}

Debug Message

Nothing like this.

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@dosportsglobal dosportsglobal added the Status: Awaiting triage Issue is waiting for triage label Apr 5, 2025
@SuGlider SuGlider added the Area: Zigbee Issues and Feature Request about Zigbee label Apr 6, 2025
@P-R-O-C-H-Y P-R-O-C-H-Y self-assigned this Apr 7, 2025
@P-R-O-C-H-Y P-R-O-C-H-Y changed the title Only Four of Six Temperature Sensors Appear as Bound Devices Zigbee - Only Four of Six Temperature Sensors Appear as Bound Devices Apr 7, 2025
@P-R-O-C-H-Y
Copy link
Member

Hi @dosportsglobal Thank you for the report. Can you also include some logs? And are the 6 sensors really connected?
Just to clarify, you are using 6 ESPs with temperature sensor example or some manufactured Zigbee temp sensors?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Zigbee Issues and Feature Request about Zigbee Status: Awaiting triage Issue is waiting for triage
Projects
None yet
Development

No branches or pull requests

3 participants