dzungpv / mitsubishi2MQTT

Mitsubishi to MQTT with ESP8266/ESP32 module
GNU General Public License v3.0
68 stars 13 forks source link

Use of &Serial1 on esp32dev #13

Closed Sprinterfreak closed 8 months ago

Sprinterfreak commented 8 months ago

The default &Serial1 (GPIO9/10, SD3/SD2) can not be used on ESP-WROOM-32. GPIO9/10 are part of internal connections to its integrated spi flash.

https://www.espressif.com/sites/default/files/documentation/esp32-wroom-32_datasheet_en.pdf

Either use &Serial as default or initialize &Serial2 on GPIO2/4 for instance?

dzungpv commented 8 months ago

@Sprinterfreak You can assign any compatible pin and now it is using Serial2: https://github.com/dzungpv/mitsubishi2MQTT/blob/6e3e7f242298d2094cf3694d3608f4bd96d5a51c/main/main.cpp#L265C19-L265C26, I often use 26, 27 or 19, 23 on ESP32 without any problem.

Sprinterfreak commented 8 months ago

That is only partially correct. It uses Serial1 if it has default settings loaded rx, tx = 0, 0.

dzungpv commented 8 months ago

You set pin other than 0 and it work. I will fix this by using Serial by default.

dzungpv commented 8 months ago

S2, C3 and C6 only have 2 hardware serial so code must be change

dzungpv commented 8 months ago

I close it because of https://github.com/dzungpv/mitsubishi2MQTT/commit/cdd28bd97bd292a478b51a43f5e17d5dc8cddc68 You can open it if still have problem.

Sprinterfreak commented 8 months ago

The thing is you MUST NOT set up Serial1 with default pins as this will destroy communication between the cpu and internal flash. GPIO9/10(D2/D3), which are default for Serial1, are reserved for SPI flash access.

grafik grafik

dzungpv commented 8 months ago

It is not using GPIO 9 and 10 in the latest update, it using UART0 by default and UART1 if you set the uart pins in the Setting. You can see readme.md