Module for controlling Samsung TVs via RS232.
Many Samsung TVs don't seem to have a standard 9 pin serial port, they usually have a service port of some kind which is either a 3.5mm stereo jack or the PC VGA connector.
For more information on how to create an interface see this post over at SamyGo
I accept no responsibility for any damage done to your computer or TV
npm install samsung-tv
var samsungTv = require('samsung-tv');
var tv = new samsungTv({
port: '' // eg. /dev/ttyS0
});
tv.getSession.on('open', function() {
// now connected
// all commands to be placed here
});
A number of examples can be found within the examples directory.
Calculate the 7th checksum byte when sending a command to the TV.
Arguments
array
- Array of 6 bytes
Example
var checksum = tv.calculateChecksum([0x08, 0x22, 0x00, 0x00, 0x00, 0x00]);
Send a command via the serial connection.
Arguments
array
- Array of 6 bytescallback(err)
- Called once write has been completed
Example
tv.send([0x08, 0x22, 0x00, 0x00, 0x00, 0x00], function(err) {
if (err) {
console.log(err);
return;
}
console.log('Sent!');
);
Get the current serialport
session.
Close the current serialport
session.
Note all of the below examples have had their error handling examples removed as they are all identical to:
tv.methodName(function(err) {
if (err) {
console.log(err);
return;
}
console.log('Sent!');
});
Toggle the TVs power.
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendPowerToggle(function(err) {
console.log('Sent!');
});
Set the TVs power to on/off.
Arguments
state
- boolcallback(err)
- Optional callback called once write has been completed
Example
Power the TV on
tv.setPower(true, function(err) {
console.log('Sent!');
});
Increase the volume by 1.
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendVolumeUp(true, function(err) {
console.log('Sent!');
});
Decrease the volume by 1.
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendVolumeDown(true, function(err) {
console.log('Sent!');
});
Set the volume to a specific level.
Arguments
volume
- Integer between 0 and 100callback(err)
- Optional callback called once write has been completed
Example
Set the volume to 15
tv.setVolume(15, function(err) {
console.log('Sent!');
});
Toggle mute.
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendVolumeMuteToggle(function(err) {
console.log('Sent!');
});
Go to the next channel in the channel list.
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendChannelUp(function(err) {
console.log('Sent!');
});
Go to the previous channel in the channel list.
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendChannelDown(function(err) {
console.log('Sent!');
});
Go to the previous channel.
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendChannelPrevious(function(err) {
console.log('Sent!');
});
Go to a specific channel.
Arguments
channel
- Channel number (eg 101)callback(err)
- Optional callback called once write has been completed
Example
Example to change to BBC HD (in the case of my current channel listing)
tv.setChannel(101, function(err) {
console.log('Sent!');
});
Set the source to TV.
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.setSourceTv(101, function(err) {
console.log('Sent!');
});
Set the source to AV (1-3).
Arguments
value
- Which AV channel to use (1-3)callback(err)
- Optional callback called once write has been completed
Example
Set the source to AV 1
tv.setSourceAv(1, function(err) {
console.log('Sent!');
});
Set the source to component (1-3).
Arguments
value
- Which component channel to use (1-3)callback(err)
- Optional callback called once write has been completed
Example
Set the source to component 1
tv.setSourceComponent(1, function(err) {
console.log('Sent!');
});
Set the source to PC.
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.setSourcePc(101, function(err) {
console.log('Sent!');
});
Set the source to HDMI (1-4).
Arguments
value
- Which HDMI channel to use (1-3)callback(err)
- Optional callback called once write has been completed
Example
Set the source to HDMI 1
tv.setSourceHdmi(1, function(err) {
console.log('Sent!');
});
Set the source to the Samsung Smart Hub.
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.setSourceSmartHub(101, function(err) {
console.log('Sent!');
});
Set the picture mode.
Value | Mode |
---|---|
0 | Dynamic |
1 | Standard |
2 | Movie |
3 | Natural |
4 | Cal night |
5 | Cal day |
6 | BD Wise |
Arguments
value
- Picture mode as per table abovecallback(err)
- Optional callback called once write has been completed
Example
Set the picture mode to dynamic
tv.setPictureMode(0, function(err) {
console.log('Sent!');
});
Set the backlight level (0-20).
Arguments
value
- Backlight level 0-20callback(err)
- Optional callback called once write has been completed
Example
Set the backlight to maximum
tv.setBacklight(20, function(err) {
console.log('Sent!');
});
Set the contrast level (0-100).
Arguments
value
- Contrast level 0-100callback(err)
- Optional callback called once write has been completed
Example
Set the contrast to maximum
tv.setContrast(100, function(err) {
console.log('Sent!');
});
Set the brightness level (0-100).
Arguments
value
- Brightness level 0-100callback(err)
- Optional callback called once write has been completed
Example
Set the brightness to maximum
tv.setBrightness(100, function(err) {
console.log('Sent!');
});
Set the sharpness level (0-100).
Arguments
value
- Sharpness level 0-100callback(err)
- Optional callback called once write has been completed
Example
Set the sharpness to maximum
tv.setSharpness(100, function(err) {
console.log('Sent!');
});
Set the colour level (0-100).
Arguments
value
- Colour level 0-100callback(err)
- Optional callback called once write has been completed
Example
Set the Colour to maximum
tv.setColour(100, function(err) {
console.log('Sent!');
});
Set the tint level (0-100).
Arguments
value
- Tint level 0-100callback(err)
- Optional callback called once write has been completed
Example
Set the tint to maximum
tv.setTint(100, function(err) {
console.log('Sent!');
});
Set the picture black tone.
Value | Mode |
---|---|
0 | Off |
1 | Dark |
2 | Darker |
3 | Darkest |
Arguments
mode
- Picture black tone as per table abovecallback(err)
- Optional callback called once write has been completed
Example
Set the picture black tone to off
tv.setPictureBlackTone(0, function(err) {
console.log('Sent!');
});
Set the dynamic contrast mode
Value | Mode |
---|---|
0 | Off |
1 | Low |
2 | Medium |
3 | High |
Arguments
mode
- Dynamic contrast mode as per table abovecallback(err)
- Optional callback called once write has been completed
Example
Set the dynamic contrast mode to off
tv.setPictureDynamicContrast(0, function(err) {
console.log('Sent!');
});
Set the shadow detail level between -2 and 2
Arguments
value
- Shawdow detail level between -2 and 2callback(err)
- Optional callback called once write has been completed
Example
Set the shadow detail level to 0
tv.setPictureShadowDetail(0, function(err) {
console.log('Sent!');
});
Set the picture gamma level between -3 and 3
Arguments
value
- Picture gamma level between -3 and 3callback(err)
- Optional callback called once write has been completed
Example
Set the picture gamma level to 0
tv.setPictureGamma(0, function(err) {
console.log('Sent!');
});
Set the picture size mode
Value | Mode |
---|---|
0 | 16:9 |
1 | Zoom1 |
2 | Zoom2 |
3 | Wide fit |
4 | Screen fit |
5 | Smart view 1 |
6 | Smart view 2 |
Arguments
size
- Picture size mode as per table abovecallback(err)
- Optional callback called once write has been completed
Example
Set the picture size to 16:9
tv.setPictureSize(0, function(err) {
console.log('Sent!');
});
Set the 3D mode
Value | Mode |
---|---|
0 | Off |
1 | 2D -> 3D |
2 | Side by side |
3 | Top bottom |
4 | Line by line |
5 | Vertical line |
6 | Checker BD |
7 | Frame sequence |
Arguments
mode
- 3D mode as per table abovecallback(err)
- Optional callback called once write has been completed
Example
Set the 3D mode to off
tv.set3DMode(0, function(err) {
console.log('Sent!');
});
Set the sound mode
Value | Mode |
---|---|
0 | Standard |
1 | Music |
2 | Movie |
3 | Clear voice |
4 | Amplify |
Arguments
mode
- Sound mode as per table abovecallback(err)
- Optional callback called once write has been completed
Example
Set the sound mode to standard
tv.setSoundMode(0, function(err) {
console.log('Sent!');
});
Send a digit key press (0-9)
Arguments
key
- Key to send 0-9callback(err)
- Optional callback called once write has been completed
Example
Send key 5
tv.sendKeyDigit(5, function(err) {
console.log('Sent!');
});
Send the ok/enter key press
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendKeyOk(function(err) {
console.log('Sent!');
});
Send the exit key press
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendKeyExit(function(err) {
console.log('Sent!');
});
Send the return key press
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendKeyReturn(function(err) {
console.log('Sent!');
});
Send the more key press
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendKeyMore(function(err) {
console.log('Sent!');
});
Send the tools key press
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendKeyTools(function(err) {
console.log('Sent!');
});
Send the info key press
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendKeyInfo(function(err) {
console.log('Sent!');
});
Send the guide key press
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendKeyGuide(function(err) {
console.log('Sent!');
});
Send the menu key press
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendKeyMenu(function(err) {
console.log('Sent!');
});
Send the up key press
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendKeyUp(function(err) {
console.log('Sent!');
});
Send the down key press
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendKeyDown(function(err) {
console.log('Sent!');
});
Send the left key press
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendKeyLeft(function(err) {
console.log('Sent!');
});
Send the right key press
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendKeyRight(function(err) {
console.log('Sent!');
});
Send the sleep mode key press
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendKeySleepMode(function(err) {
console.log('Sent!');
});
Send the red button key press
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendKeyRed(function(err) {
console.log('Sent!');
});
Send the green button key press
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendKeyGreen(function(err) {
console.log('Sent!');
});
Send the yellow button key press
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendKeyYellow(function(err) {
console.log('Sent!');
});
Send the blue button key press
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendKeyBlue(function(err) {
console.log('Sent!');
});
Send the channel list key press
Arguments
callback(err)
- Optional callback called once write has been completed
Example
tv.sendKeyChannelList(function(err) {
console.log('Sent!');
});
Unfortunately due to the non existent documentation and poor implementation of the API by Samsung there is no two way communication supported.
Managed to source a number of RS232 codes off various forum posts, specifically the download available here.
Some considerations and limitations:
- The RS232 port may need enabling via the service menu
- Not all TVs can be powered on via RS232
- Some TVs may not work at all (my 2007 LE40M87 prints output via serial but no control)
- No two way communication