ESP is a Wi-Fi device. Wi-Fi needs a network in order to establish link-level connectivity.
But you can easily create an ad-hoc network between two nodes: start one in AP mode and another in client mode, connecting to that AP.
For example:
// "Server"
#include <ESP8266WiFi.h>
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_AP);
WiFi.softAPConfig(IPAddress(192,168,4,1), IPAddress(192,168,4,1), IPAddress(255,255,255,0));
WiFi.softAP("my_ssid", "password");
}
// "Client"
#include <ESP8266WiFi.h>
void setup() {
Serial.begin(115200);
WiFi.begin("my_ssid", "password");
}
Then use your favorite protocol (UDP, MQTT, ...) to broadcast messages (UDP example). You can broadcast with UDP by sending to IP 255.255.255.255.
Note that there is a dedicated site for Arduino-related questions: https://arduino.stackexchange.com/