user66535: Brief description about the problem History
Communicating with a old VersaStat II used GPIB port but the GPIB ports PCI card stopped working but there was a another port 25 pin rs232 Serial communication port but even now, too bad computers are abending the Serial port luckily there is still virtual Blutooth COM port which can be used with a modern laptop so ESP32 microcontroller was selected to communicate with this device wirelessly (might later go for HC05 module etc.).
Fixing the voltage difference problem
Now there is a big problem the esp32 Serial uses +3.3 V or logic 1 &  0 V for logic 0 But in the rs232 port logic 0 is +3 V ~ +12 V and logic 1 is -3 V ~ -12 V  also ± 3V  undefined region. To overcome this problem I have used the following circuit with optocouplers.
Here is the circuit diagram

The following code was used to communicate with the device easy as seems
Code
#include "BluetoothSerial.h"

#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif

BluetoothSerial SerialBT;
int speedsend = 9600;

void setup() {
  Serial.begin(speedsend);
  Serial2.begin(speedsend);
  SerialBT.begin("ESP32SERIAL");
  delay(500);
}

void loop() {

  if (Serial2.available()) {
//incoming data from the device
    int i = Serial2.read();
    SerialBT.write(i);
    Serial.println(i); // To check what is coming as output
  }
  if (SerialBT.available()) {
    Serial2.write(SerialBT.read());
  }

}


But I see no meaningful characters in putty (Bluetooth COM port) in Arduino Serial I see some numbers in HEX representation. Is this the way old devices communicate?
This link show how HEX numbers correlate with ASCII characters
https://www.rapidtables.com/convert/number/hex-to-ascii.html
How to fix this issue am I doing something wrong in here the circuit parameters etc.
Communication Example with device
For a start the ID command should give a number as 2532 according to book after the conversion it gives me 32 32 34 32 0 0 , 2242 looking at the Arduino Serial numbers with the help of the converting web site shown in above url. That's how I noticed It gives me HEX numbers.
Here is the PDF rs232c Interface section PDF the original Book came with ID command page too.
https://drive.google.com/file/d/1BHhIsloF4voMxoFeSlz1GsjwfgHwgsPJ/view?usp=sharing
Another book looks same but not from the book came with
https://drive.google.com/file/d/1z0NUOe17SpVYTIBfEE8s0EKStfLKKv_-/view?usp=sharing

user4143: Firstly you don't need that really complex optocoupler circuit. You just need a run-of-the-mill MAX3232 chip (note the extra 3 in there: it's the 3.3V version), that's what they're designed for: RS232 to 3.3V logic level conversion. You can pick up breakout modules for pennies on your favourite marketplace (ali-express, ebay, etc).
As for your reading, your assumption that your numbers are hexadecimal is completely wrong. They're decimal, not hexadecimal.
You read the data from the remote device and store each byte in an integer variable. Then you print that integer variable using Serial.println(). That will always give you a decimal representation of the numeric integer variable.
Your response of 32 32 34 32 0 0 , 2242 to my trained eye looks like bad communication. Maybe caused by your optocoupler circuit (change that for a MAX3232 immediately), or maybe caused by a mismatch in your baud rate, bit count, or parity settings.

user42015: Your problem is, that you try to provide a HEX value, but you are actually providing a decimal value.
When you just write a whole number like 32, it will be interpreted by the compiler as a decimal number. The decimal number 32 is equal to HEX 20, which is a space character in ASCII.
Solution: Write your number as decimal value like this:
int i = 0x32;

The 0x preceding the value will mark it as a hexadecimal representation.

