In this post, we shall discuss how to Print Device Information Connected to NodeMCU Access Point in Serial Monitor. It is required to know the IP address and MAC address of the devices connected for tracking purposes. Sometimes IP address is used to whitelist or blacklist a device. To know the IP and MAC of the device connected to NodeMCU the program given below can be used.
NOTE: Configure NodeMCU as Hotspot (Access Point)
PROGRAM:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | //Header Files #include <ESP8266WiFi.h> #include <WiFiClient.h> #include <ESP8266WebServer.h> //Header File to get information about client extern "C" { #include<user_interface.h> } //Hotspot Name and Password const char* ssid = "ESPWebServer"; const char* password = "12345678"; ESP8266WebServer server(80); //Server on port 80 void handleRoot() { server.send(200, "text/plain", "Thank You for using www.mybtechprojects.tech"); } void client_status() { unsigned char number_client; struct station_info *stat_info; struct ip_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_client are = "); Serial.println(number_client); while (stat_info != NULL) { IPaddress = &stat_info->ip; address = IPaddress->addr; Serial.print("Client = "); Serial.print(i); Serial.println(); Serial.print(" Ip adress is = "); Serial.println((address)); Serial.print("Mac adress is = "); Serial.print(stat_info->bssid[0],HEX); Serial.print(stat_info->bssid[1],HEX); Serial.print(stat_info->bssid[2],HEX); Serial.print(stat_info->bssid[3],HEX); Serial.print(stat_info->bssid[4],HEX); Serial.println(stat_info->bssid[5],HEX); stat_info = STAILQ_NEXT(stat_info, next); i++; Serial.println(); } delay(500); } void setup(){ Serial.begin(9600); Serial.println(""); WiFi.mode(WIFI_AP); //For WI-FI with Password. WiFi.softAP(ssid,password); //For WI-FI without Password // WiFi.softAP(ssid); IPAddress myIP = WiFi.softAPIP(); Serial.print("HotSpot IP:"); Serial.println(myIP); server.on("/", handleRoot); server.begin(); Serial.println("HTTP server started"); } void loop() { client_status(); server.handleClient(); } |
OUTPUT:
THANK YOU
- IOT using Raspberry Pi Download
- CONNECT RASPBERRY PI USING VNC
- CONTROL ARDUINO FROM PI USING GUI
- Print Device Information Connected to NodeMCU Access Point
- Static IP Connection in NodeMCU
- Hotspot (Access Point) using NodeMCU
- 15 – Mail and SMS from Python
- 12 – HTTP Requests in Python
- 11 – Json Handling and Numpy Basics
- CONTROL NodeMCU FROM BLYNK ONLINE
SHARE THIS!!!
2 Comments
Mack Hollmann
(October 20, 2019 - 9:10 am)That is really attention-grabbing, You’re an overly skilled blogger. I have joined your rss feed and look ahead to seeking extra of your magnificent post. Also, I have shared your website in my social networks|
Gowtham S
(November 21, 2019 - 8:12 am)Hi Mack Hollmann,
Thanks for your support.