Created a "variableInput.h" file for editing variables in one place; instead of searching multiple lines of code, to find lines needing editing.

//   variableInput.h 
//   User defineable variables; one location for editing variables

// Replace with your network details  
#define host = "esp32"
#define ssid = "YOURSSID"
#define password = "YOURPASSWORD"

//NTP Time Servers
#define udpAddress1 = ""  //NTP Time server
#define udpAddress2 = ""  //NTP Time server

//publicIP accessiable over Internet with Port Forwarding; know the risks!!!
//WAN IP Address.  Or use LAN IP Address --same as server ip; no Internet access.
#define publicIP = "YOURPUBLICIP"
#define LISTEN_PORT  8030  //default listening Port 80 for "GET" requests.

//Graphing requires "FREE" "ThingSpeak.com" account..  
//Enter "ThingSpeak.com" data here....
//iframes of graphed data are available from "ThingSpeak.com."
#define myChannelNumber = 123456 
#define myWriteAPIKey = "E12345"

//FTP Credentials
#define ftpUser = "FTPUSER"
#define ftpPassword = "FTPPASSWORD" 

//setting the addresses 
#define ip(10,0,0,200);
#define gateway(10,0,0,1);
#define subnet(255, 255, 255, 0);
#define dns(10,0,0,1);

//Restricted access to client ip list.
#define Restricted = "/ANYNAME" 

//OTA Credentials
//default username: USERNAME
//default password: PASSWORD

// "setting the addresses" is the part that I do not understand.

Segment of related code from "wifi_Start" function:

//setting the addresses
IPAddress ip;
IPAddress gateway;
IPAddress subnet;
IPAddress dns;

Is there a solution?


  • 1
    it is unclear what you are asking ... you included a badly formatted code listing, but it is unclear how it relates to your question ... please explain in more detail what you are trying to do ... also, please format the code listing
    – jsotola
    Commented Sep 28, 2019 at 23:33
  • constants .h in my project github.com/jandrassy/Regulator/blob/master/Regulator/consts.h
    – Juraj
    Commented Sep 29, 2019 at 6:13
  • you should not use #define for constants. #defines are directives for the preprocessor
    – Juraj
    Commented Sep 30, 2019 at 14:37

2 Answers 2


You are not using #define correctly. The syntax is #define {name} {value}. There is no = between name and value so for your IP address lines you want #define myIp ip(192, 168, 1, 11)

  • Ended up with "#define ip {10,0,0,11 }" in the "variableInput.h" file and "IPAddress ip;" in the wifi-Start function. Appreciate the help!
    Commented Sep 29, 2019 at 21:48

Here's how I do it (for an Arduino that connects to my Mosquitto server) using wired ethernet (WiFi works the same way):

#include <Ethernet.h>
#include <PubSubClient.h>
EthernetClient ethClient;
PubSubClient client(ethClient);

byte mac[]    = {
  0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe
IPAddress ip(192, 168, 1, 75);
IPAddress server(192, 168, 1, 11);
void setup() {

  client.setServer(server, 1883);

  Ethernet.begin(mac, ip);

  • I understand this is the usual, useage; I need to have variable for "".
    Commented Sep 28, 2019 at 23:57
  • 1
    You can build an IPAddress(0,0,0,0) struct and assign a value to it. You'll need to take a dotted decimal address vvv.xxx.yyy.zzz and multiply vvv*256^3+xxx*256^2+yyy*256^1+zzz*256^0 to get the value to assign.
    – Dougie
    Commented Sep 29, 2019 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.