ESP8266 Mini Sniff

I have been playing around with the awesome project from https://www.hackster.io/rayburne/esp8266-mini-sniff-f6b93a

Many Thanks to Ray

Basically I want to write the output to an SD Card.

I have managed to successfully wire up the card, initialize it and Write the headings to a file, what I cannot do is write the updated data as its displayed in the serial output.

I was hoping someone could provide some guidance and possibly some code example on how to write the serial output to a file.

Thanks in advance…

The sketch is made up of 3 files attached;

Sniffing6.ino (2.7 KB)

functions.h (4.08 KB)

structures.h (4.06 KB)

You can't write serial output to a file. You can open your file right before you start printing and for every serial.print line include a line right after it to write the same thing to the SD card.

Any chance you could give me an example of how to actually implement that?

my ino file is

// by Ray Burnette 20161013 compiled on Linux 16.3 using Arduino 1.6.12

#include <ESP8266WiFi.h>
#include “./functions.h”
#include <SPI.h>
#include <SD.h>

const int chipSelect = 2;

File dataFile;

#define disable 0
#define enable 1
// uint8_t channel = 1;
unsigned int channel = 1;

void setup() {
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

Serial.printf("\n\nSDK version:%s\n\r", system_get_sdk_version());
Serial.println(F(“ESP8266 mini-sniff by Ray Burnette http://www.hackster.io/rayburne/projects”));
Serial.println(F(“Type: /-------MAC------/-----WiFi Access Point SSID-----/ /----MAC—/ Chnl RSSI”));

Serial.print(“Initializing SD card…”);

// see if the card is present and can be initialized:
if (!SD.begin(2)) {
Serial.println(“Card failed, or not present”);
// don’t do anything more:
return;
}
Serial.println(“card initialized.”);

dataFile = SD.open(“datalog.txt”, FILE_WRITE);
if (dataFile) {
dataFile.println(“Type: /-------MAC------/-----WiFi Access Point SSID-----/ /----MAC—/ Chnl RSSI”);

dataFile.close();
}

wifi_set_opmode(STATION_MODE); // Promiscuous works only with station mode
wifi_set_channel(channel);
wifi_promiscuous_enable(disable);
wifi_set_promiscuous_rx_cb(promisc_cb); // Set up promiscuous callback
wifi_promiscuous_enable(enable);
}

void loop() {
channel = 1;
wifi_set_channel(channel);
while (true) {
nothing_new++; // Array is not finite, check bounds and adjust if required
if (nothing_new > 200) {
nothing_new = 0;
channel++;
if (channel == 15) break; // Only scan channels 1 to 14
wifi_set_channel(channel);
}
delay(1); // critical processing timeslice for NONOS SDK! No delay(0) yield()
// Press keyboard ENTER in console with NL active to repaint the screen
if ((Serial.available() > 0) && (Serial.read() == ‘\n’)) {
Serial.println("\n-------------------------------------------------------------------------------------\n");
for (int u = 0; u < clients_known_count; u++) print_client(clients_known);
for (int u = 0; u < aps_known_count; u++) print_beacon(aps_known);
Serial.println("\n-------------------------------------------------------------------------------------\n");
}
}
}

Any chance you'll read the forum rules and post your code in code tags so it is readable? You're asking an awful lot for someone who won't even bother to read the "Please read this before posting" thread.

It's not hard at all to implement. What part of what I said to do didn't you understand. You obviously know how to open the file, because you did that elsewhere in the code. And you obviously know how to write to the file, because you did that elsewhere in the code. IS it the part where you copy the same thing from the serial println statements into the print statements to the file. Control-c and control-v work for me. But if you want you can also left click and get the menu and do copy-paste from there.

What part of that is confusing you?

It would appear that @ess would rather spend their precious time registering as a new member and insulting existing members, than read a few simple posting guidelines.

Thread locked.