Voice Controlled Electrical Appliances using Android app and ESP8266 Reviewed by Momizat on . https://www.youtube.com/watch?v=iozvVt0EL_M This Tutorial is a part of "Controlling Home Appliances using Android App". If you have not read the first part befo https://www.youtube.com/watch?v=iozvVt0EL_M This Tutorial is a part of "Controlling Home Appliances using Android App". If you have not read the first part befo Rating: 0
You Are Here: Home » IOT » Voice Controlled Electrical Appliances using Android app and ESP8266

Voice Controlled Electrical Appliances using Android app and ESP8266






This Tutorial is a part of “Controlling Home Appliances using Android App“. If you have not read the first part before, I strongly recommended to read it first(Click Here To Read Part 1).

As in part 2 of the tutorial we built an android app to control GPIO of ESP8266 using button press. In this tutorial instead of button we will Speech Recognization¬†to control same thing. ¬†In this article, we will use “Speech Recognizer” component of App Inventor 2¬†.

 

Step 1: Bring a button from user interface to screen, change background image  to something fancy like below.

Button-Speak

Step 2: add a text box, where you can enter the ip address of your ESP8266 wifi chip.

Step 3:¬† In block section, add “when button get click” and “call speech recognizer.gottext” like shown below.

code1

Step 4: ¬† Then Call and “Speech Recognizer . After Getting Text” like bellow and do your algorithm, call web services of ESP server inside that like bellow.

cod2

Thats all.Now Run and test your app.

To Turn On Lamp: You have to speak “Turn On Lamp”

To Turn Off Lamp: You have to speak “Turn Off Lamp”

Screen Shot of the app, I have created.

Screenshot_2016-03-13-22-11-33              Screenshot_2016-03-13-22-11-51                  Screenshot_2016-03-13-22-11-25

You can download the whole app inventor source code of the app by clicking here.

You Can download the app from play store, by clicking here.

 

Let me know, if you have any doubt regarding source code or anything related to this.

Now play with your imagination and make something cool. Happy Hacking ūüôā

First part of this tutorial: https://www.myelectronicslab.com/tutorial/controlling-home-appliances-using-android-app-part-1/

Second Part Of the tutorial: https://www.myelectronicslab.com/tutorial/controlling-home-appliences-with-esp8266-and-android-app-part-2/

[subscribe2]

About The Author

I am a maker, who loves to think, hack and build new electronics stuff, I always find time to document , share my knowledge with others. I am graduate in BTech(Electronics and Communication Engineering).

Number of Entries : 41
  • Tanmay

    Nice bro…

  • Lusifar_on

    Lots of iot project ūüôā seriously like it bro good job

  • Ciprian Colisnicencu

    I’m getting this error:
    no activity found to handle intent {act=android.speech.action.recognize_speech (has extras) }

    Can you help me?
    Thank you in advance!

    Ciprian

  • Roberto Carlos Da silva Alvare

    Congratulations for your job.
    I tried your verbal code, very good.
    Can you help me change your code for Arduino OTA?
    THE CODE I MADE IS WRONG, CAN YOU HELP ME TO CORRECT IT?
    WHAT IS YOUR EMAIL TO SEND TO THE CODE THAT I DID WITH?
    MY EMAIL IS — [email protected]

    THANK YOU

    //———OTA_TESTE_WEMOS_VOICE_GARAGEM_SOCIAL_V2————-

    //https://www.myelectronicslab.com/tutorial/voice-controlled-lamp-esp8266/
    //https://www.myelectronicslab.com/tutorial/controlling-home-appliances-using-android-app-part-1/
    //https://www.myelectronicslab.com/tutorial/controlling-home-appliences-with-esp8266-and-android-app-part-2/
    //https://www.myelectronicslab.com/tutorial/voice-controlled-lamp-esp8266/
    /*
    * This sketch demonstrates how to set up a simple HTTP-like server.
    * The server will set a GPIO pin depending on the request
    * http://server_ip/gpio/0 will set the GPIO2 low,
    * http://server_ip/gpio/1 will set the GPIO2 high
    * server_ip is the IP address of the ESP8266 module, will be
    * printed to Serial when the module is connected.
    */

    #include
    #include
    #include
    #include
    const char* ssid = “XXXXXXXXXXXXXXX”;
    const char* password = “XXXXXXXXXXXXXXX”;

    // Create an instance of the server
    // specify the port to listen on as an argument
    WiFiServer server(80);

    void setup() {
    Serial.begin(115200);
    delay(10);
    Serial.println(“Booting”);
    WiFi.mode(WIFI_STA);

    //—– prepare GPIO2
    pinMode(2, OUTPUT);
    digitalWrite(2, 0);

    //———- Connect to WiFi network
    Serial.println();
    Serial.println();
    Serial.print(“Connecting to “);
    Serial.println(ssid);

    WiFi.begin(ssid, password);

    while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(“.”);
    }
    Serial.println(“”);
    Serial.println(“WiFi connected”);

    // Start the server
    server.begin();
    Serial.println(“Server started”);

    // Print the IP address
    Serial.println(WiFi.localIP());
    while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println(“Connection Failed! Rebooting…”);
    delay(5000);
    ESP.restart();
    }
    // Port defaults to 8266
    // ArduinoOTA.setPort(8266);

    // Hostname defaults to esp8266-[ChipID]
    ArduinoOTA.setHostname(“myesp8266″);

    // No authentication by default
    // ArduinoOTA.setPassword((const char *)”123”);

    ArduinoOTA.onStart([]() {
    Serial.println(“Start”);
    });
    ArduinoOTA.onEnd([]() {
    Serial.println(“nEnd”);
    });
    ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
    Serial.printf(“Progress: %u%%r”, (progress / (total / 100)));
    });
    // ArduinoOTA.onError([](ota_error_t error) {
    // Serial.printf(“Error[%u]: “, error);
    // if (error == OTA_AUTH_ERROR) Serial.println(“Auth Failed”);
    // else if (error == OTA_BEGIN_ERROR) Serial.println(“Begin Failed”);
    // else if (error == OTA_CONNECT_ERROR) Serial.println(“Connect Failed”);
    // else if (error == OTA_RECEIVE_ERROR) Serial.println(“Receive Failed”);
    // else if (error == OTA_END_ERROR) Serial.println(“End Failed”);
    // });
    ArduinoOTA.begin();
    Serial.println(“Ready”);
    Serial.print(“IP address: “);
    Serial.println(WiFi.localIP());
    }

    void loop() {
    ArduinoOTA.handle();
    ////////}
    //——— Check if a client has connected
    WiFiClient client = server.available();
    if (!client) {
    return;
    }

    // Wait until the client sends some data
    Serial.println(“new client”);
    while(!client.available()){
    delay(1);
    }

    // Read the first line of the request
    String req = client.readStringUntil(‘r’);
    Serial.println(req);
    client.flush();

    // Match the request
    int val;
    if (req.indexOf(“/gpio/0”) != -1)
    val = 0;
    else if (req.indexOf(“/gpio/1”) != -1)
    val = 1;
    else {
    Serial.println(“invalid request”);
    client.stop();
    return;
    }

    // Set GPIO2 according to the request
    digitalWrite(2, val);

    client.flush();

    // Prepare the response
    String s = “HTTP/1.1 200 OKrnContent-Type: text/htmlrnrnrnrnGPIO is now “;
    s += (val)?”high”:”low”;
    s += “n”;

    // Send the response to the client
    client.print(s);
    delay(1);
    Serial.println(“Client disonnected”);

    // The client will actually be disconnected
    // when the function returns and ‘client’ object is detroyed
    }

Scroll to top