Head office, Rana Pratap Bagh, Delhi011 2721 1512+91 97116 99511

Science project idea

Phone web page that switches a 12 V LED strip through an ESP8266 relay

A NodeMCU (ESP8266) joins the home Wi-Fi, runs a tiny web server and turns a relay on or off when a phone browser taps a button. The relay switches a 12 V LED strip, so the whole thing is a low-voltage copy of a smart switch.

What it shows

A NodeMCU (ESP8266) joins the home Wi-Fi, runs a tiny web server and turns a relay on or off when a phone browser taps a button. The relay switches a 12 V LED strip, so the whole thing is a low-voltage copy of a smart switch.

The science

The ESP8266 has Wi-Fi built in. Code in the free ESP8266 ebook makes it serve a small HTML page with two links, /on and /off. When the phone opens a link, the board sets GPIO pin D1 high or low. That pin drives the relay module through its own transistor, and the relay contacts close the 12 V circuit to the strip. The strip current never passes through the ESP8266, which is why a relay is used instead of a bare pin.

Materials

Cost: under Rs 1,500. Many items come from home or from waste; spare parts such as LEDs, motors and wire are in the store.

  • A NodeMCU ESP8266 board and micro USB cable
  • A 5 V single-channel relay module
  • A 12 V LED strip, about 30 cm
  • A 12 V, 1 A DC adapter or 8 AA cells in a holder
  • A breadboard and jumper wires
  • A phone on the same Wi-Fi

Safety

For this project: Only the 12 V LED strip goes through the relay. Never connect the relay to a mains wire or socket. An adult must check the wiring before the adapter is plugged in.

Never use mains electricity: power models with cells, batteries or a low-voltage adapter. Sharp and hot tools, flames and lab chemicals need an adult or your teacher beside you. Keep magnets, button cells and small parts away from young children, and wash your hands after making.

All the safety rules

Step by step

9 steps. Do them in order, and test each part before you go on to the next. Write what you notice in a notebook as you go.

  1. Install the Arduino IDE and add the ESP8266 board package using the board manager URL given in the ebook.

  2. Wire the relay module: VCC to the NodeMCU Vin (5 V from USB), GND to GND, IN to pin D1.

  3. Connect the 12 V adapter positive to the relay COM terminal and the relay NO terminal to the strip positive. Strip negative goes straight back to the adapter negative.

  4. Open the web server example from the ebook, type in your Wi-Fi name and password, and set the pin to D1.

  5. Upload the sketch and open the serial monitor at 115200 baud to read the IP address the router gave the board.

  6. Type that IP address into the phone browser. You should see the page with ON and OFF buttons.

  7. Tap ON and listen for the relay click; the strip should light. If it clicks but the strip stays dark, check the COM and NO terminals.

  8. Add a third button in the HTML that toggles the state, and show the current state on the page.

  9. Mount everything in a cardboard or plastic box with the strip on the outside for the exhibition table.

What you should see

The LED strip turns on and off from any phone on the same Wi-Fi within about half a second. The serial monitor shows each request as it arrives.

Viva questions

A teacher or a judge will ask how it works. Try to answer each question before you open it, then compare.

1Why is a relay needed instead of driving the strip from a pin?

An ESP8266 pin can give only about 12 mA at 3.3 V. The strip needs 12 V and hundreds of milliamps, so the relay acts as an electrically separate switch.

2What do NO and NC on the relay mean?

Normally open and normally closed. NO is disconnected until the coil is energised; NC is the opposite.

3What happens if the Wi-Fi password is wrong?

The board never gets an IP address, so the serial monitor keeps printing dots and the page cannot load.

4Could this control a mains bulb?

Not in this project. Mains wiring needs a licensed electrician and proper enclosures; here only 12 V DC is switched.

Free ebook: Viva Questions for Science Projects

Take it further

Add a second relay and a DHT11 so the page also shows room temperature and lets you switch a 12 V fan.

Change one thing, measure what happens, and add a table or chart of your readings: that is what turns a model into your own investigation.

Free ebooks for this project

WhatsApp us