Build a Wi-Fi + IR Controlled Smart Lamp with WiFIRCard and CircuitPython
IntroductionLooking for a simple yet powerful way to add Wi-Fi and IR control to your DIY electronics? Meet WiFIRCard— a tiny Wi-Fi + IR powered smart relay board. In this project, we’ll use CircuitPython to control a lamp with both Wi-Fi commands and a regular IR remote, giving you the best of both worlds: smart automation + traditional control.
Hardware Required- WiFIRCard – Tiny Wi-Fi + IR Smart Relay Board
- USB cable for programming
- IR remote (any basic TV/DVD remote will work)
- LED lamp or small 220V/110V load (connected via the relay)
- Control the lamp from your PC or mobile via Wi-Fi commands.
- Use your regular IR remote to toggle the relay.
- Use your regular IR remote to toggle the relay.
- Super compact build with minimal wiring.
- Runs on CircuitPython for easy-to-read code.
Just connect the WiFIRCard relay output to your lamp/light load, and plug in USB for programming. (No extra wiring needed — IR receiver and Wi-Fi are built in.)
CircuitPython Codeimport board
import digitalio
import wifi
import socketpool
import time
import pwmio
import pulseio
import adafruit_irremote
# Setup relay pin
relay = digitalio.DigitalInOut(board.IO2) # Example pin, adjust as per WiFIRCard pinout
relay.direction = digitalio.Direction.OUTPUT
# IR Receiver setup
ir_receiver = pulseio.PulseIn(board.IO4, maxlen=120, idle_state=True)
decoder = adafruit_irremote.GenericDecode()
# Wi-Fi setup
wifi.radio.connect("YOUR_WIFI_SSID", "YOUR_WIFI_PASSWORD")
pool = socketpool.SocketPool(wifi.radio)
server = pool.socket()
server.bind(("0.0.0.0", 8080)) # Simple web server on port 8080
server.listen(1)
print("WiFIRCard Smart Lamp Ready!")
print("Access via http://<your_device_ip>:8080")
def toggle_relay():
relay.value = not relay.value
print("Relay toggled ->", "ON" if relay.value else "OFF")
while True:
# Handle IR remote input
pulses = decoder.read_pulses(ir_receiver)
if pulses:
try:
code = decoder.decode_bits(pulses)
print("IR Code:", code)
toggle_relay()
except:
pass
# Handle Wi-Fi requests
client, addr = server.accept()
request = client.recv(1024)
request_str = request.decode("utf-8")
if "TOGGLE" in request_str:
toggle_relay()
response = f"Relay is {'ON' if relay.value else 'OFF'}"
client.send(response.encode("utf-8"))
client.close()
How It Works- Connect WiFIRCard to Wi-Fi by entering your credentials.
- Open a browser and go to
http://<WiFIRCard_IP>:8080
→ sendTOGGLE
request to switch the lamp. - Alternatively, use any IR remote — every button press will toggle the relay.
- Smart lamp/light control.
- Wi-Fi + IR controlled appliances.
- IoT home automation projects.
- DIY learning with CircuitPython.
With WiFIRCard + CircuitPython, you can easily combine Wi-Fi and IR control in a single compact board. This project is just a starting point — from controlling fans to powering home automation devices, the possibilities are endless.
Back the project on Kickstarter: WiFIRCard Smart Relay
Comments