# Connecting an ESP32 to the SP PRO serial port The SP PRO serial port is **RS-232** (±12 V signalling), not RS-485 and not logic-level UART. You therefore **must** put an RS-232 ↔ 3.3 V level shifter between the inverter and the ESP32 — wiring the SP PRO directly to an ESP32 GPIO will damage the ESP32. Reference: Selectronic Tech Note [TN0050 "SP PRO Serial Port Pin-out"](https://www.selectronic.com.au/documents/TechNotes/TN0050_02%20SP%20PRO%20Serial%20Port%20Pin-out.pdf), cross-checked with the [selpi `connecting.md`](https://github.com/neerolyte/selpi/blob/main/docs/connecting.md) (which connects via an FT232 USB-to-RS232 cable at 57600 baud). ## SP PRO RJ45 pinout (TN0050) | RJ45 pin | Signal | Use | |---|---|---| | 1 | +12 V isolated (1 A) | optional supply — **do not** feed the ESP32 directly | | 2 | DTR | not needed | | **3** | **TXD** | SP PRO → us | | **4** | **GND** | common ground (required) | | 5 | GND | ground (redundant) | | **6** | **RXD** | us → SP PRO | | 7 | DCD | not needed | | 8 | — | not connected | Only **TXD, RXD and GND** are needed. Settings: **57600 baud, 8N1, no flow control.** ## Level shifter: MAX3232 A **MAX3232** (3.3 V RS-232 transceiver with internal charge pump) is the right part — it is the 3.3 V-capable successor to the MAX232. RS-485 transceivers (MAX3485 etc.) are **not** suitable here. Add the four 0.1 µF charge-pump capacitors per its datasheet. ## Wiring ``` SP PRO (RS-232) MAX3232 ESP32 (3.3V UART2) --------------- --------- ------------------ RJ45 pin 3 TXD -------> R1IN R1OUT -------------> GPIO16 (RX2) RJ45 pin 6 RXD <------- T1OUT T1IN <------------- GPIO17 (TX2) RJ45 pin 4 GND -------+- GND ----------------+- GND (common!) | | 3.3V ----------------- VCC (4x 0.1uF charge-pump caps) ``` - **TXD of one side always goes to RXD of the other** — note the crossover above. - **Common ground is mandatory.** RS-232 is single-ended and needs a shared reference. - RS-232 has no direction-control line (unlike RS-485), so there is nothing equivalent to DE/RE to manage. ## ESP32 UART Use **UART2** to keep UART0 free for USB logging/flashing: ```cpp Serial2.begin(57600, SERIAL_8N1, /*RX=*/16, /*TX=*/17); ``` GPIO16/17 are safe general-purpose pins on most ESP32 dev boards. (On a few modules with PSRAM these pins are reserved — pick two other free UART-capable GPIOs and update the sketch if so.) See `esp32/sppro_esp32.ino`. ## Quick bring-up checks 1. Confirm the SP PRO serial port is enabled and note its **baud** and **password** (front panel → Settings → Communications). 2. Loopback-test the MAX3232: short its TTL TX→RX and echo bytes through the ESP32. 3. With it wired to the SP PRO, the first query at `0xa000` should echo back; the `sppro-console` demo (or the sketch) will report "connected" once login succeeds. 4. If login fails, the usual causes are wrong/blank password, swapped TX/RX, or missing common ground.