Page 1 of 2

ESP Hostname Change

Posted: Wed Nov 08, 2023 8:39 pm
by nmjb18
Hi,

Does anyone know how to change the hostname of an ESP32? I have more than one ESP-VROOM-32 modules on a network and as the default hostname is "espressif" it's not possible to tell between them on my router!

Many thanks

Re: ESP Hostname Change

Posted: Sat Nov 18, 2023 6:33 am
by lucibel
hi,
I did it 1 year ago, I will check if I can find how I did it, I forgot !!

Re: ESP Hostname Change

Posted: Sat Nov 18, 2023 11:08 pm
by nmjb18
Thank you, it would be much apriciated, still stuck on this one!

Re: ESP Hostname Change

Posted: Mon Nov 20, 2023 10:59 am
by Steve-Matrix
I'm not sure we support this within Flowcode directly, but you could try adding your own custom C code to your project to do this. I've just done a search and it looks like this is the code you need to use:

Code: Select all

tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA, "my_host_name");
I'm not too familiar with the ESP32 and I don't have one to hand to test, but this might do what you need.

Re: ESP Hostname Change

Posted: Tue Dec 12, 2023 7:12 pm
by nmjb18
Hi Steve,

I have tried the code you have advised and researched the documentation supporting the ESP32 and I a failing to get the host name to change.

Re: ESP Hostname Change

Posted: Wed Dec 13, 2023 9:21 am
by BenR
Hello,

Here is some code you can try. You need to call it before you initialise the wifi. I'll also look into the problem for you and see if it's something we can add into the component.

Code: Select all

String hostname = "ESP32 Humidity Node";
WiFi.setHostname(hostname.c_str());

Re: ESP Hostname Change

Posted: Wed Dec 13, 2023 11:44 am
by nmjb18
Hi Ben,

Thank you, I will give it a go. For what it's worth, I think this would be useful to add into the component. FC makes it so easy to use the ESP32, only for the projects to become difficult to use if more than one set of hardware in on the same network.

Cheers.

Re: ESP Hostname Change

Posted: Wed Dec 13, 2023 11:53 am
by medelec35
Changing name is the best way of course, so that is the first option
Alternatively there is free software called WNetWatcher.
It will show you all the connected devices to your WiFi.
Disconnect one of the ESP32's, then on the next pass it will have a red x next to the device that is no longer connected to WiFi

At least you will then know the IP address of the disconnected device.

Re: ESP Hostname Change

Posted: Thu Dec 14, 2023 10:42 am
by BenR
Right I've had a good play and so far I've been unable to get a code change to stick and actually work. Some good info here as to the why.

https://www.esp32.com/viewtopic.php?t=9032

So the name your router or device scanner is showing is likely tied to the MAC address and just shows the vendor.

For now Martin's method of recoring the IP address is probably the best route.

You can however change the network DHCP name but the router may not be capable of showing this.

One way to do this is as follows.

In your flowcode project folder there is a build folder with the sane name as the Flowcode project. Inside this folder you will find a file named menuconfig.bat. Double click this file and it will open the configuration tool. Once in here using cursor keys to navigate, go to Component Config and then select LWIP. The top setting "local netif hostname" should allow you to specify the device name.

Press enter to edit and once you're done hit enter again and then press s follwed by enter to save the setting. Press escape a few times to exit. Now rebuild form Flowcode and hopefully the device name should now be different.

Re: ESP Hostname Change

Posted: Thu Dec 14, 2023 2:34 pm
by nmjb18
HI Ben,

Thanks for spending some of your time on this, I am sure you have 101 other things to do. I will try changing the local hostname in the file you identify and report back.

For you interest: My router shows both the Host name and vendor (along with MAC and IP) the hostname and vendor are currently one and the same, and stays this way unless I have more than one ESP32 on the network and then the hostname changes to "?" and, as would be expected, the vendor name stays as "expressif".