diff --git a/libraries/WiFi/examples/WiFiScan/WiFiScan.ino b/libraries/WiFi/examples/WiFiScan/WiFiScan.ino
index 15ce367c897..98733adb0bb 100644
--- a/libraries/WiFi/examples/WiFiScan/WiFiScan.ino
+++ b/libraries/WiFi/examples/WiFiScan/WiFiScan.ino
@@ -1,5 +1,5 @@
 /*
- *  This sketch demonstrates how to scan WiFi networks.
+ *  This sketch demonstrates how to scan WiFi networks. For chips that support 5GHz band, separate scans are done for all bands.
  *  The API is based on the Arduino WiFi Shield library, but has significant changes as newer WiFi functions are supported.
  *  E.g. the return value of `encryptionType()` different because more modern encryption is supported.
  */
@@ -7,18 +7,13 @@
 
 void setup() {
   Serial.begin(115200);
-
-  // Set WiFi to station mode and disconnect from an AP if it was previously connected.
-  WiFi.mode(WIFI_STA);
-  WiFi.disconnect();
-  delay(100);
-
+  // Enable Station Interface
+  WiFi.STA.begin();
   Serial.println("Setup done");
 }
 
-void loop() {
+void ScanWiFi() {
   Serial.println("Scan start");
-
   // WiFi.scanNetworks will return the number of networks found.
   int n = WiFi.scanNetworks();
   Serial.println("Scan done");
@@ -54,11 +49,33 @@ void loop() {
       delay(10);
     }
   }
-  Serial.println("");
 
   // Delete the scan result to free memory for code below.
   WiFi.scanDelete();
-
+  Serial.println("-------------------------------------");
+}
+void loop() {
+  Serial.println("-------------------------------------");
+  Serial.println("Default wifi band mode scan:");
+  Serial.println("-------------------------------------");
+  WiFi.setBandMode(WIFI_BAND_MODE_AUTO);
+  ScanWiFi();
+#if CONFIG_SOC_WIFI_SUPPORT_5G
+  // Wait a bit before scanning again.
+  delay(1000);
+  Serial.println("-------------------------------------");
+  Serial.println("2.4 Ghz wifi band mode scan:");
+  Serial.println("-------------------------------------");
+  WiFi.setBandMode(WIFI_BAND_MODE_2G_ONLY);
+  ScanWiFi();
+  // Wait a bit before scanning again.
+  delay(1000);
+  Serial.println("-------------------------------------");
+  Serial.println("5 Ghz wifi band mode scan:");
+  Serial.println("-------------------------------------");
+  WiFi.setBandMode(WIFI_BAND_MODE_5G_ONLY);
+  ScanWiFi();
+#endif
   // Wait a bit before scanning again.
-  delay(5000);
+  delay(10000);
 }
diff --git a/libraries/WiFi/src/WiFiGeneric.cpp b/libraries/WiFi/src/WiFiGeneric.cpp
index 40e3b12c687..644eedf57b3 100644
--- a/libraries/WiFi/src/WiFiGeneric.cpp
+++ b/libraries/WiFi/src/WiFiGeneric.cpp
@@ -378,6 +378,10 @@ static bool espWiFiStart() {
     log_e("esp_wifi_start %d", err);
     return _esp_wifi_started;
   }
+#if SOC_WIFI_SUPPORT_5G
+  log_v("Setting Band Mode to AUTO");
+  esp_wifi_set_band_mode(WIFI_BAND_MODE_AUTO);
+#endif
   return _esp_wifi_started;
 }
 
@@ -701,6 +705,90 @@ wifi_ps_type_t WiFiGenericClass::getSleep() {
   return _sleepEnabled;
 }
 
