[GH-ISSUE #1234] Placing Parameter value to a variable. #1055

Open
opened 2026-02-28 01:28:19 +03:00 by kerem · 12 comments
Owner

Originally created by @hitbyatruck on GitHub (Mar 29, 2021).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1234

I'm having some problems, creating a custom parameter to store an IP address on a variable on WiFiManager.

After following the examples, I get the Custom parameter to be printed by WiFiManager itself on the serial monitor, but once I try to use it as an IP address on the code or do a Serial.println I never get anything displayed.

I've tried getting and int from the custom parameter field to a variable and couldn't ever find a way to convert the char to an int accordingly as well.

I can't find a way to get an ip address from a custom parameter and save it as and IPaddress type variable.

Any help would be very appreciated.

Thank you.

Originally created by @hitbyatruck on GitHub (Mar 29, 2021). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1234 I'm having some problems, creating a custom parameter to store an IP address on a variable on WiFiManager. After following the examples, I get the Custom parameter to be printed by WiFiManager itself on the serial monitor, but once I try to use it as an IP address on the code or do a Serial.println I never get anything displayed. I've tried getting and int from the custom parameter field to a variable and couldn't ever find a way to convert the char to an int accordingly as well. I can't find a way to get an ip address from a custom parameter and save it as and IPaddress type variable. Any help would be very appreciated. Thank you.
Author
Owner

@tablatronix commented on GitHub (Mar 29, 2021):

Are you using the example that was made for this ?
https://github.com/tzapu/WiFiManager/blob/master/examples/AutoConnect/AutoConnectWithFSParametersAndCustomIP/AutoConnectWithFSParametersAndCustomIP.ino

<!-- gh-comment-id:809669640 --> @tablatronix commented on GitHub (Mar 29, 2021): Are you using the example that was made for this ? https://github.com/tzapu/WiFiManager/blob/master/examples/AutoConnect/AutoConnectWithFSParametersAndCustomIP/AutoConnectWithFSParametersAndCustomIP.ino
Author
Owner

@hitbyatruck commented on GitHub (Mar 29, 2021):

@tablatronix Thanks for your reply.

Actually as the Ip adress I need is for a connection to a ATEM mini pro, I was hoping to be able to just input the ATEM address on a variable of type IPAddress and pass it to the library that handles the connection.

As I was able to see the WiFiManager print out the values inserted on the Custom Parameter box, I assumed I could manipulate the value and pass it directly to the function which handles the connection with the ATEM mini pro.

I don't need the ESP32 to have a custom IP address, since the idea is to have 4 ESP32 Tally lights connected to the same wifi network, which makes no difference if they all get the IP Address from DHCP.

But as the ATEM mini pro connection library needs to have the ATEM mini pro IP address and since, in most cases, people use it with a dynamic IP Address, I need to be able to have the user insert their hardware IP address, inside the same network.

So the procedure would be:

1 - connect to each Tally light and configure the Wifi network being used.
2 - Include the IP Address of the ATEM mini pro, which should be connected by itself to the same Wifi network mentioned above.
3 - Pass the custom parameter with the ATEM mini pro IP address to a variable of type IPAddress in order for the M5Stick library to be able to establish a connection with the ATEM mini pro.

I have everything working correctly, except for the Custom parameter being passed to the variable.

So, just to clear a doubt I had with that example: I'll always need to use SPIFFS, in order to be able to use Custom Parameters or I can pass it directly to a variable?

<!-- gh-comment-id:809731924 --> @hitbyatruck commented on GitHub (Mar 29, 2021): @tablatronix Thanks for your reply. Actually as the Ip adress I need is for a connection to a ATEM mini pro, I was hoping to be able to just input the ATEM address on a variable of type IPAddress and pass it to the library that handles the connection. As I was able to see the WiFiManager print out the values inserted on the Custom Parameter box, I assumed I could manipulate the value and pass it directly to the function which handles the connection with the ATEM mini pro. I don't need the ESP32 to have a custom IP address, since the idea is to have 4 ESP32 Tally lights connected to the same wifi network, which makes no difference if they all get the IP Address from DHCP. But as the ATEM mini pro connection library needs to have the ATEM mini pro IP address and since, in most cases, people use it with a dynamic IP Address, I need to be able to have the user insert their hardware IP address, inside the same network. So the procedure would be: 1 - connect to each Tally light and configure the Wifi network being used. 2 - Include the IP Address of the ATEM mini pro, which should be connected by itself to the same Wifi network mentioned above. 3 - Pass the custom parameter with the ATEM mini pro IP address to a variable of type IPAddress in order for the M5Stick library to be able to establish a connection with the ATEM mini pro. I have everything working correctly, except for the Custom parameter being passed to the variable. So, just to clear a doubt I had with that example: I'll always need to use SPIFFS, in order to be able to use Custom Parameters or I can pass it directly to a variable?
Author
Owner

@tablatronix commented on GitHub (Mar 29, 2021):

That is what the example does..

WiFiManagerParameter custom_mqtt_server("server", "mqtt server", mqtt_server, 40);

If you need to cast to ip address there are ways to do it, it has nothing to do with wm

<!-- gh-comment-id:809795314 --> @tablatronix commented on GitHub (Mar 29, 2021): That is what the example does.. WiFiManagerParameter custom_mqtt_server("server", "mqtt server", mqtt_server, 40); If you need to cast to ip address there are ways to do it, it has nothing to do with wm
Author
Owner

@hitbyatruck commented on GitHub (Mar 29, 2021):

I followed that line of code but kept getting errors.

`

WiFiManagerParameter custom_ATEMip("ATEMIP", "ATEM ip", ATEMip, 40);
WifiManager.addParameter(&custom_ATEMip);

IPAddress switcherIp(192, 168, 1, 91); //this should be the ATEMip variable

`
When trying to divide the 4 numbers by their own variables, which I tried in despair, trying to get the ip address from the custom parameters in 4 different variables to see if I was able to handle each number as an int, I kept getting an error saying something like "invalid conversion from 'const char*' to 'char' [-fpermissive]".

I'm away from my work PC right now, so I tried to replicate part of the code above, which is the part I'm struggling with and can't find a way out.

I can't understand the type of variable I get from ATEMip variable above and how to cast it to the switcherIp variable in order to make it work.

<!-- gh-comment-id:809800589 --> @hitbyatruck commented on GitHub (Mar 29, 2021): I followed that line of code but kept getting errors. ` ``` WiFiManagerParameter custom_ATEMip("ATEMIP", "ATEM ip", ATEMip, 40); WifiManager.addParameter(&custom_ATEMip); IPAddress switcherIp(192, 168, 1, 91); //this should be the ATEMip variable ``` ` When trying to divide the 4 numbers by their own variables, which I tried in despair, trying to get the ip address from the custom parameters in 4 different variables to see if I was able to handle each number as an int, I kept getting an error saying something like "invalid conversion from 'const char*' to 'char' [-fpermissive]". I'm away from my work PC right now, so I tried to replicate part of the code above, which is the part I'm struggling with and can't find a way out. I can't understand the type of variable I get from ATEMip variable above and how to cast it to the switcherIp variable in order to make it work.
Author
Owner

@tablatronix commented on GitHub (Mar 30, 2021):

IPAddress(255, 255, 255, 255)

there is also helpers for strings
switcherIp.fromString(const char*);

wifimanager also has a helper
optionalIPFromString()

<!-- gh-comment-id:809825340 --> @tablatronix commented on GitHub (Mar 30, 2021): IPAddress(255, 255, 255, 255) there is also helpers for strings switcherIp.fromString(const char*); wifimanager also has a helper optionalIPFromString()
Author
Owner

@hitbyatruck commented on GitHub (Mar 30, 2021):

Will I need something like:

ATEMip = custom_ATEMip.getValue();

in order to get the ip address on the switchIp variable?

<!-- gh-comment-id:809840764 --> @hitbyatruck commented on GitHub (Mar 30, 2021): Will I need something like: `ATEMip = custom_ATEMip.getValue();` in order to get the ip address on the switchIp variable?
Author
Owner

@tablatronix commented on GitHub (Mar 30, 2021):

well you need to get it and save it somewhere yeah

<!-- gh-comment-id:809843413 --> @tablatronix commented on GitHub (Mar 30, 2021): well you need to get it and save it somewhere yeah
Author
Owner

@hitbyatruck commented on GitHub (Mar 30, 2021):

@tablatronix Thank you so much for your help. I'm gonna try to avoid using SPIFFS and ask for the ATEMip address on each connect, to force the request for the user to input the address on each connect, which may suit my needs better at this time.

<!-- gh-comment-id:810114818 --> @hitbyatruck commented on GitHub (Mar 30, 2021): @tablatronix Thank you so much for your help. I'm gonna try to avoid using SPIFFS and ask for the ATEMip address on each connect, to force the request for the user to input the address on each connect, which may suit my needs better at this time.
Author
Owner

@tablatronix commented on GitHub (Mar 31, 2021):

Just use the params fs example and save your ip to flash or spiffs. Then read it on boot and convert to ipaddress and pass to your application

post your code to a forum or something and you will get solutions for what you cannot get working

<!-- gh-comment-id:810686682 --> @tablatronix commented on GitHub (Mar 31, 2021): Just use the params fs example and save your ip to flash or spiffs. Then read it on boot and convert to ipaddress and pass to your application post your code to a forum or something and you will get solutions for what you cannot get working
Author
Owner

@hitbyatruck commented on GitHub (Mar 31, 2021):

I don't need to store the ip address on a permanent basis at this point. It may be suitable in further iterations of the program.

For now I'm only trying to accomplish this as in the code below, which has not been very sucessfull so far

//WiFiManager, Local intialization. Once its business is done, there is no need to keep it around
  WiFiManager wm;

  //reset settings - wipe credentials for testing
  //wm.resetSettings();

  
  WiFiManagerParameter custom_ATEM_ip("ATEMip" , "ATEM ip" , ATEM_ip, 40);
  wm.addParameter(&custom_ATEM_ip);
  

  //IPAddress switcherIp(192, 168, 1, 91); //This line works. But want to not hard code the ip address for the ATEM mini pro
  IPAddress switcherIp.fromString(ATEM_ip);
  AtemSwitcher.begin(switcherIp);
  AtemSwitcher.serialOutput(0x80);
  AtemSwitcher.connect();
<!-- gh-comment-id:810721002 --> @hitbyatruck commented on GitHub (Mar 31, 2021): I don't need to store the ip address on a permanent basis at this point. It may be suitable in further iterations of the program. For now I'm only trying to accomplish this as in the code below, which has not been very sucessfull so far ``` //WiFiManager, Local intialization. Once its business is done, there is no need to keep it around WiFiManager wm; //reset settings - wipe credentials for testing //wm.resetSettings(); WiFiManagerParameter custom_ATEM_ip("ATEMip" , "ATEM ip" , ATEM_ip, 40); wm.addParameter(&custom_ATEM_ip); //IPAddress switcherIp(192, 168, 1, 91); //This line works. But want to not hard code the ip address for the ATEM mini pro IPAddress switcherIp.fromString(ATEM_ip); AtemSwitcher.begin(switcherIp); AtemSwitcher.serialOutput(0x80); AtemSwitcher.connect(); ```
Author
Owner

@tablatronix commented on GitHub (Mar 31, 2021):

IPAddress switcherIp.fromString(ATEM_ip);
should work IF you are getvalue on ATEM_ip and you might have to memcopy it since the param is a ref.

<!-- gh-comment-id:810744106 --> @tablatronix commented on GitHub (Mar 31, 2021): IPAddress switcherIp.fromString(ATEM_ip); should work IF you are getvalue on ATEM_ip and you might have to memcopy it since the param is a ref.
Author
Owner

@tablatronix commented on GitHub (Mar 31, 2021):

see examples
strcpy(mqtt_server, custom_mqtt_server.getValue());

<!-- gh-comment-id:810744849 --> @tablatronix commented on GitHub (Mar 31, 2021): see examples strcpy(mqtt_server, custom_mqtt_server.getValue());
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#1055
No description provided.