The definition of lg4k TV reaches 2160 TV line (twice the full HD definition), and the color gamut of the picture display is close to the limit color range that human eyes can perceive, resulting in the sense of real picture. Therefore, it is often called S-class home theater.

Now most LG TVs come with a serial port (RS232). In fact, LG TVs can be fully operated through this serial port, and the function is more powerful than using a remote control. By using the serial port to send instructions, you can carry out some simple operations on the TV, such as turning on and off the TV, adjusting the volume and changing the channel.

Complex control can also be carried out, such as platform adjustment. In addition, it can also realize some functions that cannot be realized by the remote control, such as screen mute and screen lock (after that, the remote control and TV panel buttons will not work). Each button command can also be sent through the serial port, so it can completely replace the TV remote control in function.

Command format

Generally, PC sends commands to TV. PC is the master of serial port connection and TV is the slave. The command format issued by PC is [command] [space] [target device number] [space] [data (multi byte)] [carriage return]. Square brackets are only used for segmentation, not part of the actual command

[command]: 2-byte command. Different function commands are different. For example, the power control is Ka and the volume adjustment is KC

[target device number]: generally, LG TV defaults to 1. This number can be set in TV options. If 0 is used, it is sent to all connected LG TVs. Note that PC can connect multiple LG TVs. Some TVs have two serial ports, so that PCs can connect multiple LG TVs in series.

[data]: the data part of the instruction, which can be multi byte. For some instructions, the data segment is “FF”, and the instruction status can be queried. For example, if the data segment is “FF”, the current volume can be queried.

[Enter]: 0x20 of ASCII code is essential. TV uses this character to identify the end of the data packet

The TV will respond after receiving the command with correct format. The response format is [one byte after the command] [space] [equipment number] [OK / ng] [data] [x]

[one byte after instruction]: one byte after 2-byte instruction sent

[OK / ng]: command status. OK means the instruction is valid, and ng (no good) means the instruction is invalid.

[x] fixed character x

Hardware connection

Xiaobian uses a usb-rs232 converter. One end is connected to the USB port of PC and the other end is connected to the serial port interface behind LG TV

Connection test

Using any serial terminal can send and receive instructions. Xiaobian uses the HyperTerminal that comes with windows. Use HyperTerminal to set the serial port. The serial port of Xiaobian is COM4. Select COM4 in the attribute. According to the official instructions, set the baud rate to 9600, 8 bytes, no parity, 1 stop bit, which is basically the default value.

In addition, Xiaobian also checked echotyped characters locally in ASCII settings, so that he can see his input. Send line ends with line feeds is also checked to make line breaks easier to read.

After setting, test the power control command, which can control the TV to start and close, proving that the hardware connection is ready. Ka 0 1 in the figure is the boot command. A01 ok01x is the response of the TV, indicating that the equipment number is 01, the command is valid, and the current value of the command is 01

  TV RS232, control LG TV through RS232 serial port

Control software programming

When the hardware is ready, you can start software programming. Windows has its own API for controlling serial port, but it is more complex. Xiaobian planned to use QT to realize the graphical interface of the control software at the beginning, and later found that QT itself had good support for serial port.

QT has a qtserial port library to read and write serial ports. An example of serial port terminal is also provided:

So Xiaobian decided to use this example and add the control interface of LG TV on this basis.

It is not difficult to join the control interface, because this QT example has realized the underlying serial communication. Xiaobian added two menu options under tools. Tvcontrol option provides the overall control of TV, and remote option simulates the remote control of TV (see the figure below)

  TV RS232, control LG TV through RS232 serial port


LG industry conscience provides a serial connection to control the TV. Using serial port, you can completely control LG TV with computer. Imagine joining the network function, you can even use the office computer or mobile phone to control the home TV in the field.

Leave a Reply

Your email address will not be published. Required fields are marked *