0
\$\begingroup\$

We have a sensor with UART interface (baudrate 115200). Sensor sends data at 1 Hz. We connect it to Ebyte E32-868T30S RF module to send sensor data.

We configure the RF module before assembly and can't make any modification after assembly because a PCB trace is connected to the sensor. We are planning to add a microcontroller to configure the RF module.

The RF module has one UART port and there is no SPI or I2C port on it. The microcontrolller is an ESP32-WROOM-32. The sensor also has only one UART port.

schematic

simulate this circuit – Schematic created using CircuitLab

My problem is that the sensor always sends data and it can get mixed with ESP32 UART data.

How can I make a design for this application?

\$\endgroup\$

3 Answers 3

1
\$\begingroup\$

The ESP32 has three hardware UART all work at 3.3 TTL Levels. So you can connect sensor to esp32_uart0 and the RF Module to the esp32_uart1. The correct dataflow will be depend on your application.

\$\endgroup\$
0
1
\$\begingroup\$

One option would be to use an analog switch, like the DIO3712.

Connect the NC pins to the sensor, and the NO pins to the ESP32. Whenever the ESP32 needs to configure the RF module, it can simply enable the switch to take control over the UART lines. enter image description here

\$\endgroup\$
2
  • \$\begingroup\$ Do you have any alternative suggestion to DIO3712. It is out of stock on suppliers. thanks \$\endgroup\$ Commented Jan 12, 2023 at 18:49
  • \$\begingroup\$ Mouser has 4k+ in stock, and has a lead time of 12 weeks. \$\endgroup\$ Commented Jan 12, 2023 at 18:51
0
\$\begingroup\$

With the design you show, you not only have the problem of transmit data conflict, but you're also creating a bus fight by connecting two transmitters together (if one TX is high while the other is low, you can have excess current flow which could damage one or both transmitters).

The cleanest way would be to use a micro with two UARTs: one connected to the sensor and the other connected to the RF module. During normal operation, your code would relay data between the UARTs. When the code needs to talk to the RF module, it would block the sensor UART data and talk to the RF module UART.

You may want to make the relay code smart enough to recognize data frames from the sensor to avoid passing on a partial frame.

\$\endgroup\$
2
  • \$\begingroup\$ What do you mean to recognize data frames? \$\endgroup\$ Commented Jan 12, 2023 at 11:13
  • \$\begingroup\$ @Htekin they mean storing the entire sensor reading, and sending it on only when you receive the entire reading \$\endgroup\$ Commented Jan 12, 2023 at 11:29

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.