Lana VulicLuigi Francesco Cerfeda
Published © GPL3+

Controlling the XinaBox OC03 Relay Module in Python

The OC03 is a low-voltage control relay module able to switch AC and DC loads, learn how to control it with Zerynth Studio in Python.

BeginnerProtip1 hour660
Controlling the XinaBox OC03 Relay Module in Python

Things used in this project

Hardware components

OC03
XinaBox OC03
×1
CW02
XinaBox CW02
×1
IP01
XinaBox IP01
×1

Software apps and online services

Zerynth Studio
Zerynth Studio

Story

Read more

Schematics

OC03 xChip

Code

Toggle relay on OC03

Python
import streams
from xinabox.oc03 import oc03
streams.serial()

# instantiate OC03 class
OC03 = oc03.OC03(I2C0)

# begin i2c bus
OC03.start()

# start OC03
OC03.init()

# sleep time
DELAY = 500

# infinite loop
while True:

# close relay
OC03.writePin(True) 
print(OC03.getStatus()) # return state of relay to console
sleep(DELAY)

# open relay
OC03.writePin(False)
print(OC03.getStatus()) # return state of relay to console
sleep(DELAY)

Credits

Lana Vulic

Lana Vulic

4 projects • 7 followers
Luigi Francesco Cerfeda

Luigi Francesco Cerfeda

6 projects • 95 followers
Yet another Tony Stark wannabe

Comments