Sending data issue rs232 arduino 8266

I have a piece of equipment which we use hyperterminal to communicate with using the command
*SP (return) and we get an "OK" response.

I'm trying to automate this via a ESP8266 + rs232 pcb.
I have tried all variants of the code below to send this command but i get no response.
The device has paralleled up serial ports so I can monitor the data and it seems identical to when we type the keystrokes from a laptop running hyperterm.

Note
The piece of equipment sends data constantly which I can read with different code, that works, I just cant send data to it.

void setup()
{
  Serial.begin(9600);
  
  Serial.println ("*SP"); 
  Serial.print ("*SP"); 
  Serial.write (13);
  Serial.print ("*SP\r\n");

}

What am I doing wrong?

Other questions...

  1. When using Hyperterm we do have to set XON/XOFF, how do I set that in code?
  2. Is there a possibility its a voltage level issue of the RS232 data?
  3. I tried installing a PORT SNIFFER application and can see the hex data when I type *SP return is 2a 53 50 0d and this also what my bit of code generates!

Any help appreciated

Please sketch out your complete interconnection scheme- including ALL devices and connections.

XON and XOFF are simply control characters. (Ctrl-S and Ctrl-Q), printed like any other character.

Your use of multiple devices on a single RS232 line may require special consideration to avoid loading or biasing the inputs inappropriately,

I don’t see any RS332 devices, that may be why they’re not communicating…?

I suggest using EspSoftSerial library, e.g.
try this code which works on an ESP8266

// ESP8266 EspSoftware Serial test

// At boot, Serial uses UART0, which is mapped to pins GPIO1 (TX) and GPIO3 (RX).

// using library manager download and instal EspSoftwareSerial or instal ZIP
// https://github.com/plerup/espsoftwareserial

#include <SoftwareSerial.h>

// pins Rx GPIO14 (D5) and Tx GPIO 12 (D6) 
 SoftwareSerial swSer(14, 12);  

 // for loopback test connect pin D5 to pin D6

// for RS232 shield connect
// ESP8266 pin D6 TXD to TTL/RS232 Tx
// ESP8266 pin D5 RXD to TTL/RS232 Rx
// for loopback test connect 9-pin D_type connector pins 2 Tx to 3 Rx (pin 5 is GND)
// connect GND pins together and VCC to 5V

void setup() {
  Serial.begin(115200);   //Initialize hardware serial with baudrate of 115200
  swSer.begin(9600);      //Initialize software serial with baudrate of 9600
  Serial.println("\nESP8266 Software serial test started");
  Serial.println("-  for loopback test connect pin D5 to pin D6\n");
 }

void loop() {
  while (swSer.available() > 0) {  //wait for data at software serial
    Serial.write(swSer.read()); //Send data recived from software serial to hardware serial    
  }
  while (Serial.available() > 0) { //wait for data at hardware serial
    swSer.write(Serial.read());     //send data recived from hardware serial to software serial
  }
}

first test using loopback - connect D5 to D6 - text entered on serial monitor should echo back to display

to connect the ESP8266 to the device RS232 you will require a TTL to RS232 module to convert the ERSP8266 3.3V logic levels to RS232 levels (typically -8V to +8V)

connect the ESP8266 to the TTL/RS232 module so

// ESP8266 pin D6 TXD to TTL/RS232 Tx
// ESP8266 pin D5 RXD to TTL/RS232 Rx

if you connect the RS232 9pin D-type connector pins 2 and 3 you can do a loopback test
if that works connect the TTL/RS232 module to the device - you may require a crossover cable
do you have information of the equipment's RS232 connector?

1 Like

What is 2578MAX?
Most Esp8266 dev boards are designed for 5V VIN voltage. Make sure yours is rated for 9V.

OK, how about this

2578 is a TTL to RS232 converter
Yes, this board runs fine with 9v.

I don’t see any paralleled serial ports…
That relates to what I mentioned above….

Maybe you chose the wrong words ?
Is this all that you have ?

The device under test does has have 3 ports (I assume they are parralelled up) but I only plugged into those to try to monitor and debug, normally its just like above.

Can you post a datasheet link, because Google didn't turn up anything on this.

Providing 9v to the ESP and then tapping from the 3.3v pin is using the 3.3v onboard regulator to power this ?1 Down from 9v you should get some heat from the board. It is not recommended.

ok, if this where we are, you need to reflash the ESP with a simple feedthrough / loopback program so you can ‘see’ the raw serial data is actually. being sent & received.

Ignore the parsing and packeting, just catch and display the stream content.

If your board looks like this, then you need a cross-over cable also known as null-mobem cable.

this photo shows a ESP8266 connected to a TTL-RS232 module connected to a Quectel Mini PCIe EVB Kit (with a EC21-E modem)

you can see the cross-over connection between the RS232 D-Type connectors yellow and orange wires (cross over pin 2 to pin 3 pin 5 is GND)

running the code of post 5 transmitting AT commands to the modem the Serial monitor displays

ESP8266 Software serial test started
-  for loopback test connect pin D5 to pin D6

RDY
at
OK
at+cgmi
Quectel
OK
at+cgmm
EC21
OK
at+csq
+CSQ: 17,99
OK
at+cimi
+CME ERROR: 3

at_cimi fails because a SIM card is not fitted

What's a SIM and what does have to do with RS232

it is an error message which comes over RS232 from the EC21 modem in response to the at_cimi (returns the current used IMSI) command
the Quectel Mini PCIe EVB Kit modem evaluation kit did not have a SIM card installed during this particular test
if I install a SIM card I can connect to the network and use TCP and UDP, MQTT, etc

This is my board.
I have other code which reads data coming out of the device under test fine.

The exact board I have is the wemos lolin v3 which as far as I am aware can handle 6v-12v

Do you have an example of such code, a google search is sending me down different several rabbit holes.

RS232 can be looked at like a point to point connection rather then a multi drop bus. You must connect Tx (transmit) to Rx (Receive). Two Rx lines alone cannot communicate as neither can transmit.