luar123 / esphome_zb_sensor

Example of a zigbee sensor in esphome
37 stars 6 forks source link

How did you make ESP32c6 support Zigbee and use zha to configure it #22

Closed jjcszxh closed 4 months ago

jjcszxh commented 4 months ago
esphome:
  name: ${node_name}
  platformio_options:
    platform: https://github.com/luar123/platform-espressif32H2/archive/refs/tags/v6.5.1.zip
  includes:
    - esphome_zb.h
    - esp_zb_light.c
    - esp_zb_light.h

esp32:
  board: esp32-c6-devkitc-1
  variant: esp32c6
  flash_size: 8MB
  framework:
    #platform_version: 6.6.0 no
    #platform_version: 6.5.0
    type: esp-idf
    #version: 5.2.1 no
    version: 5.1.2
    sdkconfig_options:
      CONFIG_ESPTOOLPY_FLASHSIZE_8MB: y
      CONFIG_ZB_ENABLED: y
      CONFIG_ZB_ZED: y
      CONFIG_ZB_RADIO_NATIVE: y
      ZB_ED_ROLE: y

logger:
 # hardware_uart: USB_CDC
  level: ${node_logger_level}

i2c:
  sda: 6
  scl: 7

sensor:
  - platform: bh1750
    name: "${node_name}_BH1750_Illuminance"
    address: 0x23
    update_interval: 60s
    on_value:
      then:
        - lambda: |-
              int16_t value = (int16_t)(x*100);
              reportAttribute(ESP_ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT, ESP_ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID, &value);

custom_component:
- lambda: |-
    auto my_zb = new esphomeZB();
    return {my_zb};
  components:
  - id: zb

Unfortunately, the log reported an error

I (39) boot.esp32c6: SPI Flash Size : 8MB
I (44) boot: Enabling RNG early entropy source...
I (49) boot: Partition Table:
I (53) boot: ## Label            Usage          Type ST Offset   Length
I (60) boot:  0 otadata          OTA data         01 00 00009000 00002000
I (68) boot:  1 phy_init         RF data          01 01 0000b000 00001000
I (75) boot:  2 app0             OTA app          00 10 00010000 003c0000
I (82) boot:  3 app1             OTA app          00 11 003d0000 003c0000
I (90) boot:  4 nvs              WiFi data        01 02 00790000 0006d000
I (98) boot: End of partition table
I (102) esp_image: segment 0: paddr=00010020 vaddr=42070020 size=11838h ( 71736) map
I (140) esp_image: segment 1: paddr=00021860 vaddr=40800000 size=0c744h ( 51012) load
I (164) esp_image: segment 2: paddr=0002dfac vaddr=4080c750 size=017c4h (  6084) load
I (169) esp_image: segment 3: paddr=0002f778 vaddr=00000000 size=008a0h (  2208) 
I (171) esp_image: segment 4: paddr=00030020 vaddr=42000020 size=651b8h (414136) map

[18:14:09.444]攢←◆I (352) boot: Loaded app from partition at offset 0x10000
I (353) boot: Disabling RNG early entropy source...
I (364) cpu_start: Unicore app
I (365) cpu_start: Pro cpu up.

[18:14:09.481]攢←◆W (374) clk: esp_perip_clk_init() has not been implemented yet
I (381) cpu_start: Pro cpu start user code
I (381) cpu_start: cpu freq: 160000000 Hz
I (381) cpu_start: Application information:
I (384) cpu_start: Project name:     esp32-c6
I (389) cpu_start: App version:      2024.3.2
I (394) cpu_start: Compile time:     Apr 10 2024 10:12:08
I (400) cpu_sta
[18:14:09.530]攢←◆rt: ELF file SHA256:  0b00b828301fee35...
I (406) cpu_start: ESP-IDF:          5.1.2
I (411) cpu_start: Min chip rev:     v0.0
I (415) cpu_start: Max chip rev:     v0.99 
I (420) cpu_start: Chip rev:         v0.0
I (425) heap_init: Initializing. RAM available 
[18:14:09.559]攢←◆for dynamic allocation:
I (432) heap_init: At 40816E10 len 00065800 (406 KiB): D/IRAM
I (438) heap_init: At 4087C610 len 00002F54 (11 KiB): STACK/DIRAM
I (445) heap_init: At 50000000 len 00003FE8 (15 KiB): RTCRAM
I (452) spi_flash: detected chip: generic
I (456) spi_flash: flash io: dio
I (460) sleep: Configure to isolate all GPIO pins in sleep state
I (467) sleep: Enable automatic switching of GPIO sleep configuration
I (474) coexist: coex firmware version: b6d5e8c
I (479) coexist: coexist rom version 5b8dcfa
I (4
[18:14:09.615]攢←◆84) app_start: Starting scheduler on CPU0
I (489) main_task: Started on CPU0
I (493) main_task: Calling app_main()

