This community is for professionals and enthusiasts of our products and services. Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.


ESP32 38R I/O Serial Communication Through Rx and Tx

Osama Bilal


I have an issue where I am trying to connect a display to my PLC and send some data to the screen from a temperature sensor. The issue I am having is that it seems my screen is not picking up the data for some reason. Now my PLC has two RX and TX ports but how will I define them in my code? For example, do I define them using the Arduino Pins and using software serial, although I prefer hardware serial, or is their another way to use them.

Also, when I use the RS232 library, I get a message notifying me that no such library exists. I am new to this device and I appreciate any help you can offer. The code is below and your thank you. 

#include <Arduino.h>

#include <stdio.h> 

//#include <RS232.h> 

#include <genieArduino.h>

Genie genie; 

// RX and Tx pin 

//#define RXpin RX

//#define TXpin TX

//#define resetpin Reset

// gpio 34 as analog to digital pins + input only pins 

#define temp_in_pin I0_2 // analog input : PLC Pinout IO.2 : Arduino Pin 54 : this is from the User Guide 

// int temp_in_pin = I1_8;  

float temp_read; 

//mV assuming 250 Ohms resistors in series // values should technically be int, but compiler takes 'smaller' data types and converts into 'larger' data types

float input_min = 1000;      // minimum voltage input 

float rate_DegV = 0.075;     // degrees Farenheit per millivolt

float offset_temp = 2.4;     // offset voltage needs to be tested

// Temperature outputs using variables above 

float temperatureC; 

float temperatureF; 

// Temperature strings 

String Farh = " Farenheit"; 

String Celc = " Celcius"; 

void setup() {

  // put your setup code here, to run once:

  Serial.begin(9600); // 

  Serial1.begin(115200); // serial Rx1 and Tx1 pins on 



  pinMode(temp_in_pin, INPUT); 

  delay(4000);    // to help in uploading code and preventing serial overload  



void loop() {

  temp_read = analogRead(temp_in_pin); //reading pin I0_2 in zone C


  temperatureF = ((temp_read - input_min) * rate_DegV) + offset_temp; 

  Serial.println(temperatureF + Farh);  


  temperatureC = (temperatureF - 32.0) * (5.0/9.0) ; // 500mV offset with 10 mV per degree

  Serial.println(temperatureC + Celc); //celcius 

  if(temperatureF > -100){

    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0, temperatureF); 



  //delay(1000); // reloop after 1 second  


1 Answer
Quesada Dani Salvans
Best Answer

Dear Osama,

Respect to the RS-232 communication, you can use it like a common Serial port but without including the RS-232 library (it uses the ESP32 SerialSC0 port). You can see the examples here (like the Arduino based PLCs but without including the library, as commented): 

Apart from that, the device has 2 serial ports that can be used as a common serial port (you must make the begin and use the common functions, like the RS-232 one):

-Serial1 (ESP32: SerialSC1)

-Serial2 (ESP32: SerialSC0)

Finally, to use any of them, you must take into account the switch configuration that you can see on the UserGuide of the device: ETHERNET%26WIFI%26BLUETOOTH PLC Family UserGuide.pdf?dl=0

Thank you,