66535: <p><em><strong>Brief description about the problem History</strong></em></p>
<p>Communicating with a old VersaStat II used GPIB port but the GPIB ports PCI card stopped working but there was a another port <code>25 pin rs232 Serial communication port</code> but even now, too bad computers are abending the Serial port luckily there is still <code>virtual Blutooth COM port</code> which can be used with a modern laptop so <em><strong>ESP32</strong></em> microcontroller was selected to communicate with this device wirelessly (might later go for HC05 module etc.).</p>
<p><em><strong>Fixing the voltage difference problem</strong></em></p>
<p>Now there is a big problem the esp32 Serial uses <code>+3.3 V</code> or logic <code>1</code> &amp;  <code>0 V</code> for logic <code>0</code> But in the rs232 port logic <code>0</code> is <code>+3 V ~ +12 V</code> and logic <code>1</code> is <code>-3 V ~ -12 V </code> also <code>± 3V </code> undefined region. To overcome this problem I have used the following circuit with <em><strong>optocouplers</strong></em>.</p>
<p>Here is the circuit diagram</p>
<p><a href="https://i.stack.imgur.com/92Fa9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/92Fa9.png" alt="enter image description here" /></a></p>
<p>The following code was used to communicate with the device easy as seems</p>
<p>Code</p>
<pre><code>#include &quot;BluetoothSerial.h&quot;

#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif

BluetoothSerial SerialBT;
int speedsend = 9600;

void setup() {
  Serial.begin(speedsend);
  Serial2.begin(speedsend);
  SerialBT.begin(&quot;ESP32SERIAL&quot;);
  delay(500);
}

void loop() {

  if (Serial2.available()) {
//incoming data from the device
    int i = Serial2.read();
    SerialBT.write(i);
    Serial.println(i); // To check what is coming as output
  }
  if (SerialBT.available()) {
    Serial2.write(SerialBT.read());
  }

}

</code></pre>
<p>But I see no meaningful characters in putty (Bluetooth COM port) in Arduino Serial I see some numbers in HEX representation. Is this the way old devices communicate?</p>
<p>This link show how HEX numbers correlate with ASCII characters</p>
<p><a href="https://www.rapidtables.com/convert/number/hex-to-ascii.html" rel="nofollow noreferrer">https://www.rapidtables.com/convert/number/hex-to-ascii.html</a></p>
<p>How to fix this issue am I doing something wrong in here the circuit parameters etc.</p>
<p><em><strong>Communication Example with device</strong></em></p>
<p>For a start the <code>ID</code> command should give a number as 2532 according to book after the conversion it gives me 32 32 34 32 0 0 , 2242 looking at the Arduino Serial numbers with the help of the converting web site shown in above url. That's how I noticed It gives me HEX numbers.</p>
<p>Here is the PDF rs232c Interface section PDF the original Book came with ID command page too.</p>
<p><a href="https://drive.google.com/file/d/1BHhIsloF4voMxoFeSlz1GsjwfgHwgsPJ/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1BHhIsloF4voMxoFeSlz1GsjwfgHwgsPJ/view?usp=sharing</a></p>
<p>Another book looks same but not from the book came with</p>
<p><a href="https://drive.google.com/file/d/1z0NUOe17SpVYTIBfEE8s0EKStfLKKv_-/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1z0NUOe17SpVYTIBfEE8s0EKStfLKKv_-/view?usp=sharing</a></p>
 4143: <p>Firstly you don't need that really complex optocoupler circuit. You just need a run-of-the-mill MAX3232 chip (note the extra 3 in there: it's the 3.3V version), that's what they're designed for: RS232 to 3.3V logic level conversion. You can pick up breakout modules for pennies on your favourite marketplace (ali-express, ebay, etc).</p>
<p>As for your reading, your assumption that your numbers are hexadecimal is completely wrong. They're decimal, not hexadecimal.</p>
<p>You read the data from the remote device and store each byte in an integer variable. Then you print that integer variable using <code>Serial.println()</code>. That will always give you a decimal representation of the numeric integer variable.</p>
<p>Your response of <code>32 32 34 32 0 0 , 2242</code> to my trained eye looks like bad communication. Maybe caused by your optocoupler circuit (change that for a MAX3232 immediately), or maybe caused by a mismatch in your baud rate, bit count, or parity settings.</p>
 42015: <p>Your problem is, that you try to provide a HEX value, but you are actually providing a decimal value.</p>
<p>When you just write a whole number like <code>32</code>, it will be interpreted by the compiler as a decimal number. The decimal number <code>32</code> is equal to HEX <code>20</code>, which is a space character in ASCII.</p>
<p><strong>Solution:</strong> Write your number as decimal value like this:</p>
<pre><code>int i = 0x32;
</code></pre>
<p>The <code>0x</code> preceding the value will mark it as a hexadecimal representation.</p>
