Skip to content

Instantly share code, notes, and snippets.

@command-tab
Created August 19, 2020 04:42
Show Gist options
  • Save command-tab/8551bbe7033d6c7d4b2fa3ffa4b8067b to your computer and use it in GitHub Desktop.
Save command-tab/8551bbe7033d6c7d4b2fa3ffa4b8067b to your computer and use it in GitHub Desktop.
#/usr/bin/env python
# "SMAKN LCUS-1 type USB relay module USB intelligent control switch USB switch"
# https://www.amazon.com/gp/product/B01CN7E0RQ/
# pipenv install pyserial
import serial
import time
# https://pyserial.readthedocs.io/en/latest/tools.html#serial.tools.list_ports.grep
with serial.Serial('/dev/tty.usbserial-1430', 9600, timeout=1) as ser:
ser.write(serial.to_bytes([0xA0, 0x01, 0x01, 0xA2])) # ON
time.sleep(3)
ser.write(serial.to_bytes([0xA0, 0x01, 0x00, 0xA1])) # OFF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment