Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arduino-web-server-mega-2560-r3-built-in-esp8266/ #8

Open
utterances-bot opened this issue Oct 1, 2021 · 15 comments
Open

arduino-web-server-mega-2560-r3-built-in-esp8266/ #8

utterances-bot opened this issue Oct 1, 2021 · 15 comments

Comments

@utterances-bot
Copy link

Arduino - Web Server (Mega 2560 R3 built-in ESP8266)

This tutorial goes over how to use the Mega 2560 R3 built-in ESP8266 and create a web server by flashing the onboard ESP8266 with AT firmware which only requires programming only the ATmega2560. 📶

https://www.gabrielcsapo.com/arduino-web-server-mega-2560-r3-built-in-esp8266/

Copy link

jewing18 commented Oct 1, 2021

Well done sir. Worked flawlessly for me. Thank you for not spreading false information!

@gabrielcsapo
Copy link
Owner

@jewing18 let me know if you want to see any other content! Thanks for the kind words!

Copy link

frankly i most say, this post is the only working guide for this board keep it up and THANKS!!

Copy link

Just one question, and it's the hard one, I just figured out that it is possible to program mega2560 through wifi via a framework called esp_link and this youtube video shows how to do it. My problem is that the video worked with an independent esp-01 module. It is easy to figure out the connections between mega2560 and esp, but here in this Mega 2560 R3 built-in ESP8266 board, I can't figure out the relationship needed to program mega2560 via esp8266 through wifi. I appreciate it if you, please help me

Copy link

Thank you for the excellent instructions! I did fine till the test code from WiFiEspAT library - and I get a timeout error... AT+GMR returns good values. Then I get this error: Exit Status 1: 'mySSID' was not declared in this scope. I assume Exit Status 1 means successful UL of sketch, so I forged ahead to discover the TX/RX switch was already in the TX-3/RX-3 position instead of TX-0/RX-0 position for all of the previous code. Is that significant?

Copy link

SSID and PW must be quoted.

Copy link

Do you have any suggestion how to fix the timeout issue during uploading sketch ? This randomly occurs. Sometimes it works every time and sometimes it always timesout. The boerd is still running my old sketch and I still get data in the serial monitor
But at the moment I can not load a new sketch

@googygreg
Copy link

googygreg commented Jan 23, 2022

I had similar problem. Must use short, shielded USB cable that came with the Arduino. I never could get Arduino Mega with built in WiFi to ever: make a connection to my WiFi (client) nor offer a connection to (Arduino) AP. I went back to Arduino Mega and a cable. WiFi wasn't worth the hassle.

Copy link

Astra04 commented Feb 21, 2022

can you help me please mine is stuck at waiting for wifi connection

Copy link

resmithn commented Apr 6, 2022

Flash went okay received: Hard resetting via RTS pin. Changed the switches as described [5 & 6 ON] When trying the AT command. receive the following:
14:37:54.667 -> ready
14:38:07.420 -> AT
14:38:07.420 ->
14:38:07.420 -> ERROR
14:38:37.388 -> AT GMR
14:38:37.388 ->
14:38:37.388 -> ERROR
Appreciate any help you can provide.
Thank You.

Copy link

igs3000 commented Dec 28, 2022

Dear Gabriel J. Csapo,
Thank you for your Excellent Instructions.
Everything worked good as it is.
I never saw such a clean instructions for this board anywhere else.

After purchasing this "Arduino Mega 2560 with built-in WiFi", I could not understand the way to use it. So, meaninglessly I kept that for several months.
Your instructions simply gave life for that board.

Thank you.

Copy link

igs3000 commented Dec 28, 2022

Those who are not having gy-21p sensor, can comment some lines for testing the WiFi functionality and the web server code :

#define NAME_OF_SSID "Tenda_D360D0"
#define PASSWORD_OF_SSID "xxxxx"

//#include <Adafruit_BMP280.h>
#include <WiFiEspAT.h>

//Adafruit_BMP280 bme;

WiFiServer server(80);

void setup()
{

Serial.begin(115200);
while (!Serial)
;
Serial.println("Setting up...");
// if (!bme.begin(0x77)) // depending on the chip you have the i2c address is either 0x77 or 0x77
// {
// Serial.println("Could not find a valid BMP280 sensor, check wiring!");
// while (1)
// ;
// }

Serial3.begin(115200);

WiFi.init(Serial3);
Serial.println("Setting up wifi...");
if (WiFi.status() == WL_NO_MODULE)
{
Serial.println("Communication with WiFi module failed!");
// don't continue
while (true)
;
}

WiFi.begin(NAME_OF_SSID, PASSWORD_OF_SSID);
Serial.println("Waiting for connection to WiFi");
while (WiFi.status() != WL_CONNECTED)
{
delay(1000);
Serial.print('.');
}
Serial.println();

server.begin();

IPAddress ip = WiFi.localIP();
Serial.println();
Serial.println("Connected to WiFi network.");
Serial.print("To access the server, enter "http://");
Serial.print(ip);
Serial.println("/" in web browser.");
}

void loop()
{
float temp = 10; //(bme.readTemperature() * 1.8) + 32;
float pressure = 10;// = bme.readPressure();
float altitude = 10 ; // bme.readAltitude(1010);

WiFiClient client = server.available();

if (client)
{
IPAddress ip = client.remoteIP();
Serial.print("new client ");
Serial.println(ip);

while (client.connected())
{
  if (client.available())
  {
    String line = client.readStringUntil('\n');
    line.trim();
    Serial.println(line);

    // if you've gotten to the end of the HTTP header (the line is blank),
    // the http request has ended, so you can send a reply
    if (line.length() == 0)
    {
      // send a standard http response header
      client.println("HTTP/1.1 200 OK");
      client.println("Content-Type: text/html");
      client.println("Connection: close"); // the connection will be closed after completion of the response
      client.println("Refresh: 5");        // refresh the page automatically every 5 sec
      client.println();
      client.println("<!DOCTYPE HTML>");
      client.println("<html>");

      client.print("<h4>Tempature: ");
      client.print(temp);
      client.print("F");
      client.print("</h4>");

      client.print("<h4>Pressure: ");
      client.print(pressure);
      client.print("</h4>");

      client.print("<h4>Altitude: ");
      client.print(altitude);
      client.print("</h4>");

      client.println("</html>");
      client.flush();
      break;
    }
  }
}

// close the connection:
client.stop();
Serial.println("client disconnected");

}
}

@gabrielcsapo
Copy link
Owner

Dear Gabriel J. Csapo,
Thank you for your Excellent Instructions.
Everything worked good as it is.
I never saw such a clean instructions for this board anywhere else.

After purchasing this "Arduino Mega 2560 with built-in WiFi", I could not understand the way to use it. So, meaninglessly I kept that for several months.
Your instructions simply gave life for that board.

Thank you.

Glad it was helpful! It was a similar problem for me so I am happy to help others make use of the board!

Copy link

arsant68 commented Jan 9, 2023

HI
Thank you Gabriel J. Csapo to share this tutorial.
Following steep by steep your tuto, I was able to update the esp firmware ( running now 2.2.xx AT )and using as websever to monitor my solar panels.
Just a question, did you managed to run a webserver and at same time posting data to thingspeak ?
I´m struggling to run server and client at same time, as I used to do with ethernet shield.
I can post data to thingspeak but only when not running webserver at same time.
I´m using WiFiEspAT lib and AT firmware 2.2xx.
Again, thanx to spend time with your tuto... well documented and explained.

@XohaibQ
Copy link

XohaibQ commented May 22, 2024

Hi
Link is not working. Can you provide any alternative link, Please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests