'class WiFiUDP' has no member named 'localPort'

A code isn't working while It did work a week ago.

It is a reinstall of arduino ide.
I loaded the board manager, added the esp8266 board and added what I think is all the libraries
OSC / HMC5883L

Yet it keeps giving me the error below:

/Users/quintendewilde/Documents/Arduino/algorave/algorave/algorave.ino: In function 'void setup()':
algorave:65:22: error: 'class WiFiUDP' has no member named 'localPort'
Multiple libraries were found for "SPI.h"
 Used: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI
Multiple libraries were found for "Wire.h"
 Used: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire
Multiple libraries were found for "WiFi.h"
 Used: /Applications/Arduino.app/Contents/Java/libraries/WiFi
Multiple libraries were found for "HMC5883L.h"
 Used: /Users/quintendewilde/Documents/Arduino/libraries/Arduino-HMC5883L-master
Multiple libraries were found for "OSCMessage.h"
 Used: /Users/quintendewilde/Documents/Arduino/libraries/OSC-master
exit status 1
'class WiFiUDP' has no member named 'localPort'
#include <WiFi.h>
#include <WiFiUdp.h>
#include <WiFiClient.h>
#include <WiFiServer.h>

#include <HMC5883L.h>

#if defined(ESP8266)
#include <ESP8266WiFi.h>        // Include the Wi-Fi library
#include <WiFi.h>
#include <WiFiUdp.h>            // UDP library
#include <OSCMessage.h>         // OSC library
//#include <Wire.h>

HMC5883L compass;

const char* ssid     = "*";         // The SSID (name) of the Wi-Fi network you want to connect to
const char* password = "*";     // The password of the Wi-Fi network

WiFiUDP Udp; // A UDP instance to let us send and receive packets over UDP
const IPAddress outIp(192, 168, 0, 234); // remote IP of your computer
//const IPAddress outIp(172,18,96,53); // remote IP of your computer @kask
//const IPAddress outIp(192,168,0,190); // remote IP of your computer @kask

const unsigned int outPort = 4559; // remote port to receive OSC
const unsigned int localPort = 8888; // local port to listen for OSC packets (actually not used for sending)

void setup() {
  Serial.begin(115200);         // Start the Serial communication to send messages to the computer

  WiFi.begin(ssid, password);             // Connect to the network
  Serial.print("Connecting to ");
  Serial.print(ssid); Serial.println(" ...");

  int i = 0;
  while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
    Serial.print(++i); Serial.print(' ');

  Serial.println("Connection established!");
  Serial.print("IP address:\t");
  Serial.println(WiFi.localIP());         // Send the IP address of the ESP8266 to the computer

  Serial.println("Starting UDP");
  Serial.print("Local port: ");
#ifdef ESP32

  // Initialize HMC5883L
  Serial.println("Initialize HMC5883L");
  while (!compass.begin())
    Serial.println("Could not find a valid HMC5883L sensor, check wiring!");



void checkSettings()
  Serial.print("Selected range: ");

  switch (compass.getRange())
    case HMC5883L_RANGE_0_88GA: Serial.println("0.88 Ga"); break;
    case HMC5883L_RANGE_1_3GA:  Serial.println("1.3 Ga"); break;
    case HMC5883L_RANGE_1_9GA:  Serial.println("1.9 Ga"); break;
    case HMC5883L_RANGE_2_5GA:  Serial.println("2.5 Ga"); break;
    case HMC5883L_RANGE_4GA:    Serial.println("4 Ga"); break;
    case HMC5883L_RANGE_4_7GA:  Serial.println("4.7 Ga"); break;
    case HMC5883L_RANGE_5_6GA:  Serial.println("5.6 Ga"); break;
    case HMC5883L_RANGE_8_1GA:  Serial.println("8.1 Ga"); break;
    default: Serial.println("Bad range!");

  Serial.print("Selected Measurement Mode: ");
  switch (compass.getMeasurementMode())
    case HMC5883L_IDLE: Serial.println("Idle mode"); break;
    case HMC5883L_SINGLE:  Serial.println("Single-Measurement"); break;
    case HMC5883L_CONTINOUS:  Serial.println("Continuous-Measurement"); break;
    default: Serial.println("Bad mode!");

  Serial.print("Selected Data Rate: ");
  switch (compass.getDataRate())
    case HMC5883L_DATARATE_0_75_HZ: Serial.println("0.75 Hz"); break;
    case HMC5883L_DATARATE_1_5HZ:  Serial.println("1.5 Hz"); break;
    case HMC5883L_DATARATE_3HZ:  Serial.println("3 Hz"); break;
    case HMC5883L_DATARATE_7_5HZ: Serial.println("7.5 Hz"); break;
    case HMC5883L_DATARATE_15HZ:  Serial.println("15 Hz"); break;
    case HMC5883L_DATARATE_30HZ: Serial.println("30 Hz"); break;
    case HMC5883L_DATARATE_75HZ:  Serial.println("75 Hz"); break;
    default: Serial.println("Bad data rate!");

  Serial.print("Selected number of samples: ");
  switch (compass.getSamples())
    case HMC5883L_SAMPLES_1: Serial.println("1"); break;
    case HMC5883L_SAMPLES_2: Serial.println("2"); break;
    case HMC5883L_SAMPLES_4: Serial.println("4"); break;
    case HMC5883L_SAMPLES_8: Serial.println("8"); break;
    default: Serial.println("Bad number of samples!");


void loop() {

  Vector raw = compass.readRaw();
  Vector norm = compass.readNormalize();

  int Xmap = norm.XAxis;
  float XmapDecimal = (map(norm.XAxis, -500, 600, 0, 1000));
  float XmapDecimalCorrect = XmapDecimal / 1000;

  //Serial.print(" Xraw = ");
  //Serial.print(" XRaw is now =");
  // Serial.print(XmapRound);
  //Serial.print(" Yraw = ");
  //Serial.print(" Zraw = ");
  Serial.print(" Xnorm = ");
  //Serial.print(" Ynorm = ");
  //Serial.print(" ZNorm = ");
  OSCMessage msg("/trigger/prophet");

  // OSCMessage msg2("/test/amen");
  // msg.add(raw.YAxis);
  //msg.add(raw.ZAxis);    Udp.beginPacket(outIp, outPort);

If you go to the folder where you installed the libraries you should find a file called WiFiUdp.h. If you open it you will see that the class does not have a public function called localPort. So the error message is correct.

Open an example (File -> Examples -> WiFi101) from the library with UDP in the name e.g. WiFiUdpSendReceiveString.

Here you can see that the example uses a variable unsigned int localPort = 2390; to initialize the UDP class Udp.begin(localPort); but the port is past on in the library and there is no public function to retrieve it. Since "you" set the port and therefore know it there is no obvious need for the class to have it.

Since the affected line in your code is just a serialPrint. Just comment the line out and see if there are more issues. Maybe you used a completly different library before.

#include <WiFi.h>
#include <WiFiUdp.h>
#include <WiFiClient.h>
#include <WiFiServer.h>

it includes the library for Arduino WiFi Shield which you can't use on esp8266

Found the library issue! removed it and putted the correct one.

Thanks for pointing it out!! :smiley:

Found the library issue! removed it and putted the correct one.

Thanks for pointing it out!! :smiley:

it would be enough to remove the includes