Single Line Serial monitoring

I want to use an ESP32 to monitor and extract data from a single wire half duplex serial line.
I have two devices which are connected by a single wire (and Ground).
Data flows between the two , one sends command , 2nd sends response.
Message size is 24 bits, protocol not known at present.
The line is 5v TTL serial and I want to "listen" to raw data being sent back and forward between the two and export it to Excel for analysis.
Can someone point me in right direction to learn how to do this with an ESP32.
I presume that the ESP32 will need some level shifting down to 3.3v?
Thank you

yes. A resistor divider will accomplish that, with 22k from the TTL line to the ESP32 input pin, and a 33k from the ESP32 pin to GND.

You're most of the way there. The traffic you're 'eavesdropping' on can be read as if you're reading any Serial input(I'd suggest you use Serial1, reserving Serial for bidirectional communication with Serial Monitor). Start by echoing what you receive onto Serial Monitor for inspection.
From there, it's your job to sort out who's said what, though we can help once you can post captures from Serial Monitor.

You could also simply use a common serial terminal program and a TTL-USB adapter for initial sorting out, it would remove the uncertainty of programming your ESP32 to start with.

Thanks,
I wanted to use the ESP32 as the intention is that, once Ive worked out the data and protocols (another learning journey for me) , I want to try and substitute the 1st device with my ESP32 and issue commands to control the 2nd device.
So the "listening " is a first stage in the project.

I have assumed that I will need some kind of stop/start programming to pause RX whilst the ESP issues a Tx and then resume RX to receive back the response, ie working in half duplex mode.

Ive searched for the setup to use a Tx enable GPIO pin on the ESP with suitable programming but am a bit stumped.?

That part is relatively simple (once you know how to do it :wink:). You use a finite state machine with two states and you switch between those states.

  1. First state:
    • send
    • switch to second state
  2. Second state:
    • wait for reply
    • switch to first state

But I suggest that you first figure out the protocol.

Yes I agree,
need to work out data, protocols and timings by analysis.
When thats all done will additional hardware be needed for the esp32 to regulate Tx/Rx half duplex stream to avoid car crashes on the 1 wire serial connection.
Surely cant be just be 1 wire shared by UART serial TX and RX controlled by software changing states.?

Why not! You are assuming there is NO error checking or recovery from errors. Each device responds to the message from the other. Quite simple to program.

After you have send, the receive will see

  1. What was send because Rx is connected to Tx.
  2. The reply from the second device.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.