LAN DS18B20 WEB Temperature Monitor 1 meter Cable
www.WEB-Relays.com
www.Facebook.com/KMtronic

How to Send a GET Packet in Python | Control KMtronic WEB Relay board example

Spread the love
Python socket in Python | Control KMtronic WEB Relay board example
Python socket in Python | Control KMtronic WEB Relay board example

 

(1) Verify Python Interpreter Availability with ‘helloworld.py’

#!/usr/bin/python

# Hello world python program

print "Hello World!";

 

(2) Create ‘kmtronic_web_relay_test.py” file

(3) Copy and paste code:

#!/usr/bin/python

# Test KMtronic WEB Relay board

print "Test KMtronic WEB Relay board";

import socket
import time

print ""

HOST = "192.168.1.199" 
PORT = 80 # Arbitrary non-privileged port
RELAY1_ON_COMMAND = "GET /FF0101 HTTP/1.1\r\n\r\n"
RELAY1_OFF_COMMAND = "GET /FF0100 HTTP/1.1\r\n\r\n"

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))

print "RELAY1_ON_COMMAND:", RELAY1_ON_COMMAND
s.sendall(RELAY1_ON_COMMAND)

s.close()

time.sleep(1)

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))

print "RELAY1_OFF_COMMAND:", RELAY1_OFF_COMMAND
s.sendall(RELAY1_OFF_COMMAND)

s.close()

 

 

 

KMtronic WEB LAN Two channels Relay Ethernet IP Controller - BOX
KMtronic WEB LAN Two channels Relay Ethernet IP Controller – BOX

 

Python socket in Python | Control KMtronic WEB Relay board example
Python socket in Python | Control KMtronic WEB Relay board example

python kmtronic_web_relay_test.py

 

KMtronic LAN WEB 8 Channel Relay board