-->
Page 1 of 1

Arduino Uno Esp8266

PostPosted: Mon Aug 26, 2019 8:14 am
by josephchrzempiec
Hello I'm using arduino uno and a Esp8266 Huzzah board. Everything is working i can do at commands using Software Serial. I'm trying to get a Web server running also a SD Card to old files on it. But for right now I'm just trying to get a simple web page up and running. I'm attaching the sketch and Serial monitor output in here. Problem I'm having is that there is no web page. It compiles with no problem and Serial monitor says no errors it does connect to my WIFI router and does have a IP address Just no web page. I'm not very good at coding I'm really stuck can someone please help me?

This is the sketch.

Code: Select all#include <SoftwareSerial.h>
#define DEBUG true

SoftwareSerial esp8266(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);
  esp8266.begin(9600); // your esp's baud rate might be different



  sendData("AT+RST\r\n",2000,DEBUG); // reset module
//  sendData("AT",2000,DEBUG); // send AT command
//  sendData("AT+GMR\r\n",2000,DEBUG); // returns firmware
//  Serial.println("checking mode");
//  sendData("AT+CWMODE=?\r\n",5000,DEBUG); // check supported modes
//
//  Serial.println("scanning APs");
//  sendData("AT+CWLAP\r\n",21000,DEBUG); // scan list of access points

  Serial.println("set mode 1");
  sendData("AT+CWMODE=1\r\n",5000,DEBUG); // configure as both mode

//  Serial.println("joining AP");
  sendData("AT+CWJAP=\"myssid\",\"982912701284\"\r\n", 16000, DEBUG); // connect to wifi

  Serial.println("Testing CIFSR");
  sendData("AT+CIFSR\r\n",7000,DEBUG); // get ip address

  Serial.println("setting for multiple connection");
  sendData("AT+CIPMUX=1",2000,DEBUG); // configure for multiple connections

  Serial.println("print MAC address");
  sendData("AT+CIPSTAMAC?\r\n",2000,DEBUG); // print current MAC address

  Serial.println("set port 80 for server");
  sendData("AT+CIPSERVER=1\r\n,80",2000,DEBUG); // turn on server on port 80
}

void loop()
{
  if(esp8266.available()) // check if the esp is sending a message
  {

    if(esp8266.find("+IPD,"))
    {
     delay(2000);

     int connectionId = esp8266.read()-48; // subtract 48 because the read() function returns
                                           // the ASCII decimal value and 0 (the first decimal number) starts at 48

     String webpage = "<h1>Tyagi IoT</h1><button>LED1</button>";

     String cipSend = "AT+CIPSEND=";
     cipSend += connectionId;
     cipSend += ",";
     cipSend +=webpage.length();
     cipSend +="\r\n";

     sendData(cipSend,1000,DEBUG);
     sendData(webpage,1000,DEBUG);

     webpage="<button>LED2</button>";

     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);
    }
  }
}


void sendData(String command, const int timeout, boolean debug)
{
    esp8266.print(command); // send the read character to the esp8266
    long int time = millis();

    while( (time+timeout) > millis())
    {
      while(esp8266.available())
      {
        // The esp has data so display its output to the serial window
        Serial.write(esp8266.read());
      } 
    }
}



And this is the output of the serial monitor.

Code: Select allAT+RST

OK
bBֆ@j⸮⸮⸮ѐ8B⸮⸮⸮⸮J⸮⸮I⸮⸮⸮⸮cD⸮⸮J⸮R

Vendor:www.ai-thinker.com

SDK Version:0.9.5(b1)
Compileset mode 1
d @⸮⸮⸮⸮I)SC\YXV5
AT+CWMODE=1

OK
AV])⸮թ*⸮T⸮PH⸮82912701284"

OK
Testing CIFSR
AT+CIFSR
+CIFSR:STAIP,"192.168.1.69"
+CIFSR:STAMAC,"xxxxxxxx" < I blanked this out

OK
setting for multiple connection
AT+CIPMUX=1print MAC address
AT+CIPSTAMAC?

OK
set port 80 for server
AV%AM⸮eUI⸮1
,80
OK




Joseph

Re: Arduino Uno Esp8266

PostPosted: Mon Aug 26, 2019 5:09 pm
by josephchrzempiec
Hello i have tried everything and can not seem to get a web page to work can someone please help me.

Re: Arduino Uno Esp8266

PostPosted: Tue Aug 27, 2019 3:13 am
by schufti
Hi,
honestly - I don't think anybody sane did try to implement a "webserver" with esp8266 via "AT-commends".

Since you allready have set up arduino IDE (for Uno), you should take the next step and integrate esp8266 support and use one of the plethora of examples, projects and guides dealing with http server.