In this tutorial, I will show you how to turn ON and OFF a light bulb using the previous tutorial “ESP8266 NodeMCU – Blinking a LED” and adding a relay module.
- ESP8266 NodeMCU v1.0
- Micro-USB to USB cable
- 3x Male to female jumper wires
- Light bulb
- 3.3V relay module
If you want to build your own relay module (optional):
- 3.3V Relay (SRD-03VDC-SL-C)
The main goal here is to replace the LED used in the last tutorial with a 230V light bulb. In order to do that we will need a relay module. You can buy one from here or build your own module (see the last chapter of this tutorial).
Circuit and Schematic
Step 1: Start by connecting 3v3 from NodeMCU to VCC pin in relay module, GND from NodeMCU to GND from the relay module and D1 from NodeMCU to In of the relay module.
Step 2: Upload the code from last tutorial “ESP8266 NodeMCU – Blinking a LED”