Arduino Mega at2560 with integrated esp8266 Wifi how to connect

Mega Wifi R3 Atmega2560 With Esp8266 USB-TTL

Hi! how can i connect this mega wifi to my wifi? i aleady follow all the tutorial but no reponse to esp, and i see a tutorial like you need to flash the esp ( link: https://www.youtube.com/watch?v=E250CVUWNB0)

and i flash the esp ([12348 off] [567 on] [rxd0 & txd0] AiThinker_ESP8266_DIO_8M_8M_20160615_V1.5.4) but still same problem

and the ESP8266WIFI.h i have always problem with that thing
error

#include <queue.h>
next when i add and the error
#include <wl_definitions.h>
after that error again when i add
#include <Iwip/dns.h>
error again
#include

i frustrated so much

now i tried the Wifiesp library (link: GitHub - bportaluri/WiFiEsp: Arduino WiFi library for ESP8266 modules )
same no response

how can i connect this mega wifi to router?

https://robotdyn.com/mega-wifi-r3-atmega2560-esp8266-flash-32mb-usb-ttl-ch340g-micro-usb.html

https://github.com/JAndrassy/WiFiEspAT?tab=readme-ov-file#getting-started

https://github.com/JAndrassy/WiFiEspAT?tab=readme-ov-file#at-17-1

1 Like


i all ready flash in 32m but cant communicate

initially try a simple WiFi example to make sure everything is working

  1. set Tools>Board to Generic ESP8266 Module
  2. load File>Examples>ESP8266WiFi>WiFiAccessPoint
  3. set dip switches 1-4 and 8 OFF and 5-7 ON.
  4. compile and upload program
  5. set the dip switches 1-4 and 7-8 OFF and 5-6 ON
  6. press reset button
  7. the program should run and the serial monitor displays
Configuring access point...AP IP address: 192.168.4.1
HTTP server started

on your PC connect the WiFi to "ESPap" and password "thereisnospoon"
start a web browser and enter URL "192.168.4.1" it should display

using this Mega/ESP8266 is not simple - having to switch the DIL switches ON/OFF between loading and running code is awkward - also not sure how long the DIL switch will last
also having to program two microcontrollers with the overhead of interprocessor communication increases the task complexity by an order of magnitude

unless you have a specific reason to use a Mega I would recommend you get a ESP8266 or ESP32 dev module

1 Like

did you switch to Serial3 and use Serial3 in the sketch?

note: horace's advice will delete the AT firmware if there is one

1 Like

its working now thanks for the advice and the link you give (MEGA+WiFi R3 ATmega2560+ESP8266, flash 32MB, USB-TTL CH340G, Micro-USB - Robotdyn) it helps a lot

first i flash the ESP (DIP Switch 12348 off and 567 on then set RXD0&TXD0), Using ESPFlashDownloadTools_v3.4.4 then download the firmware AiThinker_ESP8266_DIO_32M_32M_20160615_V1.5.4

after that (dip switch 1234 on and 5678 off the RXD3&TXD3) for coding to connect wifi
i use a library ( GitHub - bportaluri/WiFiEsp: Arduino WiFi library for ESP8266 modules ) then theres a example of Sketch at WiFiesp "ScanNetwork"

Here's the code for "ScanNetwork"

#include "WiFiEsp.h"

// Emulate Serial1 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial3(6, 7); // RX, TX
#endif

void setup() {
  // initialize serial for debugging
  Serial.begin(115200);
  // initialize serial for ESP module
  Serial3.begin(115200);
  // initialize ESP module
  WiFi.init(&Serial3);

  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue
    while (true);
  }

  // Print WiFi MAC address
  printMacAddress();
}

void loop()
{
  // scan for existing networks
  Serial.println();
  Serial.println("Scanning available networks...");
  listNetworks();
  delay(10000);
}


void printMacAddress()
{
  // get your MAC address
  byte mac[6];
  WiFi.macAddress(mac);
  
  // print MAC address
  char buf[20];
  sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X", mac[5], mac[4], mac[3], mac[2], mac[1], mac[0]);
  Serial.print("MAC address: ");
  Serial.println(buf);
}

void listNetworks()
{
  // scan for nearby networks
  int numSsid = WiFi.scanNetworks();
  if (numSsid == -1) {
    Serial.println("Couldn't get a wifi connection");
    while (true);
  }

  // print the list of networks seen
  Serial.print("Number of available networks:");
  Serial.println(numSsid);

  // print the network number and name for each network found
  for (int thisNet = 0; thisNet < numSsid; thisNet++) {
    Serial.print(thisNet);
    Serial.print(") ");
    Serial.print(WiFi.SSID(thisNet));
    Serial.print("\tSignal: ");
    Serial.print(WiFi.RSSI(thisNet));
    Serial.print(" dBm");
    Serial.print("\tEncryption: ");
    printEncryptionType(WiFi.encryptionType(thisNet));
  }
}

void printEncryptionType(int thisType) {
  // read the encryption type and print out the name
  switch (thisType) {
    case ENC_TYPE_WEP:
      Serial.print("WEP");
      break;
    case ENC_TYPE_WPA_PSK:
      Serial.print("WPA_PSK");
      break;
    case ENC_TYPE_WPA2_PSK:
      Serial.print("WPA2_PSK");
      break;
    case ENC_TYPE_WPA_WPA2_PSK:
      Serial.print("WPA_WPA2_PSK");
      break;
    case ENC_TYPE_NONE:
      Serial.print("None");
      break;
  }
  Serial.println();
}

make use at the Serial monitor the baud set at 15200
and then it will scan a network around

If you connect to wifi with a pass, asap use wpa cause the wp2 or 3 will failed unless you use a ESP8266WIFI.h lib it supports wpa2 for security purposes