scankonstanz

WiGPSFi – ESP8266 + GPS

facebooktwittergoogle_plusmail

If you love finding solutions that could widen horizons – that is something you will like!

I wanted to know what my next ESP projects could connect to – and I decided to look for some open WiFis …. 

That is the result after two days programming – and 45 min walking arround. Only for testing this technique – Don´t do this at home, please 🙂 

In this blogpost, you can only read about finding and printing out maps with WiFi-Accesspoints and not how to crack them! I did not connected to any of this WiFis and you should also refrain. The ESP is only listening passivly!

image

I took a ESP8266 12-E  that could scan wifi. Connected a Serial GPS to it, to get the location and store them on a Micro-SD-Card. – Thats nothing new – WARDRIVING / WARCHALKING is known since a couple of years for now. In Germany it is not legal, Google payed a 140.000 € punishment because they did it.

I want to show you only my solution – here it is – the WiGPSFi:

I´m using the Arduino IDE and that is the code I wrote:


/* WiGPSfi - ESP8266 + GPS + SD + LED
* Autor: Robert Stefanowicz - euerdesign.de 04/2016
* ESP8266 Scans for Wifi-Networks - get GPS Position - write to SD
*
* Red LED blinking - NO GPS FIX
* Red LED fast strobe - SD - Error
* Each green lightup 1 Wifi Network + GPS ok + SD ok
*
* Connect ESP8266 + SD + GPS + LED:
*
* between VCC and GND capacitator 0.1uF + 470uF
*
* GPS VCC = 5V Connect a cap 470uF between GPS VCC and GPS GND
* GPS GND = GND
* GPS RX = ESP TX (Serial Baud 9600)
* GPS TX = ESP RX (Serial Baud 9600)
* SD CS = ESP 4
* SD SCK = ESP 14
* SD MOSI = ESP 13
* SD MISO = ESP 12
* SD VCC = 5V Connect a cap 470uF between SD VCC and SD GND
* SD GND = GND
* LED GRÜN = ESP 5
* LED ROT = ESP 16
* LED GND = 1kOhm GND
* ESP 5V = 5V (Konverter in ESP Breadboard Adapter) Ansonsten ESP 3,3V !!!!
* ESP GND = GND
* ESP EN = ESP VCC (3,3V)
* ESP 15 = ESP GND
*
*/
#include "ESP8266WiFi.h"
#include <TinyGPS.h>
#include <SPI.h>
#include <SD.h>
//-----------GPS
TinyGPS gps;
File myFile;
static void smartdelay(unsigned long ms)
{
unsigned long start = millis();
do
{
while (Serial.available())
gps.encode(Serial.read());
} while (millis() - start < ms);
}
void setup()
{
//------------GPS SS
Serial.begin(9600); //GPS Softwareserial
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
// Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
// or the SD library functions will not work.
pinMode(10, OUTPUT);
pinMode(16, OUTPUT);
pinMode(5, OUTPUT);
if (!SD.begin(4)) {
return;
}
} //SETUP END
void loop()
{
float flat, flon;
unsigned long age, date, time, chars = 0;
unsigned short sentences = 0, failed = 0;
ESP.wdtDisable();
gps.f_get_position(&flat, &flon, &age);
delay(50);
if (age != TinyGPS::GPS_INVALID_AGE){ //CHECK OB GPS FIX
digitalWrite(16, LOW);
int n = WiFi.scanNetworks(false);
if (n == 0){
}
else
{
for (int i = 0; i < n; ++i)
{
myFile = SD.open("scan.txt", FILE_WRITE);
if (myFile) {
digitalWrite(5, HIGH);
delay(150);
digitalWrite(5, LOW);
delay(150);
myFile.print(WiFi.BSSIDstr(i));
myFile.print(";");
myFile.print(WiFi.SSID(i));
myFile.print(";");
myFile.print(WiFi.RSSI(i));
myFile.print(";");
myFile.print((WiFi.encryptionType(i) == ENC_TYPE_NONE)?"0":"1");
myFile.print(";");
myFile.print(flat,5);
myFile.print(";");
myFile.print(flon,5);
myFile.println(";");
delay(10);
myFile.close();
}
else {
//CANT WRITE TO SD
for (int i = 0; i < 5; ++i)
{
digitalWrite(16, HIGH);
delay(200);
digitalWrite(16, LOW);
delay(200);
}
}
}
}
} else { //CHECK IF GPS FIX
digitalWrite(16, HIGH);
delay(10);
}
digitalWrite(16, LOW);
smartdelay(500);
}

That was pretty simple huh ?

 

This is a little ESP to Breadboard PCB with an voltage regulator an the firmware flash button:image

Actual WiGPSFi – ESP8266 12-E + GPS + SD + RGB LED + Powerbank

image

the result itself after uploading it to my page with a map and a scan.txt file parser

image

You could send me your SCAN.TXT – I will upload it if you want. That will be your donation to me!

 

scankonstanz

While flashing the firmware you have to disconnect the GPS and use TX and RX to flash.

image

SCAN.TXT – one of the results containing.

MAC ; SSID; dB; Protected bool; lat; long;image

What will my Server do with that file ? Let´s parse it and write to a MySQL -DB .

If you want – I can help you set it up with all MySQL-DBs and all PHP files. Just comment.

$id=$_GET["id"];
$abfrageaus = "SELECT * FROM wardrivefiles WHERE id=$id ORDER BY id ASC LIMIT 1";
$ergebnisaus = mysql_query($abfrageaus);
while($row = mysql_fetch_object($ergebnisaus))
{
$fileurl=$row->fileurl;
}
$row = 1;
if (($handle = fopen($fileurl, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
$num = count($data);
$row++;
if ($num>'1'){for ($c=0; $c < $num; $c++) {
// Beispiel
//$C = $data[$c]
// 0 = F8:D1:11:A9:9C:5E
// 1 = p1338
// 2 = -68
// 3 = 1
// 4 = 48.027412
// 5 = 8.524705
// 6 =
// 7 =
$mac = $data[0];
$ssid = $data[1];
$db = $data[2];
$protected = $data[3];
$lat = $data[4];
$lon = $data[5];
$date = $data[6];
if(strpos($lat,"*")!==false AND $ssid AND $mac) { }
else {
$query = mysql_query("SELECT * FROM scan WHERE mac='$mac'");
$anzahl = mysql_num_rows($query);
if ($anzahl == 0){
mysql_query("INSERT INTO scan SET mac='".$mac."',ssid='".$ssid."',db='".$db."',protected='".$protected."',lat='".$lat."',lon='".$lon."',date='".$date."',fileurl='".$fileurl."'");
}
}
}
} // IF SCHLEIFE
}
fclose($handle);
mysql_query("UPDATE scanfiles SET bearbeitet='1' WHERE fileurl='$fileurl'");
}

Then there is the Map what reads the MySQL-DB an load the points dynamicaly. An Iconset that I have designed – will show what is a protected Wifi network (red dot) and what is open (all other symbols).

Please share and comment your opinion.

Got the PCB! [EDIT]

Finished the work at the PCB – now i´ve got some fun 🙂

pcb

finished pictures will follow the next days.

 

facebooktwittergoogle_plusmail

4 Gedanken zu „WiGPSFi – ESP8266 + GPS“

  1. What is the supply voltage you are giving? keep it around 5V.
    I have few spare PCB where you can do these experiments.
    But I think the shipment cost will be more than the PCB cost!

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *