from machine import Pin

relayPin = 23
irPin = 22
relay = Pin(relayPin, Pin.OUT)
ir = Pin(irPin, Pin.IN)

state = 0
while True:
  irValue = ir.value()
  print(irValue)
  if irValue == 1 and state == 0:
    relay.on()
    state = 1     #turn state from 0 to 1, just to clarify the current state of ir(on/off)
  elif irValue == 0 and state == 1:
    relay.off()
    state = 0

  
NOCOMNCVCCGNDINLED1PWRRelay Module