Advertisement

WIFI Remote using ESP3266 Microcontroller

             WIFI  Remote using Esp8266 



                                In the previous articles we learnt about how to decode or encode the Ir signals of your tv remote. With the decoded ir signal values in this blog article i am to going to build a wifi tv remote which is fully powered by Esp8266 microcontroller. After building this project you can control your tv through wifi which you can access through any devices with wifi compatible like smartphone, pc,laptop or ipad.

                        For this project you will need an ESP8266 microcontroller, an ir transmitter led, and an npn transistor (to boost up the range of the ir signal send by the ESP8266). If you haven't a ESP8266 microcontroller you can buy it from here


                                        


How can we program the esp8266 microcontroller??


                        Like the arduino we can program the ESP8266 microcontroller through the arduino ide, but ot program the ESP8266 microcontroller we need install some libraries. First of all you need to include the ESP8266 board in the additional boards manager. In your arduino IDE go to file and then click preferences at the bottom you will see the additional boards manager urls. In that box paste the given link

 http://arduino.esp8266.com/stable/package_esp8266com_index.json





this will download all the boards related to the ESP8266  Controller. Then the IR Remote library for arduino board will not support for ESP8266. In order to make the things work as similar as the arduino, we have to install the IR remote library for the ESP8266 it is named as IR remote ESP8266.


Don't know how to decode your IR remote signals read this : Click here



                    Before connecting the board into your computer you should have decoded your TV remote signals and you have to change that hexadecimal values to a normal decimal values. Because this program automatically converts the decimal values to hexadecimal values.

Connect the circuit as per the diagram given below:







                       PROGRAM CODE



#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>
#include <WiFiClient.h>

const char* ssid = "JioFi";
const char* password = "0987654321";
MDNSResponder mdns;

ESP8266WebServer server(80);

IRsend irsend(4);  // An IR LED is controlled by GPIO pin 4 (D2)

