Loading Items

About This Project

In this project you will learn how to connect the ESP32 to a network, as well as the ability to program it through the Arduino IDE. Both Linux and Windows are covered in this tutorial.
Request Access

Project Info

Skills

  • Coding
  • Linux Terminal
  • Overall

Meet The Makers

Join Team
  • alexswym
    • User:alexswym
    • Rank:Master Apprentice
    • Projects:14
    • Joined:2017
  • xjoexripx
    • User:xjoexripx
    • Rank:Master
    • Projects:31
    • Joined:2016
    • From:US
  • Riley.Purvis
    • User:Riley.Purvis
    • Rank:Master Apprentice
    • Projects:12
    • Joined:2017
    • From:US
  • James
    • User:James
    • Rank:Master
    • Projects:30
    • Joined:2016
    • From:US
    Interests: Systems Architect. Love making robots and systems with moving parts.

No Comments yet. Why don't you add one?

.Adding ESP32 to Arduino IDE

.Windows



Arduino IDE

****Note that you must have a current version of Arduino IDE. If you have an older version, you will need to uninstall the older and install the newer version which can be found below******

Download the Arduino IDE

Python


In order to add ESP32 to Arduino IDE on windows, you will need to download Python. While you are installing Python, you will need to make sure to tick the "Add python.exe to Path" option on.

Git

Next you will need to install Git. Once Git is installed, open Git GUI. Click "Clone Repository", and enter in Source Location the link https://github.com/espressif/arduino-esp32.git


In the Target Directory find you "Arduino/hardware" file path. This is where you installed the Arduino IDE to. At the end of the "Arduino/hardware" you can add your own file path. For example ".../Arduino/hardware/esp32".
An example of my view is


Once finished, go into the Arduino IDE and check tools > board > ESP32 Dev Module

.Linux




Arduino IDE

****Note that you must have a current version of Arduino IDE. If you have an older version, you will need to uninstall the older and install the newer version which can be found below******

Download the Arduino IDE


Go to the directory where you installed the arduino, and you will find a "install.sh" file. You will need to run this file in the terminal by using the command

./install.sh

if you find that there is an error, you will need to edit the file. In order to do so use the command

kwrite install.sh

If you need to install kwrite, the terminal will give you instructions on how to do so.
Once the file is opened you will need to find the line RESOURCE NAME=cc.arduino.arduinoide

This line can be found a few lines from the top of the file. This line will need to be changed to

RESOURCE NAME=arduino-arduinoide

After making the change, save the file. And enter the command

./install.sh


Now you will want to add the ESP32 to the Arduino IDE as it is not added at default. Adding the ESP32 board to the Arduino IDE is as simple as a terminal command in linux. In order to do so you will need to know where the arduino directory is. Enter in the command below with minor editing


mkdir -p ~[put arduino directory here]/hardware/espressif && \
cd ~[put arduino directory here]/hardware/espressif && \
git clone https://github.com/espressif/arduino-esp32 esp32 && \
cd esp32/tools/ && \
python get.py

As an example, my command with my arduino directory is
mkdir -p ~/Documents/Arduino/arduino-1.8.2/hardware/espressif && \
cd ~/Documents/Arduino/arduino-1.8.2/hardware/espressif && \
git clone https://github.com/espressif/arduino-esp32 esp32.get esp32 && \
cd esp32/tools/ && \
python get.py

Now after opening the Arduino IDE, you should notice that under tools>board you should see ESP32 Dev Module


You may now program your ESP32 through the Arduino IDE

.Check What Networks Are Available

After you have added the ESP32 to Arduino IDE, make sure that the ESP32 Dev Module has been selected in tools>boards

Next you will want to use the code provided by espressif on github to check available networks. The code can be found here
Or you can copy and paste the code below
/*
 *  This sketch demonstrates how to scan WiFi networks.
 *  The API is almost the same as with the WiFi Shield library,
 *  the most obvious difference being the different file you need to include:
 */
#include "WiFi.h"

void setup()
{
    Serial.begin(115200);

    // Set WiFi to station mode and disconnect from an AP if it was previously connected
    WiFi.mode(WIFI_STA);
    WiFi.disconnect();
    delay(100);

    Serial.println("Setup done");
}

void loop()
{
    Serial.println("scan start");

    // WiFi.scanNetworks will return the number of networks found
    int n = WiFi.scanNetworks();
    Serial.println("scan done");
    if (n == 0) {
        Serial.println("no networks found");
    } else {
        Serial.print(n);
        Serial.println(" networks found");
        for (int i = 0; i < n; ++i) {
            // Print SSID and RSSI for each network found
            Serial.print(i + 1);
            Serial.print(": ");
            Serial.print(WiFi.SSID(i));
            Serial.print(" (");
            Serial.print(WiFi.RSSI(i));
            Serial.print(")");
            Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*");
            delay(10);
        }
    }
    Serial.println("");

    // Wait a bit before scanning again
    delay(5000);
}


Once the code has been entered into the Arduino IDE, make sure your ESP32 is connected and the proper COM is selected under tools > port.


Next upload the code to the ESP32, and open the Serial Monitor on the Arduino IDE. In order to do so click "ctr+shift+m". And a window will appear, where you will need to select the correct Baud rate of 11520. You should then see all the networks being detected by the ESP32. An example is shown below


Once you see the network you would like to connect to on the list, you are now ready to connect to it.

.Connect to a Network

In order to connect to a network, you will need to know both the name and password of the network. You will be able to make a new program where you can copy and paste the code below with minor editing needed
#include "WiFi.h"

const char* networkName = "Insert Network Name Here"; /*TODO*/
const char* networkPassword = "Insert Network Password Here"; /*TODO*/

void setup() {
  Serial.begin(115200);

  WiFi.mode(WIFI_STA);
  Serial.println("Disconnecting from old possible WiFi...");
  WiFi.disconnect();
  delay(200);
  Serial.println("Successfully disconnected!");
 
  WiFi.begin(networkName, networkPassword);

  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.println("Connecting to WiFi...");
  }

  Serial.print("\nConnected to network ");
  Serial.print(networkName);
}

void loop()
{
  
}

All you need to edit to the code is replace the TODO items with the name of your network, and the password needed for the network.
Once you flash the code, open the Serial Monitor by clicking "ctrl + shift + m", and if you entered the correct information you should see "connected to network [network name]".


Your ESP32 is now connected to the internet!

  Details Downloads Size Get it

ESP32 Github Repo

Last updated on 08/05/2017

by xjoexripx

219 -
Qty   Item Where to Find Est. Cost More Info
1 Sparkfun esp32  Thing Item Number: esp32

Sparkfun esp32 Thing

Item #: esp32

Dual-core Tensilica LX6 m

$20.00 10 files   5 links  
 
Schematic

Schematic

Updated 11/15/2016 by jamesshawver1
Eagle Files

Eagle Files

Updated 11/30/2016 by jamesshawver1
Pinout

Pinout

Updated 11/15/2016 by jamesshawver1
  • Download Pinout
  • File Size:635.7kb
pinout image

pinout image

Updated 11/15/2016 by jamesshawver1
datasheet

datasheet

Updated 11/15/2016 by jamesshawver1
Espressif Getting Started Guide

Espressif Getting Started Guide

Updated 11/15/2016 by jamesshawver1
3D CAD (Sketchup)

3D CAD (Sketchup)

Updated 11/21/2016 by jamesshawver1
3D CAD (STL)

3D CAD (STL)

Updated 11/21/2016 by jamesshawver1
3D CAD (Blender)

3D CAD (Blender)

Updated 11/21/2016 by jamesshawver1
Technical Datasheet ( Register Descriptions )

Technical Datasheet ( Register Descriptions )

Updated 6/14/2017 by James