Using Arduino Mega 2560 to collect data using ESP8266's over local wifi network

Hi everyone

I’ve struggled to find a solution to wirelessly connect 2 ESP8266’s (Adafruit Huzzah) using, I believe, AP mode on one ESP8266 & station mode on the other using Arduino IDE.

My project, ultimately, is to use 3 ESP8266’s in station mode to collect room temperature data from 3 ‘zones’ & transmit this to the ESP8266 in AP mode, which is wired to the Mega, for processing.

At present, my Mega receives room temp data from one zone using a DS18B20 sensor over a wired connection & I’d like to increase the number of ‘zones’ using wireless as detailed above.

I do not need to send this data to a web server.
I do not need to control from the web or smart phone; no IoT is needed!

I’m hoping to achieve this using Arduino IDE so I can incorporate it into my existing setup but I do not know how to start.

Any guidance would be welcomed (I’m no programmer but am familiar with basic IDE)


I created this sketch:

WiFi(ESP8266WiFi library)

This is mostly similar to WiFi shield library. Differences include:

WiFi.mode(mode): set mode to WIFI_AP, WIFI_STA, or WIFI_AP_STA.
call WiFi.softAP(ssid) to set up an open network without password
call WiFi.softAP(ssid, passphrase) to set up a WPA2-PSK network
WiFi.macAddress() is for STA mode, WiFi.softAPmacAddress() is for AP mode.
WiFi.localIP() is for STA, WiFi.softAPIP() is for AP.


#include <ESP8266WiFi.h>
const char* ssid = “VM629304-2G”;
const char* password = “xxxxxxxxxx”;

void setup()
WiFi.begin(ssid, password);

void loop()
while (WiFi.status() != WL_CONNECTED)
Serial.print("."); //prints “.” while waiting for wifi connection

Serial.print("WiFi connected to ");
Serial.print("IP address: ");
Serial.print("WiFi MAC Address: ");


which outputs this:

WiFi connected to VM629304-2G
IP address:
WiFi MAC Address: 5C:CF:7F:10:8E:D7

so I’ve successfully connected to my wireless LAN but I still have no idea how to connect this ESP8266 in STA mode to another ESP8266 in AP mode.

Any suggestions?

. . .
I'm hoping to achieve this using Arduino IDE so I can incorporate it into my existing setup but I do not know how to start.
. . .

See here for an excellent tutorial:

thanks for the reply but the link you suggested seems to deal with sending data to a web site which is not what I’m looking for.

I just want to send data over my wireless LAN