Instantly share code, notes, and snippets.

What would you like to do?
Simple test for ESP32 WiFi range
#include <Arduino.h>
#include <WiFi.h>
#include <WiFiUdp.h>
#include <esp_wifi.h>
#include "peripherals.h"
#include "credentials.h"
Led redLed( GPIO_NUM_19 );
Led greenLed( GPIO_NUM_21 );
WiFiUDP udp;
const char *toStr( wl_status_t status ) {
switch( status ) {
case WL_NO_SHIELD: return "No shield";
case WL_IDLE_STATUS: return "Idle status";
case WL_NO_SSID_AVAIL: return "No SSID avail";
case WL_SCAN_COMPLETED: return "Scan compleded";
case WL_CONNECTED: return "Connected";
case WL_CONNECT_FAILED: return "Failed";
case WL_CONNECTION_LOST: return "Connection lost";
case WL_DISCONNECTED: return "Disconnected";
return "Unknown";
void setupAp() {
delay( 500 ); // If not used, somethimes following command fails
ESP_ERROR_CHECK( esp_wifi_set_protocol( WIFI_IF_AP, WIFI_PROTOCOL_LR ) );
WiFi.mode( WIFI_AP );
Serial.println( WiFi.softAP( ssid, password ) );
Serial.println( WiFi.softAPIP() );
delay( 1000 );
void setup() {
Serial.begin( 115200 );
Serial.println( "Master" );
udp.begin( 8888 );
void loop() {
udp.beginPacket( { 192, 168, 4, 255 }, 8888 );
udp.write( 'b' );
if ( !udp.endPacket() )
ESP.restart(); // When the connection is bad, the TCP stack refuses to work
delay( 100 );

This comment has been minimized.

lbrutti commented Jun 12, 2018

hello, can this code be deployed with Arduino IDE?


This comment has been minimized.

NickChungVietNam commented Oct 9, 2018

Hi Sir.
After try this code, my ESP32 hided SSID of AP forever. I try again with my second esp32 , the result is both 2 esp32 is hide SSID forever, how can i fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment