Skip to content

WiFi Client Settings

Eric Stockenstrom edited this page Feb 21, 2020 · 24 revisions
 NOTE:   A WiFi session will not start until the activateWiFi button is pressed

On the ESP32 Dev Board, activateWiFi occurs when GPIO15 is momentarily grounded. Other ESP32
boards may use alternative GPIO pins.

Alternatively, un-comment this line in the config.h tab:

#define Start_WiFi // Start WiFi at startup, override startWiFi Pin

From v2.41 MavToPass will connect automatically to Mission Planner or QGroundcontrol if the STA / UDP options are selected

The WiFi functionality in the Mav2PassThru converter supports both TCP/IP and UDP protocols, and two modes of connection, namely Access Point (AP) or Station (STA). These bi-directional connections are possible at both ends of the converter, the front-end from the flight-controller, or the back-end to the GCS.

In AP mode, the ESP32 converter adopts IP 192.168.4.1 and advertises the hotspot name “Mav2Passthru” and password “password”. (You should change your password before flashing). From your tablet or laptop, connect to this hotspot and your device will be allocated IP 192.168.4.2. Launch the ground control software of your choice.

In STA mode, the ESP32 converter is a terminal device, and will connect to an AP device or LAN and be allocated an IP. For example, it can connect seamlessly to the ground-side Raspberry Pi of the EZ-WiFibroadcast system.

Consider the situation where we have a remote terminal, for example QGroundControl running on a tablet.

UDP to Ground Control Station using Access Point mode

This is the default connection mode for QGroundControl and it should auto-connect.

Set up the ESP32 source code like this, then compile and flash.

<pre><code>// Choose one only of these GCS-side I/O channels
// How does Mavlink telemetry leave the converter?
// These are optional, and in addition to the S.Port telemetry output
//#define GCS_Mavlink_IO  9    // NONE (default)
//#define GCS_Mavlink_IO  0    // Serial Port        
//#define GCS_Mavlink_IO  1    // BlueTooth Classic - ESP32 only
#define GCS_Mavlink_IO  2    // WiFi - ESP32 only
// Choose one - for ESP32 only
//#define WiFi_Protocol 1    // TCP/IP
#define WiFi_Protocol 2    // UDP     
// Choose one - AP means advertise as an access point (hotspot). STA means connect to a known host
#define WiFi_Mode   1  //AP        
//#define WiFi_Mode   2  // STA

Notice that this link may be set up as the QGC default

Access Point (AP) Mode with TCP/IP

Find these lines in the source code and change them like this:


// Choose one only of these GCS-side I/O channels
// How does Mavlink telemetry leave the converter?
// These are optional, and in addition to the S.Port telemetry output
//#define GCS_Mavlink_IO  9    // NONE (default)
//#define GCS_Mavlink_IO  0    // Serial Port        
//#define GCS_Mavlink_IO  1    // BlueTooth Classic - ESP32 only
#define GCS_Mavlink_IO  2    // WiFi - ESP32 only


 // Choose one - for ESP32 only
 #define WiFi_Protocol 1    // TCP/IP
 //#define WiFi_Protocol 2    // UDP    



// Choose one - AP means advertise as an access point (hotspot). STA means connect to a known host
#define WiFi_Mode   1  //AP            -
//#define WiFi_Mode   2  // STA
In the Arduino IDE use Edit/Find IDE “ssid” to locate the lines below, and change the password.

      const char *APssid =    "Mav2Passthru";    // The AP SSID that we advertise  ====>
      const char *APpw =      "password";        // Change me!

Once the table or laptop is connected, launch QGroundControl, touch the Q in the top left hand corner, and touch Comm Links. My page looks like this:

Click on Add at the bottom of the page:

and add the information for a TCP/IP access point link. The default IP address of the ESP32 converter is 192.168.4.1, and the default port is 5760.

Click OK, and then Connect. You will immediately see the parameter bar runs out to the right as the parameters are downloaded from the flight controller to QGC:

Station (Sta) Mode

Find and change these #define options in the code:


// Choose one - AP means advertise as an access point (hotspot). STA means connect to a known host
//#define WiFi_Mode   1  //AP         
#define WiFi_Mode   2  // STA

Also find and change the SSID and password of the access point to which you wish to connect.

    #if (WiFi_Mode == 2)  //  STA
      const char *STAssid =     "TargetAPName";    // Target AP to connect to      <====
      const char *STApw =       "targetPw";      // Change me!

Now compile and flash;

Open QGroundControl, touch the Q on the top left-hand side, and touch Comm Links, and ADD. Enter the fields as seen below:

Click Ok, and Connect. Voila!

Station Mode – UDP Protocol

The ESP32 converter board can also accept WiFi Mavlink telemetry input for decoding. For example, you may have an EZ-WiFibroadcast or similar HD video/telemetry link from the aircraft, with a Raspberry Pi board processing telemetry and video on the ground. That ground RPi can have its WiFi adapter activated and present as an access point with the SSID “EZ-WifiBroadcast”. EZ-WiFibroadcast employs the UDP protocol, as the “fire and forget” nature of UDP better suits the application. To setup the ESP32 board for UDP, remain in STA mode, and find and make the following changes for the UDP protocol:

// Choose one only of these Flight-Controller-side I/O channels 
// How does Mavlink telemetry enter the converter?
//#define FC_Mavlink_IO  0    // Serial Port (default)         
//#define FC_Mavlink_IO  1    // BlueTooth Classic - ESP32 only
#define FC_Mavlink_IO  2    // WiFi - ESP32 only
//#define FC_Mavlink_IO  3    // SD Card / TF - ESP32 only
// Choose one - for ESP32 only
//#define WiFi_Protocol 1    // TCP/IP
#define WiFi_Protocol 2    // UDP      
// Choose one - AP means advertise as an access point (hotspot). STA means connect to a known host
#define WiFi_Mode   1  //AP            
//#define WiFi_Mode   2  // STA
      const char *STAssid =     "EZ-WifiBroadcast";    // Target AP to connect to      <====
      const char *STApw =       "wifibroadcast";