0805-761-5108 || hello@nerdshed.com.ng

Control an A.C Light Bulb Over The Internet from a Smartphone

WARNING! WARNING! WARNING!

High voltage 240V. Exercise caution

In this article, we’ll control an AC light over the Internet using NodeMCU board and Blynk App.

Why do we use relay to control an A.C light bulb?

A.C the 220V supplied by utility (PHCN) cannot be controlled directly from the The NodeMCU board (which operates at 3V). The relay is an electromagnetic switch that electronically controls power applied to loads, in this case an AC bulb.

A relay has NO, NC and COM, what do they mean?

  • COM – Common, as the name suggests is common to both NC and NO terminals.
  • NO – Normally Open is normally open until power is applied to the relay’s coil, so current does not flow until the relay is activated.
  • NC – The Normally Closed terminal allows current to flow until the current is applied to the relay at which case it goes off.
                                       
                                                          Relay terminals

For the purpose of this tutorial, I’ll be using COM and NO.

You’ll need the following to carry out this project

Hardware

  • NodeMCU 12-E board, get here
  • 5V DC, 10A 250V AC relay module. get it here
  • 2N7000 MOSFET, get it here
  • 4.7k Ohm resistor.
  • An A.C light bulb.
  • 10 mm wires.

Software

  • Blynk app, refer to this article here if it’s your first time working with Blynk
  • Latest Arduino IDE, get it here

STEP 1: CIRCUITRY

Please note: The purpose of the transistor is to invert the output of the NodeMCU (The relay is coil is activated when logic 0 is sent in and vice versa). Also it shifts the voltage level to 5V-0V, the relay operates at 5V.

nodemcu relay circuit
                                                                        nodemcu relay circuit

STEP 2: Setting up BLYNK

We will be using Blynk app to control the A.C bulb over the internet. I showed you how to set up Blynk and create a button, if you missed it you can check it out here. For the purpose of this tutorial, we would be using the button we created. If you’ve set up Blynk successfully which entails getting your AUTH TOKEN, you can move to the next step.

(NOTE: SAVE THE TOKEN, IT CAN BE REUSED FOR OTHER PROJECTS)

STEP 3: NodeMCU code

I also showed you how to setup the NodeMCU board in the Arduino IDE, if you missed it, check it out here. After successfully setting up the board, upload this code.

NodeMCU relay code
NodeMCU relay code

When the IDE is done uploading the code to the NodeMCU board, fire up your serial monitor to debug the connection to your Wi-Fi connection. Open up your Blynk App and control your A.C light bulb!!!!

Results

If everything is done right, your A.C bulb should light up like this when you control it with the Blynk App

nodemcu blynk result
Node-Mcu Blynk result

Wanna Do More?

A setup such as this can be used to control water pumps, A.C/D.C fan, lights, garage doors.

Share This Post

Leave a Reply

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

No products in the cart.

X