- Sat May 07, 2016 6:44 am
#47040
I' sorry, you are right, my question has not too much info. I will try to explain me better.
I have tried to follow this example:
http://diymakers.es/crear-servidor-web-con-arduino/In this page, the code seems that try to insert HTML code using the sketch that loads in the Arduino. They do this:
********************************************
//Página web en formato HTML
client.println("<html>");
client.println("<head>");
client.println("</head>");
client.println("<body>");
client.println("<h1 align='center'>DIYMakers</h1><h3 align='center'>LED controlado por Servidor Web con Arduino</h3>");
//Creamos los botones. Para enviar parametres a través de HTML se utiliza el metodo URL encode. Los parámetros se envian a través del símbolo '?'
client.println("<div style='text-align:center;'>");
client.println("<button onClick=location.href='./?LED=ON\' style='margin:auto;background-color: #84B1FF;color: snow;padding: 10px;border: 1px solid #3F7CFF;width:65px;'>");
client.println("ON");
client.println("</button>");
client.println("<button onClick=location.href='./?LED=OFF\' style='margin:auto;background-color: #84B1FF;color: snow;padding: 10px;border: 1px solid #3F7CFF;width:65px;'>");
client.println("OFF");
client.println("</button>");
client.println("<br /><br />");
client.println("<b>LED = ");
client.print(estado);
client.println("</b><br />");
client.println("</b></body>");
client.println("</html>");
****************************************************************
So, when they put the IP address of the ESP01 using the browser, they can see the image shown in their web, where they have two buttons to choose if the led is ON or OFF.
I have seen a lot of examples where people creates an HTML code independently of the ESP01, like led_on.html, and from the ESP01 send the info to that page. I was not able to do that. When I saw the example of the link above, I've seen that putting in the browser 192.xxx.x.x the are able to see some buttons with that code they put in the Arduino.
I want to try something like that, but when I try this example, it seems that the module doesn't try to connect with my WiFi. I can see this when I connect the Arduino via USB with my PC and doesn't put anything in the serial monitor.
What I have achieved is to do the same, but I have to put in the browser the command, like 192.xxx.x.x/ledOn, to put the led ON.
Maybe you know why with my code is able to do the connections as the setup() says, and with the code of the link not?
I put my code here:
**********************************************
#include <SoftwareSerial.h>
SoftwareSerial BT1(3, 2); // RX | TX
String W =" ";
char w ;
void setup()
{
Serial.begin(9600);
BT1.begin(9600);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
BT1.write("AT+CWMODE=3\r\n");
delay(1000);
BT1.write("AT+CIPMUX=1\r\n");
delay(1000);
BT1.write("AT+CIPSERVER=1,80\r\n");
delay(1000);
}
void loop()
{
if (BT1.available()) // Lo que entra por WIFI - Serial
{ w = BT1.read() ;
Serial.print(w); // Vamos montando un String con lo que entra
W = W + w ;
}
if (Serial.available()) // Lo que entra por Serial - WIFI
{ char s = Serial.read();
BT1.print(s);
}
if ( w == '\n') // Sin han pulsado intro
{ if ( W.indexOf("P13") > 0 ) // Si P13 esta incluido en el string
{ digitalWrite( 13, !digitalRead(13)) ;
Serial.println("Invirtiendo pin 13");
}
if ( W.indexOf("P12") > 0 ) // Si P13 esta incluido en el string
{ digitalWrite( 12, !digitalRead(12)) ;
Serial.println("Invirtiendo pin 12");
}
if ( W.indexOf("P11") > 0 ) // Si P13 esta incluido en el string
{ digitalWrite( 11, !digitalRead(11)) ;
Serial.println("Invirtiendo pin 11");
}
W = "" ; w = ' ' ;
}
}
****************************************************
Thanks for your reply! And I didn't know that ESP01 and ESP12 use the same chip, I thought that maybe use a different version or something like that.