Olimex Support Forum

Microcontrollers => ESP32 => Topic started by: MZL on May 18, 2023, 12:29:29 PM

Title: MOD-RS232: Serial2 not available
Post by: MZL on May 18, 2023, 12:29:29 PM
Hi there,

I have a POE-ISO and a MOD-RS232.
I tried the example codes, which are posted in this forum, but nothing worked.
My example code (shortend):

#include <Arduino.h>
#include <HardwareSerial.h>
#define TXD_PIN (GPIO_NUM_4)
#define RXD_PIN (GPIO_NUM_36)

void setup()
{
  Serial2.begin(9600, SERIAL_8N1, RXD_PIN, TXD_PIN);
}

void loop()
{
  if (Serial2.available() > 0)
  {
    Serial.println("Serial2 is available");
    Serial2.print("xxxxxxxxx");
  } else {
    Serial.println("Serial2 not available");
    Serial2.print("xxxxxxxxx");
  }
}

I´m always getting "Serial2 not available".
If I change Serial2.begin(9600, SERIAL_8N1, RXD_PIN, TXD_PIN) to Serial2.begin(9600, SERIAL_8N1), I´m getting "Serial is available", but I cant´t receive data on my other adapter.
It seems as if the pins are incorrect or Serial2 doesn´t like the pins.

Any hints?

Title: Re: MOD-RS232: Serial2 not available
Post by: MZL on May 18, 2023, 12:48:11 PM
Edit:

My plattform.io:
[env:esp32-poe-iso]
platform = https://github.com/platformio/platform-espressif32.git
board = esp32-poe-iso
framework = arduino
monitor_speed = 115200
platform_packages =
framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32#master
lib_deps =
hideakitai/ArtNet@^0.2.12
adafruit/Adafruit GFX Library@^1.11.5
adafruit/Adafruit ILI9341@^1.5.12
Title: Re: MOD-RS232: Serial2 not available
Post by: LubOlimex on May 19, 2023, 08:29:55 AM
What else is in your hardware setup? What UART device do you have attached to MOD-RS232?

Is the device attached to MOD-RS232 with suitable voltage levels? MOD-RS232 will not work with 3.3V devices.
Title: Re: MOD-RS232: Serial2 not available
Post by: MZL on May 19, 2023, 11:09:51 AM
Quote from: LubOlimex on May 19, 2023, 08:29:55 AMWhat else is in your hardware setup? What UART device do you have attached to MOD-RS232?

Is the device attached to MOD-RS232 with suitable voltage levels? MOD-RS232 will not work with 3.3V devices.

Hi LubOlimx,

I just connected the Olimex POE-ISO via UEXT ribbon cable to the Olimex MOD-RS242.
My Windows-USB-RS232-Adapter is a DriverGenius USB232A-B USB to Seriell RS232 Adapter DB9. The chip is a PL-2303 from Prolific, which should run with 5V.(https://www.prolific.com.tw/US/ShowProduct.aspx?p_id=8&pcid=41).

I found the solution, my bad:
I just had the wrong settings in my Windows-RS232-Monitor.

But one last question:

What is the output voltage level of the MOD-RS232? Is it 5V or 12V, I couldn´t find the details?


Marcel


Title: Re: MOD-RS232: Serial2 not available
Post by: LubOlimex on May 19, 2023, 11:36:52 AM
Double the input. If we provide 3.3V, then 6.6V. Refer to the datasheet of the main chip for more details.