PROJECT TITLE:
Voice Controlled IoT Smart Bulb using NodeMCU, Google
Assistant, Adafruit IO, and IFTTT
---
Final Result:
Aap Google Assistant se bolenge:
> “Hey Google, Turn bulb ON”
“Hey Google, Turn bulb OFF”
Aapka AC bulb NodeMCU ke zariye relay se ON/OFF ho
jayega, bina haath lagaye!
---
STEP 1: Required Components
Component Quantity Approx Cost
NodeMCU (ESP8266) 1 ₹200
5V Relay Module 1 ₹50
AC Bulb (LED) + Holder 1 ₹40
Jumper Wires 1 set ₹20
Breadboard (optional) 1 ₹40
USB Cable (for NodeMCU) 1 ₹0
Mobile with Google Assistant 1 Already available
Power supply (Phone charger) 1 ₹0
---
🛠 STEP 2: Circuit Diagram (Wiring)
⚙ NodeMCU ↔ Relay:
Relay Pin NodeMCU Pin
IN D1
VCC 3.3V
GND GND
⚠ Relay ↔ Bulb (AC side):
1. Bulb ka ek wire → Relay ke NO pin
2. Relay COM pin → AC Live wire
3. Bulb ka doosra wire → AC Neutral wire
Relay ON hone par bulb glow karega. OFF hone par off.
---
STEP 3: Setup Arduino IDE
1. Install Arduino IDE
[Link]
2. Install ESP8266 Board
File → Preferences → Paste:
[Link]
m_index.json
Tools → Boards Manager → Search “ESP8266” → Install
3. Select Board:
Tools → Board → NodeMCU 1.0 (ESP-12E Module)
---
STEP 4: Create Adafruit IO Account
[Link]
1. Sign up/login
2. Go to Feeds → Create a feed named bulb
3. Go to My Key section (top-right) → Note:
AIO Key
Username
---
STEP 5: Arduino Code
Install Libraries (via Library Manager):
Adafruit MQTT Library
Code:
#include <ESP8266WiFi.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
#define WLAN_SSID "YourWiFiName"
#define WLAN_PASS "YourWiFiPassword"
#define AIO_SERVER "[Link]"
#define AIO_SERVERPORT 1883
#define AIO_USERNAME "YourAdafruitUsername"
#define AIO_KEY "YourAdafruitAIOKey"
WiFiClient client;
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER,
AIO_SERVERPORT, AIO_USERNAME, AIO_KEY);
Adafruit_MQTT_Subscribe bulbFeed =
Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME
"/feeds/bulb");
int relayPin = D1;
void setup() {
[Link](115200);
pinMode(relayPin, OUTPUT);
[Link](WLAN_SSID, WLAN_PASS);
while ([Link]() != WL_CONNECTED) {
delay(500);
[Link](".");
}
[Link](&bulbFeed);
}
void loop() {
MQTT_connect();
Adafruit_MQTT_Subscribe *subscription;
while ((subscription = [Link](5000))) {
if (subscription == &bulbFeed) {
String command = (char *)[Link];
if (command == "ON") {
digitalWrite(relayPin, HIGH);
} else if (command == "OFF") {
digitalWrite(relayPin, LOW);
}
}
}
}
void MQTT_connect() {
int8_t ret;
if ([Link]()) return;
while ((ret = [Link]()) != 0) {
delay(5000);
}
}
✔ Replace karo:
WiFi name & password
Adafruit username & AIO key
---
STEP 6: Setup IFTTT (Voice to Cloud Trigger)
Create IFTTT Account
[Link]
Make a New Applet:
If This:
Choose Google Assistant
Select “Say a phrase with a text ingredient”
Example: “Turn bulb $”
What do you want Assistant to say: “Turning bulb
{{TextField}}”
Then That:
Choose Webhooks
Select Make a Web Request
URL:
[Link]
ulb/data
Method: POST
Content-Type: application/json
Body:
{"value":"{{TextField}}"}
Save kar do!
---
STEP 7: Final Testing
1. NodeMCU + Relay + Bulb power on karo
2. Google Assistant se bolo:
> “Hey Google, turn bulb ON”
“Hey Google, turn bulb OFF”
Relay click karega aur bulb ON/OFF ho jayega!
---
BONUS: Add Speed/Timer Features (Advanced)
Use Firebase, Google Sheets for logs
Schedule bulb using Adafruit IO Dashboard
Connect with home automation system