Introduction: Voice Control NodeMCU ESP8266 Over Internet Using Firebase

About: I am a professional blogger from India.

In this instructable, I am going to show how to create an Android application to voice control Nodemcu esp8266.


  1. NodeMCU ESP8266 development board
  2. Breadboard
  3. LED (to check if the project is working)
  4. Firebase (to create a database)
  5. MIT app inventor 2 (to create Android application)

Step 1: Setup Firebase and Get Secret Key

We are going to use a real-time database by Google firebase. This real-time database will act as a midway broker between Nodemcu and Android device.

  • First of all, navigate to firebase site and log in using your google account.
  • Create a new real-time database.
  • Get real-database URL and secret key to access the database from the app. For a detailed tutorial, you can check out how to use firebase with MIT app inventor.

Step 2: Create Voice Controllable Android App

We are going to use MIT app inventor 2 to create our Android app. Its very simple to use and easy to integrate win Google firebase.

You can do it in two ways:-

Way one:-

  • Create a new app, and then make the layout (as shown in screenshot 1).
  • After that, create code logic (as shown in screenshot 2).

Way two:-

  • Alternatively, you can download the project (.aia file) attached below
  • Then go to MIT app inventor >> projects >> import project (as shown in screenshot 3). Select the file from your computer and upload it. After that open project and navigate to screen2 (as shown in screenshot 4).

Once layout and code logic is ready, go to layout window, click on firebaseDB1 (located at bottom of the workspace), enter database URL and secret key. Also keep ProjectBucket field empty (as shown in screenshot 5).

After that, click on the build button and save app file (.apk file) to your computer. Later transfer that file to your Android device.

Step 3: Configure Arduino IDE for Nodemcu ESP8266

  • After that, add these two libraries (reference screenshot) :-
  1. Arduino Json
  2. Firebase Arduino

Step 4: Code Time

#include "ESP8266WiFi.h"
#include "FirebaseArduino.h"

#define FIREBASE_HOST ""        // Enter Firebase database URL here without 'https://' and last '/' (ex.
#define FIREBASE_AUTH "secter-key-here"            // Enter Firebase database secret key here
#define WIFI_SSID "Wifi-SSID"            // Enter WiFi SSID to which you want to connect NodeMCU ESP8266
#define WIFI_PASSWORD "Wifi-PassWord"    // Enter password of WiFi
int data,data1,count=0;

void setup()  {



Serial.print("Connecting to Wifi");
  while (WiFi.status()!=WL_CONNECTED){


void loop() {
  if (Firebase.failed()) {
      Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
      Serial.println("Error Failed Connection To Firebase!");
    if (count==10) {count=0; ESP.reset(); }

   else { 

      Serial.println("Everything is ready!");
      delay(30); Serial.println("Everything is ready!");
      delay(30); Serial.println("Everything is ready!");


data=Firebase.getString("/data").toInt();  // Fetch data from real-time database




 if(data1==1)                          // If data is 1, trun on LED 

      Serial.println("light 1 ON"); }

    if (data1==0)             // If data is , trun off LED
      Serial.println("light 1 OFF");
    }    delay(300);

Step 5: Upload After Some Changes

You must do some necessary changes in code before uploading to Nodemcu.

  • At line 3, enter database URL without 'https://'.
  • At line 4, enter database secret key.
  • At line 5 and 6, don't forget to update WiFi SSID and Wifi password (to which you want to connect NodeMCU ESP8266)

Step 6: Getting Everything Ready

  • Install the app on your Android device.
  • Put NodeMCU esp8266 on the breadboard, connect through PC and upload the program.
  • Connect the positive terminal of LED to D2 pin and the negative terminal of LED to D3 pin (Please comment below if you want circuit diagram).
  • Now run the app and say "turn on lights" or "turn off lights".
  • Enjoy The Magic!

Step 7: Recognize More Languages

Hope everything worked fine for you till step 6.

By default speech recognizer of MIT App Inventor 2 can recognize the English language only. Now if you want to use another language in speech recognition then you need an extension. Just follow a quick workaround.

  • Download Taifun Speech recognizer extension for MIT app inventor.
  • Import this extension in your project.
  • Drag and drop TaifunSpeechRecognizer in place of the default speech recognizer.

That it!

I had tested this extension and it supports 25+ languages including Hindi, Spanish, French, German and many more. For documentation of this extension, you can check its official site.

Need any help regarding this instructable? Please comment below.

Epilog X Contest

Participated in the
Epilog X Contest