Bonjour,
et mes meilleurs voeux à toutes et à tous pour cette nouvelle année
Mon problème :
Depuis quelques semaines je m’aventure dans le domaine de la programation des ESP32 via ESPHOME.
En fait, en début d’année 2024 j’avais acquis ce petit « jouet » : KEYESTUDIO ESP32 Smart Home pour faire découvrir la domotique à mon petit-fils.
La « Smart home » est basée sur un ESP32-Wroom-32 et est programmable via Arduino IDE. J’avais testé tous les exemples fournis avec le kit pour faire fonctionner tous les capteurs/déclencheurs. Mais aucun exemple n’avait été donné pour le RC522 et je ne l’avais donc pas testé ce capteur.
Ayant acquis récemment des ESP32 et différents capteurs/déclencheurs j’ai commencé à me familiariser avec ESPHOME. Et du coup, j’ai ressorti la « Smart Home » que j’ai entièrement reprogrammée avec ESPHOME. Tout a bien fonctionné sauf quand j’ai voulu configurer le module NFC RFID RC522 (avec le bus I2C). Quoi que je fasse, j’obtiens toujours ce message : " Communication with the MFRC522 might be down, reset in… "
J’ai fait des tests avec 3 autres ESP32, même résultats. Obstiné, j’ai acquis un module NFC PN532 que j’ai testé sous bus I2C et SPI : même résultats.
Ma configuration
substitutions:
device_name: esp32-wroom3
friendly_name: ESP32-Wroom3
esphome:
name: $device_name
friendly_name: $friendly_name
esp32:
board: esp32dev
framework:
type: arduino
api:
encryption:
key: "***"
ota:
- platform: esphome
password: "***"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
power_save_mode: none
ap:
ssid: "Esp32-Wroom3 Fallback Hotspot"
password: "***"
web_server:
port: 80
logger:
# =============================================
switch:
- platform: restart
name: "Redémarrage"
binary_sensor:
- platform: status
name: "Statut"
- platform: rc522
uid: 74-10-37-94
name: "RC522 RFID Tag"
sensor:
- platform: wifi_signal
name: "Signal wifi"
update_interval: 60s
- platform: uptime
name: "Allumé depuis (s)"
id: uptime_sec
- platform: homeassistant
name: "DHT_temp"
entity_id: sensor.esp32_wroom3_temperature
id: DHT_temp
- platform: homeassistant
name: "DHT_humi"
entity_id: sensor.esp32_wroom3_humidity
id: DHT_humi
- platform: dht
pin: GPIO13
temperature:
name: "Temperature"
humidity:
name: "Humidity"
update_interval: 30s
text_sensor:
- platform: template
name: "Allumé depuis (j)"
lambda: |-
int seconds = (id(uptime_sec).state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
icon: mdi:clock-start
update_interval: 60s
i2c:
- id: i2c_rc522
sda: 21
scl: 22
scan: True
rc522_i2c:
update_interval: 1s
on_tag:
then:
- lambda: ESP_LOGI("TAG", "received tag %s", x.c_str());
- homeassistant.tag_scanned: !lambda 'return x;'
- homeassistant.tag_scanned: "1647562759"
Traces
INFO ESPHome 2024.12.2
INFO Reading configuration /config/esphome/esp32-wroom3.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing esp32-wroom3 (board: esp32dev; framework: arduino; platform: platformio/espressif32@5.4.0)
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
- toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Dependency Graph
|-- AsyncTCP-esphome @ 2.1.4
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.2.2
|-- ESPmDNS @ 2.0.0
|-- noise-c @ 0.1.6
|-- Wire @ 2.0.0
|-- ArduinoJson @ 6.18.5
RAM: [= ] 12.5% (used 40836 bytes from 327680 bytes)
Flash: [===== ] 53.2% (used 976657 bytes from 1835008 bytes)
========================= [SUCCESS] Took 18.29 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 192.168.1.223 port 3232...
INFO Connected to 192.168.1.223
INFO Uploading /data/build/esp32-wroom3/.pioenvs/esp32-wroom3/firmware.bin (982432 bytes)
Uploading: [============================================================] 100% Done...
INFO Upload took 10.66 seconds, waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 192.168.1.223 using esphome API
INFO Successfully connected to esp32-wroom3 @ 192.168.1.223 in 7.137s
INFO Successful handshake with esp32-wroom3 @ 192.168.1.223 in 0.108s
[22:52:44][I][app:100]: ESPHome version 2024.12.2 compiled on Jan 6 2025, 21:14:06
[22:52:44][C][wifi:600]: WiFi:
[22:52:44][C][wifi:428]: Local MAC: CC:DB:A7:8F:B5:30
[22:52:44][C][wifi:433]: SSID: 'poudou99'[redacted]
[22:52:44][C][wifi:436]: IP Address: 192.168.1.223
[22:52:44][C][wifi:440]: BSSID: 44:D4:53:92:AD:D8[redacted]
[22:52:44][C][wifi:441]: Hostname: 'esp32-wroom3'
[22:52:44][C][wifi:443]: Signal strength: -70 dB ▂▄▆█
[22:52:44][C][wifi:447]: Channel: 1
[22:52:44][C][wifi:448]: Subnet: 255.255.255.0
[22:52:44][C][wifi:449]: Gateway: 192.168.1.1
[22:52:44][C][wifi:450]: DNS1: 192.168.1.1
[22:52:44][C][wifi:451]: DNS2: 0.0.0.0
[22:52:44][W][homeassistant.sensor:015]: 'sensor.esp32_wroom3_humidity': Can't convert 'unknown' to number!
[22:52:44][D][sensor:094]: 'DHT_humi': Sending state nan with 1 decimals of accuracy
[22:52:44][C][logger:185]: Logger:
[22:52:44][C][logger:186]: Level: DEBUG
[22:52:44][C][logger:188]: Log Baud Rate: 115200
[22:52:44][C][logger:189]: Hardware UART: UART0
[22:52:44][C][i2c.arduino:071]: I2C Bus:
[22:52:44][C][i2c.arduino:072]: SDA Pin: GPIO21
[22:52:44][C][i2c.arduino:073]: SCL Pin: GPIO22
[22:52:44][C][i2c.arduino:074]: Frequency: 50000 Hz
[22:52:44][C][i2c.arduino:086]: Recovery: bus successfully recovered
[22:52:44][I][i2c.arduino:096]: Results from i2c bus scan:
[22:52:44][I][i2c.arduino:102]: Found i2c device at address 0x28
[22:52:44][C][uptime.sensor:033]: Uptime Sensor 'Allumé depuis (s)'
[22:52:44][C][uptime.sensor:033]: Device Class: 'duration'
[22:52:44][C][uptime.sensor:033]: State Class: 'total_increasing'
[22:52:44][C][uptime.sensor:033]: Unit of Measurement: 's'
[22:52:44][C][uptime.sensor:033]: Accuracy Decimals: 0
[22:52:44][C][uptime.sensor:033]: Icon: 'mdi:timer-outline'
[22:52:44][C][uptime.sensor:034]: Type: Seconds
[22:52:44][C][template.text_sensor:020]: Template Sensor 'Allumé depuis (j)'
[22:52:44][C][template.text_sensor:020]: Icon: 'mdi:clock-start'
[22:52:44][C][restart:068]: Restart Switch 'Redémarrage'
[22:52:44][C][restart:070]: Icon: 'mdi:restart'
[22:52:44][C][restart:091]: Restore Mode: always OFF
[22:52:44][C][status:034]: Status Binary Sensor 'Statut'
[22:52:44][C][status:034]: Device Class: 'connectivity'
[22:52:44][C][dht:017]: DHT:
[22:52:44][C][dht:018]: Pin: GPIO13
[22:52:44][C][dht:020]: Auto-detected model: DHT11
[22:52:44][C][dht:027]: Update Interval: 30.0s
[22:52:44][C][dht:029]: Temperature 'Temperature'
[22:52:44][C][dht:029]: Device Class: 'temperature'
[22:52:44][C][dht:029]: State Class: 'measurement'
[22:52:44][C][dht:029]: Unit of Measurement: '°C'
[22:52:44][C][dht:029]: Accuracy Decimals: 1
[22:52:45][C][dht:030]: Humidity 'Humidity'
[22:52:45][C][dht:030]: Device Class: 'humidity'
[22:52:45][C][dht:030]: State Class: 'measurement'
[22:52:45][C][dht:030]: Unit of Measurement: '%'
[22:52:45][C][dht:030]: Accuracy Decimals: 0
[22:52:45][C][rc522:099]: RC522:
[22:52:45][C][rc522:110]: Update Interval: 1.0s
[22:52:45][C][rc522:113]: Tag 'RC522 RFID Tag'
[22:52:45][C][rc522_i2c:011]: Address: 0x2C
[22:52:45][C][web_server:153]: Web Server:
[22:52:45][C][web_server:154]: Address: esp32-wroom3.local:80
[22:52:45][C][mdns:116]: mDNS:
[22:52:45][C][mdns:117]: Hostname: esp32-wroom3
[22:52:45][C][esphome.ota:073]: Over-The-Air updates:
[22:52:45][C][esphome.ota:074]: Address: esp32-wroom3.local:3232
[22:52:45][C][esphome.ota:075]: Version: 2
[22:52:45][C][esphome.ota:078]: Password configured
[22:52:45][C][safe_mode:018]: Safe Mode:
[22:52:45][C][safe_mode:020]: Boot considered successful after 60 seconds
[22:52:45][C][safe_mode:021]: Invoke after 10 boot attempts
[22:52:45][C][safe_mode:023]: Remain in safe mode for 300 seconds
[22:52:45][C][api:140]: API Server:
[22:52:45][C][api:141]: Address: esp32-wroom3.local:6053
[22:52:45][C][api:143]: Using noise encryption: YES
[22:52:45][C][wifi_signal.sensor:010]: WiFi Signal 'Signal wifi'
[22:52:45][C][wifi_signal.sensor:010]: Device Class: 'signal_strength'
[22:52:45][C][wifi_signal.sensor:010]: State Class: 'measurement'
[22:52:45][C][wifi_signal.sensor:010]: Unit of Measurement: 'dBm'
[22:52:45][C][wifi_signal.sensor:010]: Accuracy Decimals: 0
[22:52:45][C][homeassistant.sensor:030]: Homeassistant Sensor 'DHT_temp'
[22:52:45][C][homeassistant.sensor:030]: State Class: ''
[22:52:45][C][homeassistant.sensor:030]: Unit of Measurement: ''
[22:52:45][C][homeassistant.sensor:030]: Accuracy Decimals: 1
[22:52:45][C][homeassistant.sensor:031]: Entity ID: 'sensor.esp32_wroom3_temperature'
[22:52:45][C][homeassistant.sensor:030]: Homeassistant Sensor 'DHT_humi'
[22:52:45][C][homeassistant.sensor:030]: State Class: ''
[22:52:45][C][homeassistant.sensor:030]: Unit of Measurement: ''
[22:52:45][C][homeassistant.sensor:030]: Accuracy Decimals: 1
[22:52:45][C][homeassistant.sensor:031]: Entity ID: 'sensor.esp32_wroom3_humidity'
[22:52:45][W][rc522:399]: Communication with the MFRC522 might be down, reset in 2
[22:52:46][W][rc522:399]: Communication with the MFRC522 might be down, reset in 1
[22:52:47][W][rc522:399]: Communication with the MFRC522 might be down, reset in 0
[22:52:47][I][rc522:295]: Soft reset...
[22:52:47][I][rc522:303]: Device online.
[22:52:48][W][rc522:399]: Communication with the MFRC522 might be down, reset in 10
[22:52:49][W][rc522:399]: Communication with the MFRC522 might be down, reset in 9
[22:52:50][W][rc522:399]: Communication with the MFRC522 might be down, reset in 8
[22:52:51][W][rc522:399]: Communication with the MFRC522 might be down, reset in 7
[22:52:52][W][rc522:399]: Communication with the MFRC522 might be down, reset in 6
[22:52:53][W][rc522:399]: Communication with the MFRC522 might be down, reset in 5
[22:52:53][D][dht:048]: Got Temperature=23.3°C Humidity=34.0%
[22:52:53][D][sensor:094]: 'Temperature': Sending state 23.30000 °C with 1 decimals of accuracy
[22:52:53][D][sensor:094]: 'Humidity': Sending state 34.00000 % with 0 decimals of accuracy
[22:52:53][D][homeassistant.sensor:024]: 'sensor.esp32_wroom3_temperature': Got state 23.30
[22:52:53][D][sensor:094]: 'DHT_temp': Sending state 23.30000 with 1 decimals of accuracy
[22:52:53][D][homeassistant.sensor:024]: 'sensor.esp32_wroom3_humidity': Got state 34.00
[22:52:54][D][sensor:094]: 'DHT_humi': Sending state 34.00000 with 1 decimals of accuracy
[22:52:54][W][rc522:399]: Communication with the MFRC522 might be down, reset in 4
[22:52:55][W][rc522:399]: Communication with the MFRC522 might be down, reset in 3
[22:52:56][W][rc522:399]: Communication with the MFRC522 might be down, reset in 2
[22:52:57][W][rc522:399]: Communication with the MFRC522 might be down, reset in 1
[22:52:58][W][rc522:399]: Communication with the MFRC522 might be down, reset in 0
[22:52:58][I][rc522:295]: Soft reset...
[22:52:58][I][rc522:303]: Device online.
[22:52:59][W][rc522:399]: Communication with the MFRC522 might be down, reset in 10
[22:53:00][W][rc522:399]: Communication with the MFRC522 might be down, reset in 9
[22:53:01][W][rc522:399]: Communication with the MFRC522 might be down, reset in 8
[22:53:02][W][rc522:399]: Communication with the MFRC522 might be down, reset in 7
[22:53:03][W][rc522:399]: Communication with the MFRC522 might be down, reset in 6
[22:53:04][W][rc522:399]: Communication with the MFRC522 might be down, reset in 5
[22:53:05][W][rc522:399]: Communication with the MFRC522 might be down, reset in 4
[22:53:06][W][rc522:399]: Communication with the MFRC522 might be down, reset in 3
[22:53:07][W][rc522:399]: Communication with the MFRC522 might be down, reset in 2
[22:53:08][W][rc522:399]: Communication with the MFRC522 might be down, reset in 1
[22:53:09][D][sensor:094]: 'Allumé depuis (s)': Sending state 32.98800 s with 0 decimals of accuracy
[22:53:09][W][rc522:399]: Communication with the MFRC522 might be down, reset in 0
[22:53:09][I][rc522:295]: Soft reset...
[22:53:09][I][rc522:303]: Device online.
Pour les PN532 j’ai ce message (en bus I2C ou SPI) :
INFO .... Component pn532 is marked FAILED