BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

How to get MAC and IP address of devices connected to ESP8266 through blynk terminal

• ESP8266MOD
• Android & version 6.0.1 Marshmello
• Blynk Library version v0.6.1

#define BLYNK_PRINT Serial

#include <SPI.h>
#include <ESP8266WiFi.h>
//#include <Ethernet.h>
#include <BlynkSimpleEsp8266.h>
#//include <BlynkSimpleEthernet.h>
extern "C" {
#include <user_interface.h>  
}


// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "c-neFc_qOFWuK_k1Ereu7BrlO3ca50pZ";

// Your WiFi credentials.
// Set password to "" for open networks.
const char *ssid = "ESP8266";
const char *pass = "";

WidgetTerminal terminal(V1);

void setup()
{
  // Debug console
  delay(1000);
  Serial.begin(115200);
  Blynk.begin(auth);
  terminal.clear();
   
  terminal.println();
  terminal.print("Configuring access point...");


  WiFi.softAP(ssid,pass);
  IPAddress myIP= WiFi.softAPIP();
  terminal.print("AP IP address: ");
  terminal.println(myIP);

  
  
}

void loop()
{
  delay(5000);
  client_status();
  delay(4000);
  Blynk.run();
}

void client_status(){

  unsigned char number_client;
  struct station_info *stat_info;

  struct ip4_addr *IPaddress;
  IPAddress address;
  int i=1;

  number_client= wifi_softap_get_station_num();
  stat_info = wifi_softap_get_station_info();
  
  terminal.print(" Total Connected Clients are = ");
  terminal.println(number_client);
  
    while (stat_info != NULL) {
    
      IPaddress = &stat_info->ip;
      address = IPaddress->addr;
      
      terminal.print("client= ");
      
      terminal.print(i);
      terminal.print(" IP adress is = ");
      terminal.print((address));
      terminal.print(" with MAC adress is = ");
      
      terminal.print(stat_info->bssid[0],HEX);terminal.print(" ");
      terminal.print(stat_info->bssid[1],HEX);terminal.print(" ");
      terminal.print(stat_info->bssid[2],HEX);terminal.print(" ");
      terminal.print(stat_info->bssid[3],HEX);terminal.print(" ");
      terminal.print(stat_info->bssid[4],HEX);terminal.print(" ");
      terminal.print(stat_info->bssid[5],HEX);terminal.print(" ");
      
      stat_info = STAILQ_NEXT(stat_info, next);
      i++;
      terminal.println(); 
}
delay(5000);
}

I’m a new user of blynk. now i just want to see the output of the following code on the terminal of blynk.

Please edit your code add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Pete.

1 Like

Sir,
I Got it. But now need the solution.

What are you seeing in your terminal monitor ? (copy and paste the results, and use triple backticks again).
Does your device show as being online in the app?

You should also read this:

Pete.

There is nothing showing in the terminal monitor and moreover my device is not being showing online. I select NodeMCU and connection type is WIFI from app.

get rid of the delays in you loop

Sorry, I meant to say “what are you seeing in your serial monitor”.

And you’ve not answered the question about whether the device is showing as being online in the app…

Pete.

It’s showing that , it wasn’t online yet.

And what do you see in the serial monitor on your computer?

Pete.

1 Like

Nothing is appeared on the serial monitor.

Set the baud rate in the serial monitor(115200). And reset the module (make sure you have connected the module to the pc and select the correct com port). It should throw some info in the serial monitor saying the module is connected to the wifi router you have specified in the code.

I already set baud rate in the serial monitor (115200) and also select the correct com port and after upload the code, i checked the serial monitor which is connected to com port 5 but didn’t appeared any kind of word like --“connected to the wifi router”. Is there any kind of trouble shooting option for proper solution??

There are unnecessary delays in your code. Remove the delay just before the Serial.begin(115200) and see if any output is shown on the serial monitor.

What does appear in your serial monitor when you press the reset button on the NodeMCU?
If nothing appears at all then you’re doing something wrong.
If something appears then post it here.

Pete.

1 Like

This code was for getting mac address and ip address of connected devices along with esp8266.

#include <ESP8266WiFi.h>
 
extern "C" {
  #include<user_interface.h>
}
 
/* configuration  wifi */
const char *ssid = "ESP8266";
const char *pass = "12345678";
 
void setup() {
  delay(1000);
  Serial.begin(115200);
  Serial.println();
  Serial.print("Configuring access point...");
  
  WiFi.softAP(ssid,pass);
  
  IPAddress myIP = WiFi.softAPIP();
  
  Serial.print("AP IP address: ");
  Serial.println(myIP);
}
 
void loop() {
  delay(5000);
  client_status();
  delay(4000);
}
 
void client_status() {
 
  unsigned char number_client;
  struct station_info *stat_info;
  
  struct ip4_addr *IPaddress;
  IPAddress address;
  int i=1;
  
  number_client= wifi_softap_get_station_num();
  stat_info = wifi_softap_get_station_info();
  
  Serial.print(" Total Connected Clients are = ");
  Serial.println(number_client);
  
    while (stat_info != NULL) {
    
      IPaddress = &stat_info->ip;
      address = IPaddress->addr;
      
      Serial.print("client= ");
      
      Serial.print(i);
      Serial.print(" IP adress is = ");
      Serial.print((address));
      Serial.print(" with MAC adress is = ");
      
      Serial.print(stat_info->bssid[0],HEX);Serial.print(" ");
      Serial.print(stat_info->bssid[1],HEX);Serial.print(" ");
      Serial.print(stat_info->bssid[2],HEX);Serial.print(" ");
      Serial.print(stat_info->bssid[3],HEX);Serial.print(" ");
      Serial.print(stat_info->bssid[4],HEX);Serial.print(" ");
      Serial.print(stat_info->bssid[5],HEX);Serial.print(" ");
      
      stat_info = STAILQ_NEXT(stat_info, next);
      i++;
      Serial.println();
    }
    
  delay(500);
}

And the output is

Now i want to see this output from blynk terminal.

I don’t think an ESP can operate in AP mode and allow client connections at the same time as connecting to Blynk.

Can you explain more about what this project actually does?

Pete.

This project was to create an atmosphere, when smart devices will near to this ESP8266, it will display the connected devices IP address and MAC address through Serial monitor which i have already shown on the upper comments. Now i just want to use blynk app to display the connected devices on terminal of blynk instead of arduino builtin serial monitor. That’s it.

Rafi.

So you’re wanting multiple ‘smart devices’ to connect to your ESP8266 and for that ESP8266 to report their IP address via Blynk. Is that correct?

If that’s not what you’re trying to achieve then PLEASE explain in much more detail, as it’s impossible to help at the moment with the information you’ve provided.

Pete.

Yes Sir,
That was what i need to display via Blynk.

I don’t believe that it’s possible for an ESP8266 to have multiple smart devices connected to it, and for it to effectively act as a router for these devices.

The sensible solution would be for these smart devices to connect directly to Blynk.

But, you’re not sharing enough information for people to fully understand d what it is that you’re trying to achieve, and why you’re trying to achieve it.

Pete.