LoRa Family RS-232
Serial Communication Standard
RS-232 protocol formally defines the signals connecting between DTE (Data Terminal Equipment) such as a computer terminal, and DCE (Data Circuit-terminating Equipment or Data Communication Equipment), such as a modem.
Our Arduino Based PLCs incorporate the integrated circuit MAX232.
MAX232 converts signals from to TIA-232 (RS-232) serial port to signals suitable for use in TTL-compatible digital logic circuits. The MAX232 is a dual transmitter / dual receiver that is used to convert the RX, TX, CTS, RTS signals.

MAX232 Pin Configuration and Typical Operating Circuit
MAX232 Pin Configuration and Typical Operating Circuit
Hardware
Check the LoRa Family products now!
IMPORTANT: Make sure that your Ethernet PLC is powered (12-24Vdc).
Switch configuration
For the RS-232 communication protocol there isn't any switch that affects it. So it does not matter the configuration of the switches to implement a RS-232 communication.
Used pins
For RS-232 communication protocol the defined Arduino Mega pins are showed in the chart below:
M-Duino Ethernet PLC pinout Arduino Mega pinout TX 16 (Serial2 TX) RX 17 (Serial2 RX)
You can access easily to RS-232 pins in our Ethernet PLCs, you can see their position in the following image:


Connections
Once the hardware configuration is done, it's possible to proceed with the software configuration and also its usage. Firstable it's necessary to include the RS232.h library provided in our boards.
#include <RS232.h>
RS232.begin(9600);
RS-232 Library - Functions
* Remember that both devices have to communicate on the same baud rate.
Now everything is ready to start using the RS232 functions or methods. RS232 is a class that can use the same methods than Serial class. Take a look on Arduino web site references to see the different available functions. The most used methods that every Industrial Shields developed has to know are:
RS232.begin(baud); //sets the baud rate for RS232 data transmision RS232.read(); //reads incoming RS232 data RS232.write(byteToSend); //write binary data to RS232 port RS232.write(dataToSend, dataLength); //write binary data to RS232 port RS232.available() //returns the number of bytes available for reading on RS232 port
This is all it’s necessary to know to use RS232 on Industrial Shields equipment’s. Finally it is showed an example using RS232.
Example codes
Basic RS-232 write example:
// Include Industrial Shields libraries #include <RS232.h> //// IMPORTANT: check switches configuration //////////////////////////////////////////////////////////////////////////////////////////////////// void setup() { // Begin serial port Serial.begin(9600); // Begin RS232 port RS232.begin(38400); } //////////////////////////////////////////////////////////////////////////////////////////////////// void loop() { // Wait bytes in the serial port if (Serial.available()) { byte tx = Serial.read(); // Echo the byte to the serial port again Serial.write(tx); // And send it to the RS-232 port RS232.write(tx); } }