Arduino Nano IR remote control project controlling fan and lights using relay module

Build a Smart Room with Arduino Nano IR Remote (Fan & Light Control)

It Started with a Simple Problem

I didn’t start this project because I wanted a “smart room.”

I started it because I was annoyed.

Every night, after lying down, I had to get up again just to switch off the light. Then again for the fan. Sometimes, I just stayed under the blanket, avoiding that one extra step — even though I knew it meant wasting electricity.

A simple TV remote—instant, offline, reliable. Why couldn’t my room work the same way?

No apps. No setup. Just press a button and it works.

Because there’s no WiFi involved, the system responds instantly without any delay.

Just a remote — like a TV.

And that’s exactly what this project does.


What You’re Actually Building

This is not just a “relay + Arduino” demo.

You’re building a real, usable system that:

  • Controls fan + 2 lights
  • Works using a standard IR remote
  • Responds instantly (no internet required)
  • Can be expanded later (WiFi, automation, etc.)
Arduino Nano connected with relay modules and IR receiver inside plastic box for home automation.
Inside view of the relay control circuit used for IR remote home automation project.

Final Control System:

ButtonAction
Fan buttonToggle fan
Light 1Toggle
Light 2Toggle
*ALL ON
#ALL OFF

This is not theory — this is something you can actually install in your room.


Components Used (Real Setup)

Here’s exactly what I used — nothing fancy:

No unnecessary components. No over-engineering.


Why I Chose IR Instead of WiFi

Before building, I considered ESP32 and WiFi control.

But here’s the reality:

❌ WiFi Problems

  • Delay in switching
  • Dependency on internet
  • App dependency
  • Setup complexity

✅ IR Advantages

  • Instant response
  • No network required
  • Works every time
  • Simple to debug

For basic room automation, IR is actually more practical.


How This System Works (Simple Logic)

Let’s break it down without jargon.

  1. Remote sends IR signal
  2. IR receiver captures it
  3. Arduino reads the code
  4. Based on code → relay ON/OFF
  5. Relay controls AC load

That’s it.

No cloud. No API. No complexity.


Wiring Setup (Important Part)

Real Arduino Nano relay control setup mounted on wall for fan and light automation using IR remote.
Actual wall-mounted installation of Arduino relay system for fan and light control.

🔌 Arduino to IR Receiver

IR PinArduino
VCC5V
GNDGND
OUTD2

🔌 Arduino to Relays

RelayArduino Pin
FanD3
Light1D4
Light2D5

🔌 Power Supply

Use your 5V charger:

  • 5V → Arduino 5V pin
  • 5V → Relay VCC
  • GND → Common ground

AC Wiring (Critical)

Think of the relay like a switch controlled by Arduino.

Normally, you press a switch to turn ON a light.
Here, the relay does that job automatically.

Each relay has 3 pins:

  • COM → main input wire (Phase)
  • NO → goes to your light/fan (OFF by default)

When relay is OFF:
→ COM and NO are not connected → device is OFF

When relay turns ON:
→ COM and NO connect → device turns ON

So basically, relay is just opening and closing a connection like a switch.


Arduino Code (Tested & Working)

This is the exact working code used in this setup:

I uploaded the code expecting everything to work.

Nothing happened.

The IR receiver LED was blinking, but there was no response from the relays.

The Catch I Learned the Hard Way

At first, nothing worked.

The IR receiver LED blinked, but Arduino showed nothing.

Turns out:

  • I was using old IRremote code
  • But had new library installed

This mismatch silently breaks everything.

👉 Lesson:
Always match code with library version.


Another Mistake (Important)

🔧 Using Active LOW Relay?

If your relay works opposite (turns ON when signal is LOW), then you are using an Active LOW relay.

You don’t need a separate code.

Just change this line:

👉 Replace with:

Apply the same change for all relays.

💡 Quick Test:
Upload this line:

  • If relay turns ON → Active HIGH
  • If relay stays OFF → Active LOW

