The use of the ESP8266 in the world of IoT

User avatar
By lozi_dani
#47074 Perfect! I am going to study that about the camera, I think it is possible but will not be easy hehe. You are right about the time of the reception of the images, now I'm getting one image per second, but is enough for my project. When I achieve something I will post it here.

About the HTML, do you think that to create the buttons for the movement of the robot is possible in the same way I can create a title in the page? In HTML, I know that it is possible to create buttons like, for example, simulating the arrow keys of my keyboard, and that's what I trying to achieve. As you said, concatenating strings I can build the page but, also can I build the buttons? Or maybe I need to do something different for that?
User avatar
By martinayotte
#47077 About HTML, of course the whole thing can be done with single string and then sent with single client.println(), all buttons are part of that HTML code, javascript/ajax of each buttons could be handled with different URL, such as "/arrowUp" and "/arrowDown" instead of the "/ledON" of the examples.
User avatar
By lozi_dani
#47102 I am trying this right now:

[lis]
#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()) // WIFI - Serial
{ w = BT1.read() ;
Serial.print(w);
W = W + w ;
}
if (Serial.available()) // Serial - WIFI
{ char s = Serial.read();
BT1.print(s);
}
if ( w == '\n'){ // If ENTER
if ( W.indexOf("P13") > 0 )
{ digitalWrite( 13, !digitalRead(13)) ;
Serial.println("Invirtiendo pin 13");
}
if ( W.indexOf("P12") > 0 )
{ digitalWrite( 12, !digitalRead(12)) ;
Serial.println("Invirtiendo pin 12");
}
if ( W.indexOf("P11") > 0 )
{ digitalWrite( 11, !digitalRead(11)) ;
Serial.println("Invirtiendo pin 11");
}

W = "" ; w = ' ' ;
}

if ( w == '\n'){
String str = String("<html>");
str += "<head>";
str += "</head>";
str += "<body>";
str += "<h1 align='center'>Project</h1><h3 align='center'>Motores controlados por Web</h3>";
str += "<div style='text-align:center;'>";
str += "<button onClick=location.href='./?P11\' style='margin:auto;background-color: #84B1FF;color: snow;padding: 10px;border: 1px solid #3F7CFF;width:65px;'>";
str += "AUTO-MAN";
str += "</button>";
str += "<button onClick=location.href='./?P12\' style='margin:auto;background-color: #84B1FF;color: snow;padding: 10px;border: 1px solid #3F7CFF;width:65px;'>";
str += "DERECHA";
str += "</button>";
str += "<button onClick=location.href='./?P13\' style='margin:auto;background-color: #84B1FF;color: snow;padding: 10px;border: 1px solid #3F7CFF;width:65px;'>";
str += "IZQUIERDA";
str += "</button>";
str += "<br /><br />";
// more html code here ...
str += "</body>";
str += "</html>";
BT1.println(str);
}
}
[/lis]

And it doesn't works. I think I'm doing it well, but I don't know where it breaks. The program compile right, but when I start the serial monitor or try to connect with its IP using the browser, nothing.

But if I avoid the HTML code, I have no problem putting in the browser the IP with the command like IP/command. Why could be this happening if I only added a string to display it in the browser?

This is the code that works fine:

[lis]
#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()) // WIFI - Serial
{ w = BT1.read() ;
Serial.print(w);
W = W + w ;
}
if (Serial.available()) // Serial - WIFI
{ char s = Serial.read();
BT1.print(s);
}
if ( w == '\n'){ //If ENTER
if ( W.indexOf("P13") > 0 )
{ digitalWrite( 13, !digitalRead(13)) ;
Serial.println("Invirtiendo pin 13");
}
if ( W.indexOf("P12") > 0 )
{ digitalWrite( 12, !digitalRead(12)) ;
Serial.println("Invirtiendo pin 12");
}
if ( W.indexOf("P11") > 0 )
{ digitalWrite( 11, !digitalRead(11)) ;
Serial.println("Invirtiendo pin 11");
}

W = "" ; w = ' ' ;
}
}
[/lis]

I have seen that I don't need to inicialize any client or server to do this (the code that works), So I think that is the same for the code where I add the HTML. Anyway, I am not able to compile programs with the ESP libraries because this libraries says that I need to run it in an ESP board, an my Arduino is _AVR_.

Even so I think I don't need this libraries because the code runs well (without the HTmL code of course). So maybe you could see what could be wrong in the code with the HTML that I am not able to see?