ESP8266 Serial remote control

Hi

I have an olde Denon Reciver,
it do only have RS232C connection.

So i want to connect a ESP8266 to it so i can be able to control it over ethernet

I want it simple

for an example:
if i goto URL "http://ESP8266-IP/denon/PW=ON"
the ESP8266 will send "PWON" (Turn ON the AVR)

if i goto URL "http://ESP8266-IP/denon/MV=UP"
the ESP8266 will send "MVUP" (Turn UP the Master Volume)

if i goto URL "http://ESP8266-IP/denon/MV=80"
the ESP8266 will send "MV80" (Sets the Master Volume to 80)

over the Serial connection with folloring settings:

Speed: 6900
Bit: 8
Half Duplex

Hope that some on can help me.

Post your program and tell us which part you are having trouble with.

If you want someone to write code for you please ask in the Gigs and Collaborations section of the Forum and be prepared to pay.

...R

I look for some code,
i dont think i am the first one to try to make a rs232 wifi gateway.

So maby you can send me in a direction,
maby a link.

line-web:
I look for some code,
i dont think i am the first one to try to make a rs232 wifi gateway.

What did Google tell you?

I suspect you are unlikely to find a ready-made program that will do exactly what you want. However there will be a lot of examples and tutorials for the different parts.

Have a look at the Useful Links Thread.

...R

i Tryed Google,
But i can only find Guides to Connect the ESP8266 to the pc over RS232 to USB

Read this to get the web server part working:
https://tttapa.github.io/ESP8266/Chap10 - Simple Web Server.html
Then it's just a matter of Serial.print'ing the right commands to the UART.
If it's a 3.3V TTL UART, you can probably connect it to the ESP directly, if it's true RS232, you'll need something like the MAX-232 for level shifting. If it's a 5V TTL UART, use a simple resistive voltage divider on the ESP's RX line, or don't connect it at all if you don't need it.

Pieter

One of the standard examples for the ESP8266 is have it set up a web server, displaying a page with two links. One switches on an LED, one switches it off. Replace the LED digitalWrite for a Serial.println() and you're pretty much there.

line-web:
i Tryed Google,
But i can only find Guides to Connect the ESP8266 to the pc over RS232 to USB

Isn't that essentially the same as what you want to do? Except that you are connecting to a different device.

Or, are you referring to guides about how to program the ESP8266?

Try Googling esp8266 html to serial

...R

Will this work?

#include <ESP8266WiFi.h>
 
const char* ssid = "SSID";//type your ssid
const char* password = "PASS";//type your password
 
WiFiServer server(80);//Service Port
 
void setup() {
  Serial.begin(9600);
  delay(10);
   
  // Connect to WiFi network
  WiFi.begin(ssid, password);
   
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
   
  // Start the server
  server.begin();
 
  // Print the IP address
  Serial.print("Use this URL to connect: ");
  Serial.print("http://");
  Serial.print(WiFi.localIP());
  Serial.println("/Denon/");
}
 
