Quantcast
Aktuelles
Digital Eliteboard - Das Digitale Technik Forum

Registriere dich noch heute kostenlos, um Mitglied zu werden! Sobald du angemeldet bist, kannst du auf unserer Seite aktiv teilnehmen, indem du deine eigenen Themen und Beiträge erstellst und dich über deinen eigenen Posteingang mit anderen Mitgliedern unterhalten kannst! Zudem bekommst du Zutritt zu Bereichen, welche für Gäste verwehrt bleiben

Registriere dich noch heute kostenlos, um Mitglied zu werden! Sobald du angemeldet bist, kannst du auf unserer Seite aktiv teilnehmen, indem du deine eigenen Themen und Beiträge erstellst und dich über deinen eigenen Posteingang mit anderen Mitgliedern unterhalten kannst! Zudem bekommst du Zutritt zu Bereichen, welche für Gäste verwehrt bleiben

WLAN Fernsteuerrung für Enima2 boxen selbstgebaut mit dem ESP8622

atzedvb

Newbie
Registriert
12. Mai 2013
Beiträge
8
Reaktionspunkte
12
Punkte
23
Problem: Ich hab eine VU+ Solo im Wohnzimmer und über einen HDMI Splitter die Küche und das Bad angeschlossen. Soweit so gut, aber wie steuere ich nun in der Küche bzw. im Bad meine VU+, per smartphone oder Tablet macht wenig Sinn.

Benötigte Hardware:
1x ESP8266 Modul ca. 5€
1x IR reciever 1€ (oder aus ausgedienter Hardware Auslöten)
1x USB Micro Kabel ca. 1€
1x Lötkolben
Lötet den IR-Reciver siehe Pinbelegung:

Du musst angemeldet sein, um Bilder zu sehen.

nach folgenden Schema auf:

+ auf 5V
- auf G (masse)
Data out an D4



Du musst angemeldet sein, um Bilder zu sehen.


So ungefähr.

Dann die Arduino IDE herrunterladen installieren und bei Datei/Voreinstellungen/Zusätsliche Bordvervalter diesen link eintragen:

Jetzt könnt ihr mit dem Proggen beginnen.
hier der Code:
Code:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <IRremoteESP8266.h>

////////////////////////// Hier Anpassen /////////////////////////////////////////////////
IRrecv irrecv(D4);//IR Emfänger an D4 gelötet
const char *ssid = "meinWlan"; //SID eures Wlans
const char *password = "xyz"; //Passwort Wlan
IPAddress receiver(192,168,***,***); //IP Adresse des Receivers
/////////////////////////////////////////////////////////////////////////////////////////


char* tastencodes[] = {"113", "116",  "388", "370",     "102", "107","2","3","4","5","6","7","8","9","10","412",   "11","407", "398","399",  "400",   "401","103","108", "105", "106", "352","115",   "114",     "174", "358","402",  "403",    "139", "393",         "392",  "138", "168",   "207", "119",  "208",   "377","167",   "128", "385"};
char* tastennames[] = {"mute","Power","text","subtitle","home","end","1","2","3","4","5","6","7","8","9","previous","0","next","red","green","yellow","blue","up","down","left","right","OK","vol-up","vol-down","exit","epg","ch-up","ch-down","menu","videoaltlast","audio","help","rewind","play","pause","forward","tv","record","stop","radio"};
int numoftasten = sizeof(tastencodes)/4;

decode_results results;
WiFiClient client;
ESP8266WebServer server ( 80 );

// you can write your own css and html code (head) here
String head1 = "<!DOCTYPE html> <html>\n <head>\n <title>Vu+ Solo2 Websteuerung</title>\n <style>\n";
String css = "body {background: url(\"http://www.hdwallpapers.in/walls/distant_planet_3d-HD.jpg\") no-repeat fixed 0 0 / cover rgba(0,0,0,0); color: #ffeeff; font-family: 'Century Gothic', CenturyGothic, AppleGothic, sans-serif;}h1 {font-size: 2em;}\n";
String head2 = "</style>\n</head>\n<body>\n<center>\n";
String header = head1 + css + head2;
String body = "";

String website(String h, String b){
  String complete = h+b;
  return complete;
}

void setup ( void ) {
  Serial.begin(115200);

   // Connect to WiFi network
   if (Serial){
    Serial.print("Verbinde zu : ");
    Serial.println(ssid);
    }
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
    if (Serial){
     delay(1000);
     Serial.print(".");
     }
  }
   if (Serial){
    printWifiStatus();
    }
  bauebody();
  // Starte den webserver, this page is loaded when accessing the root of esp8266´s IP
   server.on("/", [](){
   String webPage = website(header, body);
   server.send(200, "text/html", webPage);
   });

  // pages for all your sockets are created dynamical
  for(int i = 0; i < numoftasten ; i++){
    String path = "/taste="+String(tastencodes[i]);
    const char* pathChar = path.c_str();
 
    server.on(pathChar, [i](){
      String webPage = website(header, body);
      server.send(200, "text/html", webPage);
      if (Serial){
       Serial.print("Tastencode: ");
       Serial.print(tastencodes[i]);
       Serial.print(" Tastenname: ");
       Serial.println(tastennames[i]);
      }
      httpAnfrage(i);
      });
   }

  server.begin();
  if (Serial){
   Serial.println("HTTP Server gestarted");
   }
    irrecv.enableIRIn();// Starte den IR Receiver
  if (Serial){
   Serial.println ("Infrarot Receiver gestartet");
   }
}

void loop ( void ) {
  server.handleClient();
   if (irrecv.decode(&results)) {
    dump(&results);
    irrecv.resume(); // Empfange nächsten code
   }
}


void httpAnfrage(int code) {
  // close any connection before send a new request. This will free the socket on the WiFi shield
  client.stop();

  // if there's a successful connection:
  if (client.connect(receiver, 80)) {
     if (Serial){
      Serial.println(" sende GET /api/remotecontrol?command="+String(tastencodes[code]));
     }
    // send the HTTP GET request:
    client.println("GET /api/remotecontrol?command="+String(tastencodes[code])+" HTTP/1.1");
    client.println("Host: google.de");
    client.println("User-Agent: ESP8266");
    client.println("Connection: close");
    client.println();
    }
   else {
    if (Serial){
    Serial.println("Verbindung zur vuplus gescheitert");  // wenn keine Verbindung möglich
    }
  }
 }

void dump(decode_results *results) {
  // Dumps out the decode_results structure.
  // Call this after IRrecv::decode()
  int count = results->rawlen;
  if (results->decode_type == RC6) {
       check(results->value);
    }
    else{
    if (results->decode_type >= 0 ){
     if (Serial){
       checkhersteller(results->decode_type);
       Serial.print(" -> Decoded: ");
       Serial.println(results->value, HEX);
       }
     }
    }
}

void printWifiStatus() {
  Serial.println("");
  Serial.println("WiFi vebunden");
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());// SSID vom verbundenen Netzwerk:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Addresse: ");
  Serial.println(ip);// WiFi shield's IP Addresse:
  long rssi = WiFi.RSSI();// Signalstärke
  Serial.print("Signal Staerke (RSSI): ");
  Serial.print(rssi);
  Serial.println(" dBm");
  Serial.print("IP Addresse: der VU+ : ");
  Serial.println(receiver);
}

void check(unsigned long c) {
   String t="";
byte buf[4];
buf[0] = (byte) c;
buf[1] = (byte) c >> 8;
buf[2] = (byte) c >> 16;
buf[3] = (byte) c >> 24;
  if (Serial) {
   Serial.print(buf[0]);
   Serial.print(" -> ");
   }
switch (buf[0]) {
    case 0: t="11"; break;
    case 1: t="2";  break;
    case 2: t="3";  break;
    case 3: t="4"; break;
    case 4: t="5"; break;
    case 5: t="6"; break;
    case 6: t="7";  break;
    case 7: t="8";  break;
    case 8: t="9"; break;
    case 9: t="10"; break;
    case 12: t="116"; break;
    case 13: t="113"; break;
    case 16: t="115"; break;
    case 17: t="114"; break;
    case 32: t="402"; break;
    case 33: t="403"; break;
    case 40: t="208";  break;
    case 41: t="168"; break;
    case 44: t="207"; break;
    case 48: t="119"; break;
    case 49: t="128";  break;
    case 55: t="167"; break;
    case 60: t="388"; break;
    case 73: t="393"; break;
    case 75: t="370"; break;
    case 84: t="139"; break;
    case 85: t="174"; break;
    case 88: t="103";  break;
    case 89: t="108";  break;
    case 90: t="105"; break;
    case 91: t="106"; break;
    case 92: t="352"; break;
    case 109: t="398";  break;
    case 110: t="399"; break;
    case 111: t="400"; break;
    case 112: t="401"; break;
    case 129: t="138"; break;
    case 185: t="102"; break;
    case 186: t="107"; break;
    case 187: t="412"; break;
    case 188: t="407"; break;
    case 204: t="358"; break;
    case 228: t="377"; break;
    case 229: t="392"; break;
    case 242: t="385"; break;
    }

   for(int i = 0; i < numoftasten ; i++){
    if ( t == String(tastencodes[i]) ){
      httpAnfrage(i);
    if (Serial) {
       Serial.print(" -> Vu+ Solo2, Taste: "+ t +" -> ");
       Serial.println(tastennames[i]);
     }
      break;
      }
   }
}

void checkhersteller(int code){
switch (code) {
  case 1:
    Serial.print ("NEC");
    break;
  case 2:
    Serial.print ("SONY");
    break;
  case 3:
    Serial.print ("RC5");
    break;
  case 4:
    Serial.print ("RC6");
    break;
  case 5:
    Serial.print ("DISH");
    break;
  case 6:
    Serial.print ("SHARP");
    break;
  case 7:
    Serial.print ("PANASONIC");
    break;
  case 8:
    Serial.print ("JVC");
    break;
  case 9:
    Serial.print ("SANYO");
    break;
  case 10:
    Serial.print ("MITSUBISHI");
    break;
  case 11:
    Serial.print ("SAMSUNG");
    break;
  case 12:
    Serial.print ("LG");
    break;
  case 13:
    Serial.print ("WHYNTER");
    break;
  case 14:
    Serial.print ("AIWA_RC_T501");
    break;
  case 15:
    Serial.print ("COOLIX");
    break;
  default:
    Serial.print ("Kein bekannter Code");
    break;
    }
}

String IpAddress2String(const IPAddress& ipAddress)
{
  return
  String(ipAddress[0]) + String(".") +\
  String(ipAddress[1]) + String(".") +\
  String(ipAddress[2]) + String(".") +\
  String(ipAddress[3])  ;
}

void bauebody() {
 body = "<h1>Vu+ Solo2 Websteuerung</h1>\n";
   body +="<img border=\"0\" src=\"http://"+IpAddress2String(receiver)+"/static/remotes/vu/rc.png\" usemap=\"#map\" width=\"135\" height=\"500\" border=\"0\">\n";
   body +="<map name=\"map\">\n";
   body +="<area shape=\"circle\" coords=\"33,28,15\"   id=\"113\" alt=\"mute\" onclick=\"window.location='taste=113';\">\n";
   body +="<area shape=\"circle\" coords=\"105,28,15\"  id =\"116\" alt=\"Power\" onclick=\"window.location='taste=116';\">\n";
   body +="<area shape=\"circle\" coords=\"33,53,15\"   id =\"388\" alt=\"text\" onclick=\"window.location='taste=388';\">\n";
   body +="<area shape=\"circle\" coords=\"58,53,15\"   id =\"370\" alt=\"subtitle\" onclick=\"window.location='taste=370';\">\n";
   body +="<area shape=\"circle\" coords=\"82,53,15\"   id =\"102\" alt=\"home\" onclick=\"window.location='taste=102';\">\n";
   body +="<area shape=\"circle\" coords=\"105,53,15\"  id =\"107\" alt=\"end\" onclick=\"window.location='taste=107';\">\n";
   body +="<area shape=\"circle\" coords=\"38,79,15\"   id =\"2\" alt=\"1\" onclick=\"window.location='taste=2';\">\n";
   body +="<area shape=\"circle\" coords=\"70,79,15\"   id =\"3\" alt=\"2\" onclick=\"window.location='taste=3';\">\n";
   body +="<area shape=\"circle\" coords=\"102,79,15\"  id =\"4\" alt=\"3\" onclick=\"window.location='taste=4';\">\n";
   body +="<area shape=\"circle\" coords=\"38,106,15\"  id =\"5\" alt=\"4\" onclick=\"window.location='taste=5';\">\n";
   body +="<area shape=\"circle\" coords=\"70,106,15\"  id =\"6\" alt=\"5\" onclick=\"window.location='taste=6';\">\n";
   body +="<area shape=\"circle\" coords=\"102,106,15\" id =\"7\" alt=\"6\" onclick=\"window.location='taste=7';\">\n";
   body +="<area shape=\"circle\" coords=\"38,133,15\"  id =\"8\" alt=\"7\" onclick=\"window.location='taste=8';\">\n";
   body +="<area shape=\"circle\" coords=\"70,133,15\"  id =\"9\" alt=\"8\" onclick=\"window.location='taste=9';\">\n";
   body +="<area shape=\"circle\" coords=\"102,133,15\" id =\"10\" alt=\"9\" onclick=\"window.location='taste=10';\">\n";
   body +="<area shape=\"circle\" coords=\"38,161,15\"  id =\"412\" alt=\"previous\" onclick=\"window.location='taste=412';\">\n";
   body +="<area shape=\"circle\" coords=\"70,161,15\"  id =\"11\" alt=\"0\" onclick=\"window.location='taste=11';\">\n";
   body +="<area shape=\"circle\" coords=\"102,161,15\" id =\"407\" alt=\"next\" onclick=\"window.location='taste=407';\">\n";
   body +="<area shape=\"circle\" coords=\"33,186,15\"  id =\"398\" alt=\"red\" onclick=\"window.location='taste=398';\">\n";
   body +="<area shape=\"circle\" coords=\"58,186,15\"  id =\"399\" alt=\"green\" onclick=\"window.location='taste=399';\">\n";
   body +="<area shape=\"circle\" coords=\"82,186,15\"  id =\"400\" alt=\"yellow\" onclick=\"window.location='taste=400';\">\n";
   body +="<area shape=\"circle\" coords=\"105,186,15\" id =\"401\" alt=\"blue\" onclick=\"window.location='taste=401';\">\n";
   body +="<area shape=\"circle\" coords=\"70,213,15\"  id =\"103\" alt=\"up\" onclick=\"window.location='taste=103';\">\n";
   body +="<area shape=\"circle\" coords=\"70,283,15\"  id =\"108\" alt=\"down\" onclick=\"window.location='taste=108';\">\n";
   body +="<area shape=\"circle\" coords=\"35,248,15\"  id =\"105\" alt=\"left\" onclick=\"window.location='taste=105';\">\n";
   body +="<area shape=\"circle\" coords=\"105,248,15\" id =\"106\" alt=\"right\" onclick=\"window.location='taste=106';\">\n";
   body +="<area shape=\"circle\" coords=\"70,248,20\"  id =\"352\" alt=\"OK\" onclick=\"window.location='taste=352';\">\n";
   body +="<area shape=\"circle\" coords=\"40,307,15\"  id =\"115\" alt=\"volume up\" onclick=\"window.location='taste=115';\">\n";
   body +="<area shape=\"circle\" coords=\"40,338,13\"  id =\"114\" alt=\"volume down\" onclick=\"window.location='taste=114';\">\n";
   body +="<area shape=\"circle\" coords=\"70,310,15\"  id =\"174\" alt=\"exit\" onclick=\"window.location='taste=174';\">\n";
   body +="<area shape=\"circle\" coords=\"70,334,15\"  id =\"358\" alt=\"epg\" onclick=\"window.location='taste=358';\">\n";
   body +="<area shape=\"circle\" coords=\"99,307,15\"  id =\"402\" alt=\"channelup\" onclick=\"window.location='taste=402';\">\n";
   body +="<area shape=\"circle\" coords=\"99,338,15\"  id =\"403\" alt=\"channeldown\" onclick=\"window.location='taste=403';\">\n";
   body +="<area shape=\"circle\" coords=\"36,362,15\"  id =\"139\" alt=\"menu\" onclick=\"window.location='taste=139';\">\n";
   body +="<area shape=\"circle\" coords=\"59,362,15\"  id =\"393\" alt=\"videoaltlast\" onclick=\"window.location='taste=393';\">\n";
   body +="<area shape=\"circle\" coords=\"81,362,15\"  id =\"392\" alt=\"audio\" onclick=\"window.location='taste=392';\">\n";
   body +="<area shape=\"circle\" coords=\"104,362,15\" id =\"138\" alt=\"help\" onclick=\"window.location='taste=138';\">\n";
   body +="<area shape=\"circle\" coords=\"36,393,15\"  id =\"168\" alt=\"rewind\" onclick=\"window.location='taste=168';\">\n";
   body +="<area shape=\"circle\" coords=\"59,393,15\"  id =\"207\" alt=\"play\" onclick=\"window.location='taste=207';\">\n";
   body +="<area shape=\"circle\" coords=\"81,393,15\"  id =\"119\" alt=\"pause\" onclick=\"window.location='taste=119';\">\n";
   body +="<area shape=\"circle\" coords=\"104,393,15\" id =\"208\" alt=\"forward\" onclick=\"window.location='taste=208';\">\n";
   body +="<area shape=\"circle\" coords=\"36,415,15\"  id =\"377\" alt=\"tv\" onclick=\"window.location='taste=377';\">\n";
   body +="<area shape=\"circle\" coords=\"59,415,15\"  id =\"167\" alt=\"record\" onclick=\"window.location='taste=167';\">\n";
   body +="<area shape=\"circle\" coords=\"81,415,15\"  id =\"128\" alt=\"stop\" onclick=\"window.location='taste=128';\">\n";
   body +="<area shape=\"circle\" coords=\"104,415,15\" id =\"385\" alt=\"radio\" onclick=\"window.location='taste=385';\">\n";
   body +="</map>\n";
   body += "</center>\n</body>\n</html>";
 }

Falls alles geklappt hat steckt einfach euer ESP8266 an einen freien USB port eures TV an und nach ca. 8 sek. könnt ihr mit der Fernbedienung von jedem Raum aus euren Reciever steuern.
Mit der IP-Adresse eures ESP8266 könnt ihr auch im Browser euren Receiver per web steuern (smartphone, tablet usw.)
Du musst angemeldet sein, um Bilder zu sehen.


Solltet ihr keine VU+ haben müsst ihr die Codes im Quelltext natürlich anpassen.
Viel Spass mit dieser Anleitung
MfG AtzeDVB


edit: habe das Bild für die Weboberfläche vergessen

.
Du musst angemeldet sein, um Bilder zu sehen.
 

Anhänge

Du musst angemeldet sein, um die Anhangsliste zu sehen.
Zuletzt bearbeitet:
Zurück
Oben