- Notifications
You must be signed in to change notification settings - Fork7.8k
Closed
Description
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>constexpruint8_t LED_PIN =8;constexpruint8_t NUM_LEDS =1;Adafruit_NeoPixelrgbLed(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);structRGB {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*/#defineTHERMOSTAT_ENDPOINT_NUMBER5#defineSWITCH_ENDPOINT_NUMBER6uint8_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;unsignedlong currentmillis;unsignedlong previousmillis;unsignedlong previousmillis1 =0;unsignedlong extramillis =0;constunsignedlong period1 =1000;constunsignedlong period2 =10000;constunsignedlong period3 =60000;constunsignedlong period5 = rem *1000;constunsignedlong period4 =100;float manualMinTemp =0.0;float manualMaxTemp =100.0;float manualTolerance =0.1;voidsetColor(const RGB &color) { rgbLed.setPixelColor(0, rgbLed.Color(color.r, color.g, color.b)); rgbLed.show();}/****************** Temperature sensor handling *******************/voidrecieveSensorTemp(float temperature) {setColor(COLOR_OFF);delay(200);setColor(CUSTOM_COLOR);}/********************* Arduino functions **************************/voidmanualConfigCallback(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;}voidsetup() { Serial.begin(115200);setColor(CUSTOM_COLOR);// Init button switchpinMode(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 modeif (!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);}voidloop() {if (Serial.available() >0) { String input = Serial.readStringUntil('\n'); input.trim();if (input =="PING") { recCon =true; Serial.println("PONG");delay(100); }elseif (input.equalsIgnoreCase("change")) { rem =40;if (isOperational) { isOperational =false; isBroadcasting =true; Zigbee.openNetwork(rem); previousmillis =millis(); previousmillis1 =millis(); }elseif (isBroadcasting) { isOperational =true; isBroadcasting =false; } }elseif (input.equalsIgnoreCase("s")) { zbSwitch.setLightLevel(2); }elseif (input.equalsIgnoreCase("b")) {if (light) { zbSwitch.setLightLevel(3); light =false; }else { zbSwitch.setLightLevel(9); light =true; } }elseif (input.equalsIgnoreCase("0")) { zbSwitch.setLightLevel(0); }elseif (input.equalsIgnoreCase("1")) { zbSwitch.setLightLevel(1); }elseif (input.equalsIgnoreCase("t")) { zbSwitch.setLightLevel(4); }elseif (input.equalsIgnoreCase("c")) { zbSwitch.setLightLevel(5); }elseif (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 handlingwhile (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.