Real-World Behavior (What to Expect)

Once the setup is complete, the response feels instant.

Press a button, and the relay switches immediately — no delay, no waiting.

Since everything works offline, the system remains stable and reliable every time you use it.

It doesn’t feel like a DIY project anymore. It behaves like a proper built-in control system.


Common Mistakes You Should Avoid

1. Powering from Arduino USB

At first, I tried powering the entire setup directly from the Arduino USB.

It worked… but only for a few seconds.

Then the relays started flickering, and sometimes the Arduino would reset randomly.

This happens because the USB port cannot supply enough current for multiple relays.

👉 Use a separate 5V power supply (like a mobile charger) to power both Arduino and relays properly.

2. Using NC Instead of NO

This is a very common wiring mistake.

If you connect your load to the NC (Normally Closed) terminal, your device will stay ON all the time — even when the relay is OFF.

👉 Always use NO (Normally Open) so the device turns ON only when the relay is activated.

3. Ignoring Common Ground

One mistake that causes confusing behavior is not connecting all grounds together.

If Arduino, relay module, and power supply don’t share a common ground, the system may behave randomly or not respond at all.

👉 Always connect all GND points together.

4. Cheap USB Cable

This is something most people overlook.

A cheap or thin USB cable can cause voltage drop, which leads to unstable operation — especially when relays switch.

👉 Use a good-quality USB cable to ensure stable power delivery.


Safety Considerations (Don’t Ignore)

You’re dealing with AC mains here, so this part is not optional.

A loose connection or wrong wiring can heat up within seconds. In the worst case, it can damage components or even cause sparks.

So don’t rush this.

Double-check every connection before powering it ON. Make sure all wires are properly tightened and insulated.

Always test your setup with a simple bulb first before connecting a fan or any heavy load.

And most importantly — never touch the circuit while it’s powered.


Why This Project Matters

This isn’t just a beginner project.

It teaches:

  • Real-world control systems
  • Signal decoding
  • Relay switching
  • AC safety
  • System debugging

More importantly:

👉 It solves an actual daily problem.


How You Can Upgrade This

Once this works, you can go further:

🔹 Add WiFi Control (ESP32)

If you want to control your devices from your phone, you can replace Arduino Nano with ESP32.

This allows you to build a simple web interface or app-based control while still keeping your relay setup the same.

If you want a more advanced system with mobile control, check my NodeMCU-based smart alarm project.

🔗 ESP32 Pinout Guide

If you’re confused between boards:

🔗 Microcontroller Development Boards Guide

🔹 Add Fan Speed Control

Right now, the relay only turns the fan ON or OFF.

If you want speed control, you’ll need to use a TRIAC-based dimmer circuit instead of a relay.

This allows you to control fan speed smoothly instead of just switching it.

🔹 Add Motion Sensor

You can add a PIR motion sensor to automate lighting.

This way, lights turn ON when someone enters the room and turn OFF automatically when no motion is detected.

🔹 Save State (EEPROM)

Currently, if power goes OFF, the system resets.

By storing the last state in EEPROM, you can restore the previous ON/OFF status automatically after power returns.


Final Thoughts & What to Do Next

This project taught me something simple but important — most problems don’t need complex solutions.

I initially thought about using WiFi, apps, and cloud control. But in reality, a simple IR remote solved the problem faster, more reliably, and without unnecessary complexity.

The biggest lesson was not in building the circuit, but in debugging it. Library mismatches, relay logic confusion — these small mistakes can completely break a system if you don’t understand what’s happening underneath.

If you’re building this, start simple.

Test it with one relay and a bulb first. Make sure the logic works, understand how your relay behaves (Active HIGH or LOW), and then expand it step by step.

Don’t rush the wiring, especially when dealing with AC. Take your time, verify connections, and prioritize safety.

And once everything is working, you’ll realize — controlling your room with a remote feels natural. Going back to manual switches won’t feel the same.

If you build this or get stuck anywhere, drop a comment. I’ll help you figure it out.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *