How to save serial monitor data to SD Card esp8266

hello, I have a problem, I am using an esp8266 to capture the internal ip and mac of the devices that connect to the esp, what I want to do is save that information that appears on the serial monitor, but on the micro sd, I was I read in the forum but I did not find an answer

#include <ESP8266WiFi.h>

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

const char *ssid = "testesp8266";
const char *pass = "test321";

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 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 de usuarios = ");
  Serial.println(number_client);
  
    while (stat_info != NULL) {
      struct ipv4_addr *IPaddress;
      IPaddress = &stat_info->ip;
      address = IPaddress->addr;
      
      Serial.print("Usuario= ");
      
      Serial.print(i);
      Serial.print(" IP Adress = ");
      Serial.print((address));
      Serial.print(" MAC Address = ");
      
      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);
}

that is the code that I have, I understand the idea of ​​writing in the .txt of the sd but I don't know how to save all the information that is loading in the serial monitor

The datalogger example in the SD library shows how to create a new file.

Of course I know that, but how do I save what appears on the serial monitor?

You have to send it to the serial monitor in your program, right?
Each time you call Serial.print() or Serial.println() also call a function to log that data.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.