Send data from one module (AP) to another (station connected
Posted: Thu Aug 13, 2015 3:46 am
I want to have one module as an access point and the second module as a station connected to the access point. The station should read the webpage on the access point's server.
Say my access point code is this:
How should the code look like for the second module set up as the station for it to read that webpage and store "Hello world!" in a string variable for future use? I saw some examples with functions like wifi.send(), but I still have no idea how to implement it. It can also be set up like this: the server on the access point sends data to the server on the station when an event occurs (no matter what, a button is pressed, a url on the server is visited) and the station stores it in a variable. Thanks!
Say my access point code is this:
Code: Select all
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <EEPROM.h>
const char *ssid = "ESPapnew";
const char *password = "thereisnospoon";
ESP8266WebServer server(80);
void handleRoot() {
server.send(200, "text/html", "Hello, world!");
}
void setup() {
delay(1000);
WiFi.softAP(ssid, password);
server.on("/", handleRoot);
server.begin();
}
void loop() {
server.handleClient();
}
How should the code look like for the second module set up as the station for it to read that webpage and store "Hello world!" in a string variable for future use? I saw some examples with functions like wifi.send(), but I still have no idea how to implement it. It can also be set up like this: the server on the access point sends data to the server on the station when an event occurs (no matter what, a button is pressed, a url on the server is visited) and the station stores it in a variable. Thanks!