+/**
+ * control wifi band mode
+ * @param band_mode enum possible band modes
+ * @return ok
+ */
+bool WiFiGenericClass::setBandMode(wifi_band_mode_t band_mode) {
+#if SOC_WIFI_SUPPORT_5G
+  if (!WiFi.STA.started() && !WiFi.AP.started()) {
+    log_e("You need to start WiFi first");
+    return false;
+  }
+  wifi_band_mode_t bm = WIFI_BAND_MODE_AUTO;
+  esp_err_t err = esp_wifi_get_band_mode(&bm);
+  if (err != ESP_OK) {
+    log_e("Failed to get Current Band Mode: 0x%x: %s", err, esp_err_to_name(err));
+    return false;
+  } else if (bm == band_mode) {
+    log_d("No change in Band Mode");
+    return true;
+  } else {
+    log_d("Switching Band Mode from %d to %d", bm, band_mode);
+  }
+#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_ERROR
+  if (WiFi.STA.connected() || WiFi.AP.connected()) {
+    log_e("Your network will get disconnected!");
+  }
+#endif
+  err = esp_wifi_set_band_mode(band_mode);
+  if (err != ESP_OK) {
+    log_e("Failed to set Band Mode: 0x%x: %s", err, esp_err_to_name(err));
+    return false;
+  }
+  delay(100);
+  return true;
+#else
+  if (band_mode == WIFI_BAND_MODE_5G_ONLY) {
+    log_e("This chip supports only 2.4GHz WiFi");
+  }
+  return band_mode != WIFI_BAND_MODE_5G_ONLY;
+#endif
+}
+
+/**
+ * get the current enabled wifi band mode
+ * @return enum band mode
+ */
+wifi_band_mode_t WiFiGenericClass::getBandMode() {
+#if SOC_WIFI_SUPPORT_5G
+  wifi_band_mode_t band_mode = WIFI_BAND_MODE_AUTO;
+  if (!WiFi.STA.started() && !WiFi.AP.started()) {
+    log_e("You need to start WiFi first");
+    return band_mode;
+  }
+  esp_err_t err = esp_wifi_get_band_mode(&band_mode);
+  if (err != ESP_OK) {
+    log_e("Failed to get Band Mode: 0x%x: %s", err, esp_err_to_name(err));
+  }
+  return band_mode;
+#else
+  return WIFI_BAND_MODE_2G_ONLY;
+#endif
+}
+
+/**
+ * get the current active wifi band
+ * @return enum band
+ */
+wifi_band_t WiFiGenericClass::getBand() {
+#if SOC_WIFI_SUPPORT_5G
+  wifi_band_t band = WIFI_BAND_2G;
+  if (!WiFi.STA.started() && !WiFi.AP.started()) {
+    log_e("You need to start WiFi first");
+    return band;
+  }
+  esp_err_t err = esp_wifi_get_band(&band);
+  if (err != ESP_OK) {
+    log_e("Failed to get Band: 0x%x: %s", err, esp_err_to_name(err));
+  }
+  return band;
+#else
+  return WIFI_BAND_2G;
+#endif
+}
+
 /**
  * control wifi tx power
  * @param power enum maximum wifi tx power
diff --git a/libraries/WiFi/src/WiFiGeneric.h b/libraries/WiFi/src/WiFiGeneric.h
index ed216229ed4..8497b4b4f3d 100644
--- a/libraries/WiFi/src/WiFiGeneric.h
+++ b/libraries/WiFi/src/WiFiGeneric.h
@@ -111,6 +111,10 @@ class WiFiGenericClass {
   bool setTxPower(wifi_power_t power);
   wifi_power_t getTxPower();
 
+  bool setBandMode(wifi_band_mode_t band_mode);
+  wifi_band_mode_t getBandMode();
+  wifi_band_t getBand();
+
   bool initiateFTM(uint8_t frm_count = 16, uint16_t burst_period = 2, uint8_t channel = 1, const uint8_t *mac = NULL);
 
   static bool setDualAntennaConfig(uint8_t gpio_ant1, uint8_t gpio_ant2, wifi_rx_ant_t rx_mode, wifi_tx_ant_t tx_mode);