void handleRoot() {
  server.send(200, "text/html",
              "<html>" \
                "<head><title>wifi Remote</title></head>" \
                "<h2><a href=\"ir?code=2160016324\">POwer ON/OFF </a></h2>" \
                "<body>" \
                  "<h1>Hello from ESP8266, you can send NEC encoded IR signals from here!</h1>" \
                  "<h2><a href=\"ir?code=16753245\">POwer ON/OFF </a></h2>" \
                  "<body><a href=\"ir?code=16769565\">Mute</a></body>" \
                  "<p><a href=\"ir?code=16748655\">Play/Pause</a></p>" \
                  "<body><a href=\"ir?code=16736925\">Stop</a></body>" \
                  "<p><a href=\"ir?code=16720605\">Mode</a></p>" \
                  "<p><a href=\"ir?code=16712445\">Play Again</a></p>" \
                  "<p><a href=\"ir?code=16761405\">Equilizer</a></p>" \
                  "<p><a href=\"ir?code=16769055\">Previous</a></p>" \
                  "<p><a href=\"ir?code=16754775\">Next</a></p>" \
                  "<p><a href=\"ir?code=16738455\">Volume Down</a></p>" \
                  "<p><a href=\"ir?code=16750695\">Volume Up</a></p>" \
                  "<p><a href=\"ir?code=16756815\">Number 0</a></p>" \
                  "<p><a href=\"ir?code=16724175\">Number 1</a></p>" \
                  "<p><a href=\"ir?code=16718055\">Number 2</a></p>" \ // use your own TV remote decoded signal values
                  "<p><a href=\"ir?code=16743045\">Number 3</a></p>" \
                  "<p><a href=\"ir?code=16716015\">Number 4</a></p>" \
                  "<p><a href=\"ir?code=16726215\">Number 5</a></p>" \
                  "<p><a href=\"ir?code=16734885\">Number 6</a></p>" \
                  "<p><a href=\"ir?code=16728765\">Number 7</a></p>" \
                  "<p><a href=\"ir?code=16730805\">Number 8</a></p>" \
                  "<p><a href=\"ir?code=16732845\">Number 9</a></p>" \
                  "<h2>Full TV Control </h2>" \
                  "<h2><a href=\"ir?code=2160016324\">POwer ON/OFF </a></h2>" \
                  "<h2><a href=\"ir?code=2160017854\"> Last Channel </a></h2>" \
                  "<h2><a href=\"ir?code=2160001534\">Volume Up </a></h2>" \
                  "<h2><a href=\"ir?code=2160034174\">Volume Down </a></h2>" \
                  "<h2><a href=\"ir?code=2160005614\">List of Channels </a></h2>" \
                  "<h2><a href=\"ir?code=2160042334\">Channel Up</a></h2>" \
                  "<h2><a href=\"ir?code=2160026014\">Channel Down </a></h2>" \ // the number 2160026014 in this line of code is the decoded IR signal value which is converted into a decimal value
                  "<h2><a href=\"ir?code=2160019894\">Numeber 1 </a></h2>" \
                  "<h2><a href=\"ir?code=2160052534\">Numeber 2 </a></h2>"  \
                  "<h2><a href=\"ir?code=2160014284\">Numeber 3 </a></h2>" \
                  "<h2><a href=\"ir?code=2160030094\">Numeber 4 </a></h2>" \
                  "<h2><a href=\"ir?code=2160062734\">Numeber 5 </a></h2>" \
                  "<h2><a href=\"ir?code=2160051180\">Numeber 6 </a></h2>" \
                  "<h2><a href=\"ir?code=2160021934\">Numeber 7 </a></h2>" \
                  "<h2><a href=\"ir?code=2160054564\">Numeber 8 </a></h2>" \
                  "<h2><a href=\"ir?code=2160010204\">Numeber 9 </a></h2>" \
                  "<h2><a href=\"ir?code=2160058654\">Numeber 0 </a></h2>" \
                  "<h2><a href=\"ir?code=2160015814\">Mute </a></h2>" \
                  "<h2><a href=\"ir?code=2160042844\">Exit </a></h2>" \
                  "<h2><a href=\"ir?code=2160030604\">Ok</a></h2>" \
                  "<h2><a href=\"ir?code=2160020404\">Arrow Down</a></h2>" \
                  "<h2><a href=\"ir?code=2160034684\">Arrow Right</a></h2>" \
                  "<h2><a href=\"ir?code=2160040294\">Arrow Left</a></h2>" \
                  "<h2><a href=\"ir?code=2160022444\">Arrow Up</a></h2>" \
                  "<h2><a href=\"ir?code=2160030604\">Ok</a></h2>" \
         
                  "</body>" \
              "</html>");
}

void handleIr() {
  for (uint8_t i = 0; i < server.args(); i++) {
    if (server.argName(i) == "code") {
      uint32_t code = strtoul(server.arg(i).c_str(), NULL, 10);
      irsend.sendNEC(code, 32);
    }
  }
  handleRoot();
}

void handleNotFound() {
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET)?"GET":"POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i = 0; i < server.args(); i++)
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  server.send(404, "text/plain", message);
}

void setup(void) {
  irsend.begin();

  Serial.begin(115200);
  WiFi.begin(ssid, password);
  Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  if (mdns.begin("esp8266", WiFi.localIP())) {
    Serial.println("MDNS responder started");
  }

  server.on("/", handleRoot);
  server.on("/ir", handleIr);

  server.on("/inline", [](){
    server.send(200, "text/plain", "this works as well");
  });

  server.onNotFound(handleNotFound);

  server.begin();
  Serial.println("HTTP server started");
}

void loop(void) {
  server.handleClient();
}



                            After uploading the code don't unplug the ESP8266 from your computer, open the serial monitor it will print the local ip address through which you can access your wifi remote web page for controlling your TV. 



                Then copy the local IP address and paste it on your web browser you will see your remote buttons on your web page. Make sure that your device and your  ESP8266 should connected on the same wifi network.


Post a Comment

0 Comments