0
\$\begingroup\$

I am trying to understand how to connect an ESP32's UART pins to my raspberry pi 3B+'s I2C pins. I see several bridge chips available for this like TI's MSP430 Datasheet. But I am not very circuit savvy so I am having a difficult time. The pins I need to use on the ESP32 are: GPIO 9 and 10, RX and TX respectively (UART1). On the Raspberry Pi: GPIO 2 and 3, SDA and SCL respectively. Does anyone know answers to the questions below?

  1. Besides connecting the RPi, ESP, Vcc, GND pins to the bridge at the correct I/O positions on the chip, what additional circuitry would be needed to make good communication?

  2. What the ESP32 code would look like (Arduino IDE)?

  3. What the Pi's code would look like (python)?

\$\endgroup\$
7
  • \$\begingroup\$ Why do you want to use I2C on the Raspberry Pi? It does have an Uart as well, so why not connect them instead? \$\endgroup\$
    – PMF
    Mar 12 at 18:15
  • \$\begingroup\$ Good question, the reason is UART pins are occupied by another module. \$\endgroup\$
    – Feynman137
    Mar 12 at 18:16
  • \$\begingroup\$ The ESP32 has an I2C interface, the PI has an I2C interface, why not use that? \$\endgroup\$
    – Lior Bilia
    Mar 12 at 18:43
  • \$\begingroup\$ I was just wondering about this... Both modules I2C interfaces are unoccupied in my application. I have never tried this before. \$\endgroup\$
    – Feynman137
    Mar 12 at 18:49
  • \$\begingroup\$ @Feynman137: Get yourself a Pi4. It has 6 Uarts ;-) \$\endgroup\$
    – PMF
    Mar 12 at 18:53
0
\$\begingroup\$

schematic

simulate this circuit – Schematic created using CircuitLab

The ESP32 has more than 1 UART. Although it is common to only use one of them in the default configuration, the ESP32 has 3 UARTs. You can configure which GPIO pins to use by using the uart_set_pin() function. You should check the datasheet or the Espressif website for the details.

Using multiple UARTs allows the ESP to act as a Serial Bridge. This function is frequently implemented with the different flavors of ESPs as a WiFi Serial Bridge, but it works for wired connections as well.

UART Page

\$\endgroup\$
1
  • \$\begingroup\$ ESP does have multiple UART, but Pi 3b+ doesn't have pins for more than one UART and these pins are currently occupied. This is the issue. I was not aware of the uart_set_pin() function though, so I appreciate the suggestion. \$\endgroup\$
    – Feynman137
    Mar 15 at 4:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.