First Time WiFi Module Setup

Start 

You must follow this guide the first time you want to use the WiFi module. The module comes with a different Baud rate than what our libraries use. If you'd like to know more about Baud rates and why we have to change it, check out the page after this one.

My module is different from the pictures 

In the middle of the production of this kit, our manufacturer changed what the WiFi module looks like. There is one that has a silver rectangle and one button. The other version has a black square and two buttons. The hardware is identical. They have the same hardware specifications and function the same.

Both WiFi modules side by sideBoth WiFi modules side by side

Modules 

Gather the following parts to complete this project.

Parts

All Parts
All Parts
WiFi
Cable
PartQuantity
WiFi 1
Cable 1

WiFi Module 

Take a cable and unwrap it. Plug one side into the WiFi socket and the other into any Digital socket.

Parts needed
Parts needed
Take a cable
Unwrap it
Plug one side into the WiFi socket
The other into any Digital socket

Upload

Upload the following code. The example below uses the D8 digital pin.

Download file Copy to clipboard
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
#include <SoftwareSerial.h>
#define TIMEOUT 10000

//Creates serial communication object
SoftwareSerial espSerial(8, 9); // RX, TX

String response = "";

int baudCount = 0;

bool timedout = false;
bool set = false;
bool confirmed = false;

unsigned long timestamp = 0;

void setup() {
  // Open serial communications
  Serial.begin(9600);
  espSerial.begin(115200);
  Serial.println("Testing WiFi Module...");
  espSerial.write("AT\r\n");
}



void loop() { // run over and over
  while (response == "" && !timedout) {
    if (espSerial.available()) {
      delay(200);
      espSerial.write("AT\r\n");
      //Display in the Serial Monitor
      response = espSerial.readString();
    }
    if(millis() > (TIMEOUT + timestamp)){
      timedout = true;
      timestamp = millis();
    }
  }
  if(timedout && !set && !confirmed){
    Serial.println("Timeout communicating with WiFi Module at 115200 Baud");
  }

  if (response.endsWith("OK\r\n") && !set && !timedout) {
    Serial.println("Found WiFi Module. Setting Baudrate to 9600...");
    espSerial.write("AT+UART_DEF=9600,8,1,0,0\r\n");
    set = true;
    response = "";
    espSerial.end();
    espSerial.begin(9600);
    delay(200);
    espSerial.write("AT\r\n");
  }
  if (!set && timedout) {
    Serial.println("Setting Baudrate to 9600...");
    espSerial.write("AT+UART_DEF=9600,8,1,0,0\r\n");
    set = true;
    response = "";
    espSerial.end();
    espSerial.begin(9600);
    delay(200);
    espSerial.write("AT\r\n");
    timestamp = millis();
    timedout = false;
  }

  if (response.endsWith("OK\r\n") && set && !confirmed) {
    Serial.println("WiFi Module configured to 9600 baud");
    delay(200);
    Serial.println("Ready for Thimble use");
    confirmed = true;
  }
}

Did it work? 

Open the Serial Monitor after uploading to see if it worked. You want to see this output text...

Download file Copy to clipboard
1
2
3
4
Testing WiFi Module...
Found WiFi Module. Setting Baudrate to 9600...
WiFi Module configured to 9600 baud
Ready for Thimble use

I only see Testing WiFi Module

Press the reset button on your Arduino. If still only see Testing ESP... run the code below.

Download file Copy to clipboard
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
#include <SoftwareSerial.h>

//Creates serial communication object
SoftwareSerial espSerial(8, 9); // RX, TX

String response = "";

bool confirmed = false;

void setup() {
  // Open serial communications
  Serial.begin(9600);
  espSerial.begin(9600);
  Serial.println("Testing WiFi Module...");
  espSerial.write("at\r\n");
}


void loop() { // run over and over
  while (response == "") {
    if (espSerial.available()) {
      delay(200);
      espSerial.write("at\r\n");
      //Display in the Serial Monitor
      response = espSerial.readString();
    }
  }

  if (response.endsWith("OK\r\n") && !confirmed) {
    Serial.println("Your WiFi Module is working!");
    Serial.println("You are done with this step");
    confirmed = true;
  }
}

Did it work?

Open the Serial Monitor after uploading to see if it worked. If you see this...

Download file Copy to clipboard
1
2
3
Testing ESP...
Your WiFi Module is working!
You are done with this step

...then you are ready to go. If not, then double check you are using D8 as your socket and run the first code again.