Skip to content

Instantly share code, notes, and snippets.

Last active September 5, 2022 03:47
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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 );
Copy link

lbrutti commented Jun 12, 2018

hello, can this code be deployed with Arduino IDE?

Copy link

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