WiFi Training Transmitter

One of the toughest transmitters to direction find is that of an unauthenticated, WiFi client. Without being attached to an access point, a WiFi client may only send out a transmission, or probe request, once every 5 minutes. It is not uncommon to see requests sent every 20 minutes. There are ways to expedite the process and those methods have been discussed at length in a previous article. One thing that is absolutely necessary is practice and the Adafruit Feather M0 WiFi transmitter can help to that end.

Feather M0 WiFi

Hardware

Adafruit carries several different WiFi transmitters, but I chose the following because I didn’t know any better and still don’t.

Adafruit Feather M0 WiFi – ATSAMD21 + ATWINC1500: https://www.adafruit.com/product/3010

Unlike the previous transmitters covered, the M0 WiFi has a built-in antenna so you don’t need to add anything. It’s ready to go straight out of the packaging. Also, since it operates within the WiFi band, there is no guessing at what frequency you’ll be producing. Everything will be nicely in the 2.4 GHz band.

Software

The Feather is programmed using the Arduino IDE, so if you have never downloaded the software, follow the procedures below:

To deal with the new WiFi module, you will need to download and install the WiFi101 libraries. Follow the tutorial here: https://learn.adafruit.com/adafruit-feather-m0-wifi-atwinc1500/using-the-wifi-module

This tutorial will also update the firmware on your module. Complete the previous tutorial down to the Scanning for WiFi part. Pay particular attention to the part about adding WiFi.setPins(8,7,4,2); to any sketch that is an example WiFi101 program. Without this line of code, the example code provided through Arduino will not work. You will need to add it.

Code

The following code causes the M0 WiFi to send probe requests as if it is looking for an access point. The user can specify how often this activity occurs. As with previous code I’ve produced involving Adafruit transmitters, just stick to changing the parameters within the ******* block and you can’t go wrong. Simply copy and paste the following code into your Arduino sketch window. If you prefer Github, the code can be found here: https://github.com/skinnyrad/Training-Fruit-Feather-Transmitters/blob/master/M0_WiFi_ATSAMD21_ATWINC1500.ino

#include <SPI.h>
#include <WiFi101.h>

//***********************************************************************************
//WHAT DO YOU WANT THIS TO DO?
// 1 - The WiFi client will probe request based on the interval delayTime
// 2 - The WiFi client will transmit randomly between 2 specified times

//Choose the number of the option you want.
int WhatToDo = 2;

//FOR OPTION 1
//Chose how often, in milliseconds, to transmit a WiFi signal
int delayTime = 10000;

//FOR OPTION 2
//Give the lower and upper limits, in milliseconds, of how often to transmit a signal
int lowerLimit = 5000;
int upperLimit = 300000; //5 minutes (300000) is a reasonable upper limit although
//20 minutes (1200000) is not unheard of.
//***********************************************************************************

int ledPin = 13;
void setup()
{
  WiFi.setPins(8,7,4,2);
  pinMode (ledPin, OUTPUT);
}

void loop()
{
  if(WhatToDo == 1) //OPTION 1
  {
    delay(delayTime);
    WiFi.scanNetworks();
  }

  if(WhatToDo == 2)//OPTION 2
  {
    delay(random(lowerLimit,upperLimit));
    WiFi.scanNetworks();

    //Blinks whenever randomly timed WiFi signal transmits
    digitalWrite(ledPin,HIGH);
    delay(250);
    digitalWrite(ledPin,LOW);
    delay(250);
    digitalWrite(ledPin,HIGH);
    delay(250);
    digitalWrite(ledPin,LOW);
  }
}

The code needs to be changed to meet your demands and the first variable to specify is WhatToDo. You can choose either 1 or 2. If you choose 1, then also change the variable called delayTime to how often you would like the transmitter to send out a set of probe requests. It is currently set for 10 seconds even though it says 10,000. This is because all timing must be specified in milliseconds. Once compiled and uploaded the transmitter will then probe request every 10 seconds.

If you choose 2, then the transmitter will send out a set of probe requests between the two times specified in lowerLimit and upperLimit. With the current setup, the transmitter will produce a set of probe requests for some random time between 5 seconds to 5 minutes.

Wireshark

In case you are interested in exactly what is being transmitted by the M0 WiFi, here is a Wireshark capture of the probe requests being transmitted on Channel 10: http://skinnyrd.com/wp-content/uploads/2018/08/Feather_M0_Network_Scan-.pcapng.zip

Questions

If you have any questions regarding the setup or code, just let me know. Thanks!



Leave a Reply