void loop() {
  // 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 request = client.readStringUntil('\r');
  //Serial.println(request);
  client.flush();
   
  // Match the request
 
  if (request.indexOf("/Denon/PW=ON") != -1) {
    Serial.print("PWON<CR>");
  } 
  if (request.indexOf("/Denon/PW=STANDBY") != -1){
    Serial.print("PWSTANDBY<CR>");
  } 
  if (request.indexOf("/Denon/MV=UP") != -1){
    Serial.print("MVUP<CR>");
  } 
  if (request.indexOf("/Denon/MV=DOWN") != -1){
    Serial.print("MVDOWN<CR>");
  } 
  if (request.indexOf("/Denon/MU=ON") != -1){
    Serial.print("MUON<CR>");
  } 
  if (request.indexOf("/Denon/MU=OFF") != -1){
    Serial.print("MUOFF<CR>");
  } 
  if (request.indexOf("/Denon/SI=PHONE") != -1){
    Serial.print("SIPHONE<CR>");
  } 
  if (request.indexOf("/Denon/SI=CD") != -1){
    Serial.print("SICD<CR>");
  } 
  if (request.indexOf("/Denon/SI=TUNER") != -1){
    Serial.print("SITUNER<CR>");
  } 
  if (request.indexOf("/Denon/SI=DVD") != -1){
    Serial.print("SIDVD<CR>");
  } 
  if (request.indexOf("/Denon/SI=V.AUX") != -1){
    Serial.print("SIV.AUX<CR>");
  } 
  if (request.indexOf("/Denon/SI=TV") != -1){
    Serial.print("SITV<CR>");
  }
 
  //Set ledPin according to the request
  //digitalWrite(ledPin, value);
   
  // Return the response
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println(""); //  do not forget this one
  client.println("<!DOCTYPE HTML>");
  client.println("<html>");

  client.println("Power <a href=\"/Denon/PW=ON\">ON</a>
");
  client.println("Power <a href=\"/Denon/PW=STANDBY\">STANDBY</a>
");
  client.println("

");
  client.println("Volume <a href=\"/Denon/MV=UP\">UP</a>
");
  client.println("Volume <a href=\"/Denon/MV=DOWN\">DOWN</a>
");
  client.println("Mute <a href=\"/Denon/MU=ON\">ON</a> ");
  client.println("Mute <a href=\"/Denon/MU=OFF\">OFF</a>
");
  client.println("

");
  client.println("

");
  client.println("<a href=\"/Denon/SI=DVD\">DVD</a> - <a href=\"/Denon/SI=CD\">CD</a>
");
  client.println("<a href=\"/Denon/SI=TV\">TV</a> - <a href=\"/Denon/SI=V.AUX\">V.AUX</a>
");
  client.println("<a href=\"/Denon/SI=PHONE\">PHONE</a> - <a href=\"/Denon/SI=TUNER\">TUNER</a>
");
  client.println("</html>");
 
  delay(1);
  //Serial.println("Client disconnected");
  Serial.println("");
}

line-web:
Will this work?

Only one way to find out ...

i don't know how "" is going to work.

Replace "" with '\r'.

line-web:
i don't know how "" is going to work.

Did you try to simply run that code and see what happens?

It did not work.

line-web:
It did not work.

That does not provide any useful information from which to make suggestions.

You need to explain in detail what happens when you run the program.

...R

Robin2:
That does not provide any useful information from which to make suggestions.

You need to explain in detail what happens when you run the program.

...R

The program worked fine running on the PC
But when i connected it to the AVR, ther was no respose.

i was able to connect to the webserver. but nothing happend when i klicked a link, other then it reloadet with the new url,
so the Serial communication did not work.

line-web:
The program worked fine running on the PC

What does that mean?
How was it connected to the PC?
What did you see on the PC?
What program were you using on the PC?

But when i connected it to the AVR, ther was no respose.

How was it connected to the AVR?

Did you replace all the ""s with '\r' as recommended in Reply #11?

If so you have changed the program and you need to post the latest version.

...R

Robin2:
What does that mean?
How was it connected to the PC?
What did you see on the PC?
What program were you using on the PC?

How was it connected to the AVR?

Did you replace all the ""s with '\r' as recommended in Reply #11?

If so you have changed the program and you need to post the latest version.

...R

I am using Arduino io,
and by "working on the pc"
i got my respons in Serial Monitor as i was hoping for the AVR to resive.

yes i changed the "" to "\r" so it look like:

#include <ESP8266WiFi.h>
 
const char* ssid = "SSID";//type your ssid
const char* password = "PASS";//type your password
 
WiFiServer server(80);//Service Port
 
void setup() {
  Serial.begin(9600);
  delay(10);
   
  // Connect to WiFi network
  WiFi.begin(ssid, password);
   
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
   
  // Start the server
  server.begin();
 
  // Print the IP address
  Serial.print("Use this URL to connect: ");
  Serial.print("http://");
  Serial.print(WiFi.localIP());
  Serial.println("/Denon/");
}
 
void loop() {
  // 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 request = client.readStringUntil('\r');
  //Serial.println(request);
  client.flush();
   
  // Match the request
 
  if (request.indexOf("/Denon/PW=ON") != -1) {
    Serial.print("PWON\r");
  } 
  if (request.indexOf("/Denon/PW=STANDBY") != -1){
    Serial.print("PWSTANDBY\r");
  } 
  if (request.indexOf("/Denon/MV=UP") != -1){
    Serial.print("MVUP\r");
  } 
  if (request.indexOf("/Denon/MV=DOWN") != -1){
    Serial.print("MVDOWN\r");
  } 
  if (request.indexOf("/Denon/MU=ON") != -1){
    Serial.print("MUON\r");
  } 
  if (request.indexOf("/Denon/MU=OFF") != -1){
    Serial.print("MUOFF\r");
  } 
  if (request.indexOf("/Denon/SI=PHONE") != -1){
    Serial.print("SIPHONE\r");
  } 
  if (request.indexOf("/Denon/SI=CD") != -1){
    Serial.print("SICD\r");
  } 
  if (request.indexOf("/Denon/SI=TUNER") != -1){
    Serial.print("SITUNER\r");
  } 
  if (request.indexOf("/Denon/SI=DVD") != -1){
    Serial.print("SIDVD\r");
  } 
  if (request.indexOf("/Denon/SI=V.AUX") != -1){
    Serial.print("SIV.AUX\r");
  } 
  if (request.indexOf("/Denon/SI=TV") != -1){
    Serial.print("SITV\r");
  }
 
  //Set ledPin according to the request
  //digitalWrite(ledPin, value);
   
  // Return the response
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println(""); //  do not forget this one
  client.println("<!DOCTYPE HTML>");
  client.println("<html>");

  client.println("Power <a href=\"/Denon/PW=ON\">ON</a> / <a href=\"/Denon/PW=STANDBY\">STANDBY</a>

");
  client.println("Volume <a href=\"/Denon/MV=UP\">UP</a> / <a href=\"/Denon/MV=DOWN\">DOWN</a>

");
  client.println("Mute <a href=\"/Denon/MU=ON\">ON</a> / <a href=\"/Denon/MU=OFF\">OFF</a>

");
  client.println("

");
  client.println("<a href=\"/Denon/SI=DVD\">DVD</a> - <a href=\"/Denon/SI=CD\">CD</a> - <a href=\"/Denon/SI=TV\">TV</a>
");
  client.println("<a href=\"/Denon/SI=V.AUX\">V.AUX</a> - <a href=\"/Denon/SI=PHONE\">PHONE</a> - <a href=\"/Denon/SI=TUNER\">TUNER</a>
");
  client.println("</html>");
 
  delay(1);
  //Serial.println("Client disconnected");
  Serial.println("");
}

There could be a number of different problems:

  1. Hardware: you didn't connect the right pins, or you didn't use the right voltage level.
  2. Baud rate
  3. Commands: the commands you Serial.print is incorrect.

Try controlling the receiver first, then try to add WiFi.

Pieter

line-web:
I am using Arduino io,

I don't know what that means.

If this was my project I would strip out ALL the WiFi stuff and reduce the code so that it is just sending a single command. When I got that working I would add the other codes one by one testing at each step. When I had all that working I would add in the WiFi stuff.

...R