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
ESP Hostname Change
-
- Posts: 22
- http://meble-kuchenne.info.pl
- Joined: Mon Apr 19, 2021 4:47 pm
- Has thanked: 10 times
- Been thanked: 1 time
-
- Matrix Staff
- Posts: 1384
- Joined: Sat Dec 05, 2020 10:32 am
- Has thanked: 184 times
- Been thanked: 322 times
Re: ESP Hostname Change
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:
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.
Code: Select all
tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA, "my_host_name");
-
- Matrix Staff
- Posts: 1895
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 491 times
- Been thanked: 664 times
Re: ESP Hostname Change
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.
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());
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: ESP Hostname Change
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.
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.
-
- Matrix Staff
- Posts: 1610
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 567 times
- Been thanked: 531 times
Re: ESP Hostname Change
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.
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.
Martin
-
- Matrix Staff
- Posts: 1895
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 491 times
- Been thanked: 664 times
Re: ESP Hostname Change
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: ESP Hostname Change
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".
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".