Page 1 of 1

Struggling to Compile ESP32 WireGuard Example Code

Posted: Mon Jul 14, 2025 8:54 pm
by Byteman-34
Pretty simple - I’m trying to compile a small Wireguard demo example for an ESP32 using the Arduino IDE. I can’t get past an error that says: wireguardif.c fatal error: tcpip_adapter.h no such file.

#include <WiFi.h>
#include <WireGuard-ESP32.h>
Include something else? I’m lost…

FULL CODE BELOW…

Code: Select all


#include <Adafruit_Neopixel.h>
#include <Arduino.h>
#include <WiFi.h>
#include <WireGuard-ESP32.h>

#define RGB_BRIGHTNESS 200   // max 255
#define WIFI_SSID "Baddfasddfdfs"
#define WIFI_PASSWORD "??????45??"

IPAddress local_ip(192.168.1.1);                                          // [Interface] VPN Address
char private_key[]      = "8CRo9QpWNsdQ------KVPqP72ULvHJK32YpmcP5Tr1U=";   // [Interface] PrivateKey of esp
char public_key[]       = "oeqDhAeox-—---cKq/fo4ubgssbwhO3K2Nkmn6JVhg8=";   // [Peer] PublicKey of peer
char endpoint_address[] = (192.168.1.250);                   // [Peer] Endpoint
int endpoint_port       = 443;                                              // [Peer] Endpoint
   
static WireGuard wg;
static const inline void beginWireGuard()
{
  // Must set the correct time
  configTime(9 * 60 * 60, 0, "ntp.jst.mfeed.ad.jp", "ntp.nict.jp", "time.google.com");
  wg.begin(
  local_ip,           // IP address of the local interface
  private_key,        // Private key of the local interface
  endpoint_address,   // Address of the endpoint peer.
  public_key,         // Public key of the endpoint peer.
  endpoint_port);     // Port pf the endpoint peer.

}


void setup()
{
  WiFi.begin (WIFI_SSID, WIFI_PASSWORD);
  Serial.begin(115200);
 
  // blinky on-board LED upon boot up....
   #ifdef RGB_BUILTIN
    neopixelWrite (RGB_BUILTIN, 0, 100, 0);   //GREEN ON
    delay(1500);
    // neopixelWrite (RGB_BUILTIN, 0,0,0);   //OFF
   #endif
   
   delay (500);
   
   Serial.println("SETUP DONE...");
}
 
bool isConnected = false;


// the loop function runs over and over again forever
void loop()
{
  if (WiFi.status () == WL_CONNECTED && !isConnected)
  {
    neopixelWrite (RGB_BUILTIN, 0, RGB_BRIGHTNESS, 0);  //BLUE ON
    Serial.println("WIFI Connected");
    beginWireGuard();
    isConnected = true;
  }  
 
 
  if (WiFi.status () != WL_CONNECTED)
  {
    Serial.println (".");
    neopixelWrite (RGB_BUILTIN, RGB_BRIGHTNESS, 0,0);    //RED ON
    delay (1000);
    isConnected = false;  
  }  
 

}


Re: Struggling to Compile ESP32 WireGuard Example Code

Posted: Tue Jul 15, 2025 3:09 am
by lbernstone
Networking APIs were completely overhauled in v3.x (IDF 5.x). Your best bet is to downgrade to v2.0.17 and build with that.

Re: Struggling to Compile ESP32 WireGuard Example Code

Posted: Tue Jul 15, 2025 3:21 am
by lbernstone
This repo has forked and updated it to use the netif interface.