[18:14:09.688]攢←◆[0[I][logger:158]: Log initialized
[W][app:02
[18:14:09.715]攢←◆2]: Component custom_component already registered! (0x4081d5c0)
[I][app:029]: Running through setup()...
[C][i2c.idf:017]: Setting up I2C bus...
[I][i2c.idf:233]: Performing I2C bus recovery
[D][esp-idf:000]: [0
[18:14:09.747]攢←◆;32mI (599) gpio: GPIO[7]| InputEn: 1| OutputEn: 1| OpenDrain: 1| Pullup: 1| Pulldown: 0| Intr:0 

[D][esp-idf:000]: I (609) gpio: GPIO[6]| InputEn: 1| OutputEn: 1| OpenDrain: 1| Pullup: 1| Pulldown: 0| Intr:0 

[C][bh1750.sensor:041]: Setting up BH1750 'esp32-c6_BH1750_Illuminance'...
[18:14:09.792]攢←◆
assert failed: zb_osif_nvram_init zb_esp_nvram.c:65 (zb_partition != NULL)
Core  0 register dump:
MEPC    : 0x4080162a  RA      : 0x40806dce  SP      : 0x4081e3f0  GP      : 0x4080cf50  
TP      : 0x4080d920  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130  
S0/FP   : 0x00000001  S1      : 0x4081e
[18:14:09.842]攢←◆55a  A0      : 0x4081e448  A1      : 0x4080d1d5  
A2      : 0x00000001  A3      : 0x00000029  A4      : 0x00000001  A5      : 0x40817000  
A6      : 0x0000000c  A7      : 0x76757473  S2      : 0x0000007d  S3      : 0x4081e448  
S4      : 0x4081e448  S5      : 0x4207e480  S6      : 0x00000000  S7      : 0x00000000  
S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938  
MSTATUS : 0x00001881  MTVEC   : 0x40800001  MCAUSE  : 0x00000007  MTVAL   :
[18:14:09.893]攢←◆ 0x00000000  
MHARTID : 0x00000000  

Stack memory:
4081e3f0: 0x00000000 0x00000000 0x4207e430 0x4080b888 0x00000000 0xffffffff 0x408179e4 0x4080d1d4
4081e410: 0x00003536 0x00000000 0x00000000 0x00000000 0x00000000 0x4080d6d4 0x4207e4bc 0x4080d9b4
4081e430: 0x4207e480 0x4080d6e4 0x4081e410 0x4080d6e8 0x4207e430 0x4080d1d4 0x65737361 0x66207472
4081e450: 0x656c6961 0x7a203a64 0x736f5f62 0x6e5f6669 0x6d617276 0x696e695f 0x627a2074 0x7073655f
4081e470: 0x72766e5f 0x632e6d61 0x2035363a 0x5f627a28 0x74726170 0x6f697469 0x3d21206e 0x4c554e20
4081e490: 0x4000294c 0x40
[18:14:09.937]攢←◆880000 0x40816e10 0x40022574 0x00000000 0x00000000 0x4087cdb8 0x40806edc
4081e4b0: 0x00000000 0x00000000 0x4087cdb8 0x40807412 0x00000001 0x00000000 0x00000000 0x00000000
4081e4d0: 0x00000000 0x00000000 0x00000000 0x000000ff 0x40880000 0x40818d90 0x40816e10 0x400225ca
4081e4f0: 0x40817000 0x00000000 0x40818d90 0x4205fc3a 0x00000000 0x00000000 0x00000000 0x00000000
4081e510: 0x4207c000 0x00000000 0x00000000 0x00000000 0x4207c000 0x40814edc 0x4080eedc 0x42057a7e
4081e530: 0xa5a5a5a5 0xa5a5a5a5 0x4081e5b0 0x42029930 0x00000000 0x00000000 0x4081e5b0 0x4201d596
4081e550: 0xa5a5a5a5 0xa5a5a5a5 0x00000000 0x4200007e 0x42000054 0x00000000 0x00000000 0x4080cf50
4081e570: 0x4080d920 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4081e590: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4081e5b0: 0x00000002 0x00000000 0x00000006 0x00000bb8 0x00000000 0x00000000 0x00000000 0x00000000
4081e5d0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4081e5f0: 0x00000000 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0x0005e001 0x40816e24
4081e610: 0x40816e24 0x8ad9bc2d 0x1b0df259 0xdc7d74d4 0x7dab6341 0x52d8962d 0xb649919c 0x815aa39a
4081e630: 0xe0866e42 0xce9da3c0 0x36736015 0xab384e21 0x115d90be 0x1858dd94 0xff95120c 0x8813888d
4081e650: 0x2d0ddaa0 0x6bb87306 0x2d8875a0 0x51
[18:14:10.057]攢←◆48b263 0x35e24b03 0xd73b3c60 0xd0b2cc7e 0x53aa4813
4081e670: 0xc7f6950b 0x40baf843 0xaf79268b 0x6904eee8 0x3ba54f51 0x37ed1699 0x79e39684 0xacacc941
4081e690: 0xf756bbc4 0xfb8eacb4 0xa0325e80 0x187f9d68 0x7a4de21a 0x9f2a523f 0x5b934498 0x6dc6176a
4081e6b0: 0xceab1bc1 0x5f0843bb 0x376f5cb0 0x09e86bd6 0xa7a8037b 0xbad22772 0xa45f8260 0x78ecdeca
4081e6d0: 0x434d9699 0x82928726 0x5ebc5864 0xbd11028f 0xb8e3882d 0x1de6cb73 0x0e10ddfb 0xfc6ea708
4081e6f0: 0xc1dba7f4 0x78acb6e7 0x397387b5 0x9988fad8 0xc725d613 0x8311eac1 0x937fca17 0x4f8f840c
4081e710: 0x3f68768a 0xaa996147 0x91668e32 0xafdbd669 0x7bcba048 0xa2be9c8c 0x3e4a887b 0x78b63c2c
4081e730: 0x61106751 0x7f66f315 0x7abedd42 0x65a83742 0xae27d0b3 0x5c6e3a97 0x1e4d6736 0xee592fac
4081e750: 0xd5c53b50 0xe48b8c65 0xfe423c3d 0xa0bcbf6f 0x71d41851 0xec897af6 0x0fc72538 0x5b3872de
4081e770: 0x9cd5dec3 0x3401b7cb 0xa115f331 0x4f9c8ea4 0x64db7cb4 0x78d5a4cf 0x990c0d87 0x95135d57
4081e790: 0x460b6925 0x5b3978cf 0x000d0487 0x43900c8c 0x0b0ba6a2 0x3de5cc5d 0xa7cc33b1 0xe8727b4c
4081e7b0: 0x9b0c2423 0x2f08fbfc 0xf24ca804 0xb1205be8 0x659b7016 0x376557b0 0xc9ddaf6e 0x257da48b
4081e7d0: 0xc8880f24 0xc9d7b6a6 0xeed0bca7 0xbe6ef643 0x48856c67 0x855466af 0x1ef17d92 0x44768b60
luar123 commented 4 months ago

You need to use the partition table from my setup. And it is always a good idea to erase the complete flash before flashing.

lboue commented 4 months ago

You need to use the partition table from my setup.

@luar123 Check this branch: ZB_C6_sensor

You are using another sensor: BH1750 Ambient Light Sensor. I haven't tested this sensor so I wouldn't know.

Did you try with ESP32-H2?

jjcszxh commented 4 months ago

According to your partition table, I have successfully connected to zha, but my esp32c6 is 8mbflash. How should I write the partition table