Arduino UNO control of RS232 Equipment

I'm working on a project to control a TV wall from Arduino via RS232. This is a 3x3 wall of TVs, which are commercial grade and do not have IR control. I simply need to send a specific string via RS232 to the TVs (they are daisy-chained via RS232) to tell them to turn on or off.

I've done this many times with professional control systems. However, this client is looking for a budget solution.

The plan is to use a standard wall-switch as a dry contact closure via GPIO pins on the Uno, so the Uno knows if the TVs should be on or off.

Originally, I thought I could just wire a serial connector to the Uno for RS232 control, until I learned that the Uno is TTL.

So, I've purchased the MAX3232 device, but haven't discovered how that connects to the Uno. The TVs don't need anything other than RX, TX, shield - no DTS, etc.

If someone can point me to a wiring schematic and maybe even a sample sketch, I'd really be thankful.

Here is the MAX3232 I purchased: https://www.amazon.com/gp/product/B07PFB4MHR/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1

Perhaps this is the prompting you're looking for:
Vcc to 5V, Gnd to Gnd.
Use SoftwareSerial
There is some "confusion" expressed in the 'Comments' as to RXD/TXD and which is IN/OUT, but, if it doesn't work one way then "roll your data" (switch those wires) and see if that goes.

Without the datasheet explaining the protocol (Speed & data structure) this is not possible.

If you post this info here, I'm sure we can help. :grinning:

IF individual TVs are being turned on and off, then the individual TVs must have individual addresses in the message. The OP has not explained if only one TV is turned off/on at a time or if multiple devices can be addresses in a single message.
A bit of documentation, please.
Paul

1. Connect your UNO with MAX232 Module as per following diagram (Fig-1) using SUART Port (Software UART Port) and loop back connection for testing of the module.


Figure-1:

2. Upload the following sketch in UNO.

#include<SoftwareSerial.h>
SoftwareSerial SUART(6, 7);  

void setup()
{
     Serial.begin(9600);
    SUART.begin(9600);
}

void loop()
{
     SUART.print('A');    //sending A using SUART port
     byte n = SUART.available();
     if(n != 0)
     {
           char x = SUART.read();
           Serial.println(x);
     }
   delay(1000);
}

3. Check that A appears on the Serial Monitor of UNO at 1-sec interval.
4. Disconnect jumper ar 9-pin connector side of MAX232 Module.
5. Check nothing appears on Serial Monitor.
6. If Step-3 to 5 works, then connect your TV with MAX232 Module as per Fig-2. To get help in sketching, you need to provide 'information" that is to be sent to TV.


Figure-2:

This is a Video Wall (nine displays in a 3x3 format). They have RS232 in/out ports to daisy chain. In the command, I can specify individual TVs by an assigned Serial ID, or if I use 0 in the command, it will trigger all the displays. e.g I could assign them IDs during setup of 1-9, and then transmit "ka 03 01" to turn on TV 3, or I can transmit "ka 00 01" to turn all of them on.

I do quite a bit of serial control from other systems, so the software (command) side I'm familiar with. What I'm looking for here is the getting the hardware configured properly. We typically use something like QSC's Q-Sys, which is way too expensive for this task.

So, then, is all this enough for you to proceed?

An expensive device may be so because the various TV displays return an acknowledge message and a status byte to the controller. Is the case?
Paul

Hi,
Do you know the baud rate and the transmission configuration it is?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

What protocol do the TVs use? ISTR that there is already Arduino support for some of the popular commercial AV control protocols.

Some devices we control do return status, but it's informational and not necessary for function.

I finally got everything working. Strangely, if I loop the TX back to the RX using a jumper, then I see line feeds in the serial monitor, but I don't see the character that I transmitted. However, I finally set up a terminal app on another computer, and connected the Arduino project (by way of the Max3232) to that computer, and was able to verify functionality.

Here is the final sketch. I also added an RGB LED that would light red when the displays should be off, and green when on. A simple coaxial power connector allows me to plug in the wall switch when I install it. And I 3D printed an enclosure based on this design:

IMG_7089
IMG_7088

And, here's the sketch:

/*
  Arduino sketch to control LG displays.

  Pins Used:
  Pin 10 = Serial RX
  Pin 11 = Serial TX
  These two pins connect to MAX3232 device for TTL <-> RS232

  Pin 12 = red LED
  Pin 13 = green LED

  Pin 4 = dry contact closure to trigger TV state:
    Closed = TVs on
    Open = TVs off
    (switch connects between pin and ground)

  This sketch based on https://codebender.cc/example/SoftwareSerial/SoftwareSerialExample#SoftwareSerialExample.ino
 
 Receives from the hardware serial, sends to software serial.
 
 */
#include <SoftwareSerial.h>

// Pins we use
const byte displayRX  = 10;
const byte displayTX  = 11;
const byte ledRedPin  = 12;
const byte ledGrnPin  = 13;
const byte switchPin  = 4;

// Track switch status
int reading;
int previous = HIGH;

// Display data
String powerOn  = "ka 00 01\r";
String powerOff = "ka 00 00\r";

// Serial baud rates
const int debugBaud = 57600;
const int displayBaud = 9600;

SoftwareSerial displaySerial(displayRX, displayTX); // RX, TX

//
//
//
void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(57600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // Configure the switch and LED pins for us to use
  pinMode(switchPin, INPUT_PULLUP);
  pinMode(ledRedPin, OUTPUT);
  pinMode(ledGrnPin, OUTPUT);
  
  Serial.println("Intializing serial communication...");

  // set the data rate for the SoftwareSerial port
  displaySerial.begin(9600);
  Serial.println("...done");
  displaySerial.println("");

  // We assume we are off to begin with
  TVsOff();
}

//
//
//
void TVsOn()
{
    // Display what we are transmitting over RS232 on the debug monitor
    Serial.println(powerOn);

    // Make sure the LED represents the state
    digitalWrite(ledGrnPin, HIGH);
    digitalWrite(ledRedPin, LOW);
  
    // Turn the display on
    displaySerial.print(powerOn);  
}

//
//
//
void TVsOff()
{
    // Display what we are transmitting over RS232 on the debug monitor
    Serial.println(powerOff);

    // Make sure the LED represents the state
    digitalWrite(ledRedPin, HIGH);
    digitalWrite(ledGrnPin, LOW);
  
    // Turn the display off
    displaySerial.print(powerOff);  
  
}

//
//
//
void loop() // run over and over
{
   // Check the switch state
   
   reading = digitalRead(switchPin);
   
    // if the switch just changed states, send the appropriate serial command

    if (reading != previous) {
      if (reading == LOW) {   // LOW = ON
        TVsOn();
        Serial.println("Switch is now on");
  //      Serial.println(powerOn);
    //    digitalWrite(ledPin, HIGH);
      
        // Turn the display on
      //  displaySerial.print(powerOn);  
      }
      else {  // HIGH = OFF
        Serial.println("Switch is now off");
        TVsOff();
 //       Serial.println(powerOff);
   //     digitalWrite(ledPin, LOW);

        // Turn them off
     //   displaySerial.print(powerOff);
      }

      // Remember the last switch state
      previous = reading;
    }

    // Slow down a bit
    delay(250);
}