I am running into an error whenever I try to upload to my ESP32, I get:
consts.h:12: multiple definition of `mqtt_server'; .pio\build\esp32dev\src\connections.cpp.o:C:\Users\<user>\Documents\PlatformIO\Projects\TelTestCheck/src/consts.h:12: first defined here
consts.h
//wifi login
#pragma once
#define WIFI_NETWORK "Home network"
#define WIFI_PASSWORD "DA552567"
#define WIFI_TIMEOUT_MS 20000
const double stepRotation = 3200.0;
const char* mqtt_server = "127.0.0.1";
const int mqttPort = 1883;
timeUtills.h
#ifndef timeUtils_h
#define timeUtils_h
#include <NTPClient.h>
#include <Arduino.h>
#include "connections.h"
const long gmtOffset_sec = 3600*5;
const int daylightOffset_sec = 3600;
const char* ntpServer = "pool.ntp.org";
Connections conn;
class ntpUtils{
public:
void ntpStart();
void timeKeep();
void timeIncrement();
};
#endif
connections.h
#ifndef connections_H
#define connections_H
#include <Arduino.h>
#include <WiFi.h>
#include <WiFiUdp.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>
#include "consts.h"
void callback(char* topic, byte* payload, unsigned int length);
class Connections{
String epfemValues[73][4];
void connectToWiFi();
void mqttConnect();
void loopCon();
};
#endif
I have narrowed the problem down to a file called timeUtils.h which contains an include to connections.h, if this include is removed the problem goes away but I do need the connections class. Im not sure how to fix this error
Thanks