ESP Status Utility

I figured I’d share this little program I created to get info from a ESP8266/ESP8285. It gives you basic info (SDK version, operating mode, CPU freq, physical wifi mode; DHCP hostname, station & access point MAC addresses). It also allows you to set your operating mode, max TX power, and hostname which are persistent even after uploading sketches. The only library you need installed is a internal library that gets installed when you add the ESP platform to your IDE. So as long as your setup for ESPs this should run no prob.

extern "C" {
#include "user_interface.h"
}

#define STATION_IF 0x00
#define SOFTAP_IF 0x01

uint8 hwaddr[6];
uint8 hwaddr2[6];


void setup() 
{
  // uncomment below to set options
  
  wifi_set_opmode(0x01); //set station mode
  //  wifi_set_opmode (0x03);  // set AP + station
  system_phy_set_max_tpw(82);  // max pwr
  //  wifi_station_set_hostname("ESP"); // Set hostname here

  Serial.begin(9600);

  while(!Serial)
  {
    delay(1);
  }
}

void loop() 
{
  Serial.print("SDK: ");
  Serial.println(system_get_sdk_version());

  Serial.print("operating mode: ");
  byte mode = wifi_get_opmode_default();
  if (mode == 1)
  {
    Serial.println("Station Mode");
  }

  if (mode == 2)
  {
    Serial.println("SoftAP mode");
  }

  if (mode == 3)
  {
    Serial.println("Station + SoftAP");
  }


  Serial.print("CPU Freq: ");
  Serial.println(system_get_cpu_freq());

  byte phyMode = wifi_get_phy_mode();
  Serial.print("phy mode: ");
  if (phyMode == 1)
   {
   Serial.println("11B");
   }

  if (phyMode == 2)
    {
    Serial.println("11G");
    }

  if (phyMode == 3)
    {
    Serial.println("11N");
    }

  Serial.print("DHCP hostname: ");
  Serial.println(wifi_station_get_hostname());

  Serial.print("station mac: ");
  wifi_get_macaddr(STATION_IF, hwaddr);
  Serial.print(hwaddr[0], HEX);
  Serial.print(":");
  Serial.print(hwaddr[1], HEX);
  Serial.print(":");
  Serial.print(hwaddr[2], HEX);
  Serial.print(":");
  Serial.print(hwaddr[3], HEX);
  Serial.print(":");
  Serial.print(hwaddr[4], HEX);
  Serial.print(":");
  Serial.print(hwaddr[5], HEX);
  Serial.println("");

  Serial.print("AP mac: ");
  wifi_get_macaddr(SOFTAP_IF, hwaddr2);
  Serial.print(hwaddr2[0], HEX);
  Serial.print(":");
  Serial.print(hwaddr2[1], HEX);
  Serial.print(":");
  Serial.print(hwaddr2[2], HEX);
  Serial.print(":");
  Serial.print(hwaddr2[3], HEX);
  Serial.print(":");
  Serial.print(hwaddr2[4], HEX);
  Serial.print(":");
  Serial.print(hwaddr2[5], HEX);
  Serial.println("");
  Serial.println("");
  Serial.println("");
  Serial.println("");

  delay(10000);
}
6 Likes

Awesome, I’ll have to check that out next time I have one out for testing. Thanks @vapor83!

I learned most of these values are persistent even when using the Arduino IDE to program the ESP. I had a couple ESP access points in range at my place. I thought someone else was doing IoT stuff but turned out a couple of my ESPs were operating in dual mode. :smirk:

1 Like

Thank you for posting this!

~Benny

I also changed category to The Library :slight_smile:

Thanks Vape!
:+1:

2 Likes

Thats what i´am looking for ! Thanks a lot for sharing !

Happy New Year 2018

great add !