Hello I am new to the forum that's why I will introduce myself.
Being in french high school I have for project for my baccalaureate to achieve a litter called home automation that would see the frequency of passage of my cat on my phone the whole with WIFI. And it is the wifi that worries me since it's been over a week that I stay on the same problem thatI would like to solve that's why I'm calling for your help. I use an ESP-01 with arduino mega the whole forming a mini server (arduinoWebServer) that I program with AT commands so far no problem. I can also load a web page and display text that I send via the command AT + CIPSEND = ID, numberDATA. However beyond that I would like to be able to display the information sent on an application that is my first goal in the end by using APP INVENTOR. In short I do the right things to receive the DATA (message) but an error message appears on my phone ...
voici mon programme :
#define esp8266 Serial2// <===== In case of using MEGA, take out the comment
//#include <SoftwareSerial.h> // In case of using MEGA, mark the line as comment
//SoftwareSerial esp8266(2,3); // In case of using MEGA, mark the line as comment
//Rx ==> Pin 2; TX ==> Pin3
#define speed8266 115200 // <========= Change the Speed for the one used at Module
#define CH_PD 4
#define DEBUG true
void setup() {
Serial.begin(9600);
esp8266.begin(115200);
reset8266();
InitWifiModule();
}
void loop() {
if (esp8266.available()){
while(esp8266.available()){
char c=esp8266.read();
Serial.write(c);
}
}
if(Serial.available()){
delay(1000);
String command="";
while(Serial.available()){
command+=(char)Serial.read();
}
esp8266.println(command);}
}
void reset8266 ()
{
pinMode(CH_PD, OUTPUT);
digitalWrite(CH_PD, LOW);
delay(300);
digitalWrite(CH_PD, HIGH);
}
String sendData(String command, const int timeout, boolean debug)
{
String response = "";
esp8266.print(command); // send the read character to the esp8266
long int time = millis();
while( (time+timeout) > millis())
{
while(esp8266.available())
{
char c = esp8266.read(); // read the next character.
response+=c;
}
}
if(debug)
{
Serial.print(response);
}
return response;
}
void InitWifiModule()
{
sendData("AT+RST\r\n", 2000, DEBUG); // reset
sendData("AT+CWMODE=1\r\n", 1000, DEBUG);
//sendData("AT+CWJAP=\"dlink\",\"\"\r\n", 2000, DEBUG); //Connect network
// sendData("AT+CWJAP=\"Livebox-A5D8\",\"GmYXRsZbuVgsEQkEZM\"\r\n", 2000, DEBUG); //Connect network
delay (1000);
sendData("AT+CIFSR\r\n", 1000, DEBUG); // Show IP Adress
sendData("AT+CIPMUX=1\r\n", 1000, DEBUG); // Multiple conexions
sendData("AT+CIPSERVER=1,80\r\n", 1000, DEBUG); // start comm port 80
}
I put all the documents at the bottom of the post:
-1 image on the program initialization (AT commands) to create the server seen from the serial monitor of the arduino IDE
-1 image on the serial monitor of the arduino IDE when sending data to a web page (Hello World)
-4 images on the problem related to the application (3 of the application part interface + error message and the other data sent from the serial monitor of the arduino IDE)
-1 image on the wiring diagram used
Hoping to have some feedback, thank you