hi guys
i need help about my college task, i'm newbie and starting to find the coding on internet, im using arduino uno , modulwifi esp8266 , 2 led + resistor, and converter 3.3volt.
i got this code and video and compile and upload to uno and still no idea about output pin to led on code i was found.
#include <SoftwareSerial.h>
#define DEBUG true
SoftwareSerial Schneider(2, 3); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.
// This means that you need to connect the TX line from the esp to the Arduino's pin 2
// and the RX line from the esp to the Arduino's pin 3
void setup()
{
Serial.begin(9600);
Schneider.begin(9600); // your esp's baud rate might be different
sendData("AT+RST\r\n", 2000, DEBUG); // reset module
sendData("AT+CWMODE=2\r\n", 1000, DEBUG); // configure as access point
sendData("AT+CIFSR\r\n", 1000, DEBUG); // get ip address
sendData("AT+CIPMUX=1\r\n", 1000, DEBUG); // configure for multiple connections
sendData("AT+CIPSERVER=1,80\r\n", 1000, DEBUG); // turn on server on port 80
}
void loop()
{
if (Schneider.available()) // check if the esp is sending a message
{
/*
while(esp8266.available())
{
// The esp has data so display its output to the serial window
char c = esp8266.read(); // read the next character.
Serial.write(c);
} */
if (Schneider.find("+IPD,"))
{
delay(1000);
int connectionId = Schneider.read() - 48; // subtract 48 because the read() function returns
// the ASCII decimal value and 0 (the first decimal number) starts at 48
String webpage = "
Hello
<h2>World!LED1";String cipSend = "AT+CIPSEND=";
cipSend += connectionId;
cipSend += ",";
cipSend += webpage.length();
cipSend += "\r\n";
sendData(cipSend, 1000, DEBUG);
sendData(webpage, 1000, DEBUG);
webpage = "LED2";
cipSend = "AT+CIPSEND=";
cipSend += connectionId;
cipSend += ",";
cipSend += webpage.length();
cipSend += "\r\n";
sendData(cipSend, 1000, DEBUG);
sendData(webpage, 1000, DEBUG);
String closeCommand = "AT+CIPCLOSE=";
closeCommand += connectionId; // append connection id
closeCommand += "\r\n";
sendData(closeCommand, 3000, DEBUG);
}
}
}
String sendData(String command, const int timeout, boolean debug)
{
String response = "";
Schneider.print(command); // send the read character to the esp8266
long int time = millis();
while ( (time + timeout) > millis())
{
while (Schneider.available())
{
// The esp has data so display its output to the serial window
char c = Schneider.read(); // read the next character.
response += c;
}
}
if (debug)
{
Serial.print(response);
}
return response;
}
I particularly appreciated for who wants to help me ,
thank you