Using Arduino Mega 2560 to collect data using ESP8266's over local wifi network
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)
Update
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 = "xxxxxxxx";
void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("my_esp8266_STA");
}
void loop()
{
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print("."); //prints "." while waiting for wifi connection
}
Serial.println("");
Serial.print("WiFi connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
Serial.print("WiFi MAC Address: ");
Serial.println(WiFi.macAddress());
delay(2000);
}
which produced this:
WiFi connected to VM629304-2G
IP address: 192.168.0.23
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?