ESP32E & RS232 getting no data

Hi

I'm a novice when it comes to this and I need help. I am trying to read this scale
QAL Scale
using RS232

I am using a ESP32, this one -> FireBeetle ESP32-E
and I got a rs232-to-ttl adapter hooked up to it on pin 16 & 17, GND and 33V.
image

I found a code example online but I'm getting nothing.

#define RXD2 16
#define TXD2 17

void setup() {
  // Note the format for setting a serial port is as follows: Serial2.begin(baud-rate, protocol, RX pin, TX pin);
  Serial.begin(115200);
  Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
  Serial.println("Serial Txd is on pin: "+String(TX));
  Serial.println("Serial Rxd is on pin: "+String(RX));
}

void loop() { //Choose Serial1 or Serial2 as required
  while (Serial2.available()) {
    Serial.print(char(Serial2.read()));
  }
}

The manual for the scale has the following section. I have checked on the scale and the baudrate is set to 9600 and Mode 1.

SECTION 5 RS-232 OUTPUT

Specifications: RS-232 output of weighing data, 1200/2400/4800/9600/19200 bps,1 stop bit, 8 data bits, No Parity.

Mode 1: Continue output

ST,GS 0.119,kg ST for stable; US for unstable ; GS for gross weight; NT for net weight ; 0.119 for weighing value; kg for unit (kg, lb); HEX 0d and HEX oa : HEX for hex; 0d for enter; 0a for next line.

Mode 2: Automatic output

Automatic output mode is same as continue output. The only difference is:

After weighing, when take away the goods display returns to zero, then transfers.

Mode 3: Print output

There are two kinds of formats which could be selected as Lab 1 and Lab 2.

Data Format for normal weighing operations. Examples as follow.

Any help would be appreciated

1 Like

Welcome to the Community.

Thanks for a well posted first message.

Would you happen to have a one of those cheap logic analyizers, HiLetgo USB Logic Analyzer Device With EMI Ferrite Ring USB Cable 24MHz 8CH 24MHz 8 Channel UART IIC SPI Debug: AmazonSmile: Industrial & Scientific?

Here is how I receive serial on an ESP32.

void fReceiveSerial_LIDAR( void * parameters  )
{
  bool BeginSentence = false;
  sSerial.reserve ( StringBufferSize300 );
  char OneChar;
  for ( ;; )
  {
    EventBits_t xbit = xEventGroupWaitBits (eg, evtReceiveSerial_LIDAR, pdTRUE, pdTRUE, portMAX_DELAY);
    if ( LIDARSerial.available() >= 1 )
    {
      while ( LIDARSerial.available() )
      {
        OneChar = LIDARSerial.read();
        if ( BeginSentence )
        {
          if ( OneChar == ‘>’)
          {
            if ( xSemaphoreTake( sema_ParseLIDAR_ReceivedSerial, xSemaphoreTicksToWait10 ) == pdTRUE )
            {
              xQueueOverwrite( xQ_LIDAR_Display_INFO, ( void * ) &sSerial );
              xEventGroupSetBits( eg, evtParseLIDAR_ReceivedSerial );
              //
            }
            BeginSentence = false;
            break;
          }
          sSerial.concat ( OneChar );
        }
        else
        {
          if ( OneChar == ‘<’ )
          {
            sSerial = “”; // clear string buffer
            BeginSentence = true; // found begining of sentence
          }
        }
      } //  while ( LIDARSerial.available() )
    } //if ( LIDARSerial.available() >= 1 )
    xSemaphoreGive( sema_ReceiveSerial_LIDAR );
  }
  vTaskDelete( NULL );
} //void fReceiveSerial_LIDAR( void * parameters  )

Hi,
modify this line to :
Serial.println(Serial2.read()),HEX);
and see if it prints something other than 0.

I've tried this. But the thing is I receive nothing not even 1 character from the ttl module. I've tried swapping RX & TX also.

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