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

How to Send a UDP Packet in Python | Control KMtronic UDP Relay board

Spread the love

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

#!/usr/bin/python

# Hello world python program

print "Hello World!";

 

(2) Create ‘kmtronic_up_relay_test.py” file

(3) Copy and paste code:

#!/usr/bin/python
# Test KMtronic UDP Relay board

print "Test KMtronic UDP Relay board";

import socket
import time

UDP_IP = "192.168.1.199"
UDP_PORT = 12345

RELAY1_ON_COMMAND = "FF0101"
RELAY1_OFF_COMMAND = "FF0100"

print "UDP target IP:", UDP_IP
print "UDP target port:", UDP_PORT

print "RELAY1_ON_COMMAND:", RELAY1_ON_COMMAND

sock = socket.socket(socket.AF_INET, # Internet
 socket.SOCK_DGRAM) # UDP
sock.sendto(RELAY1_ON_COMMAND, (UDP_IP, UDP_PORT))

time.sleep(1)

print "RELAY1_OFF_COMMAND:", RELAY1_OFF_COMMAND
sock.sendto(RELAY1_OFF_COMMAND, (UDP_IP, UDP_PORT))

 

UDP LAN Two channels Relay Ethernet IP Controller - BOX
UDP LAN Two channels Relay Ethernet IP Controller – BOX

 

 

"kmtronic_up_relay_test.py" file
python kmtronic_up_relay_test.py

 

 

KMtronic LAN WEB 8 Channel Relay board