ESP Hostname Change

Use this section to discuss your embedded Flowcode projects.
nmjb18
Posts: 22
http://meble-kuchenne.info.pl
Joined: Mon Apr 19, 2021 4:47 pm
Has thanked: 10 times
Been thanked: 1 time

Flowcode v10 ESP Hostname Change

Post 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

Xbiotec
Posts: 200
Joined: Thu Sep 23, 2021 3:44 pm
Location: France
Has thanked: 32 times
Been thanked: 24 times

Re: ESP Hostname Change

Post by Xbiotec »

hi,
I did it 1 year ago, I will check if I can find how I did it, I forgot !!
Seb

nmjb18
Posts: 22
Joined: Mon Apr 19, 2021 4:47 pm
Has thanked: 10 times
Been thanked: 1 time

Re: ESP Hostname Change

Post by nmjb18 »

Thank you, it would be much apriciated, still stuck on this one!

Steve-Matrix
Matrix Staff
Posts: 1384
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 184 times
Been thanked: 322 times

Re: ESP Hostname Change

Post 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.

nmjb18
Posts: 22
Joined: Mon Apr 19, 2021 4:47 pm
Has thanked: 10 times
Been thanked: 1 time

Re: ESP Hostname Change

Post 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.

BenR
Matrix Staff
Posts: 1895
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 491 times
Been thanked: 664 times

Re: ESP Hostname Change

Post 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());

nmjb18
Posts: 22
Joined: Mon Apr 19, 2021 4:47 pm
Has thanked: 10 times
Been thanked: 1 time

Re: ESP Hostname Change

Post 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.

medelec35
Matrix Staff
Posts: 1610
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 567 times
Been thanked: 531 times

Re: ESP Hostname Change

Post 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.
Martin

BenR
Matrix Staff
Posts: 1895
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 491 times
Been thanked: 664 times

Re: ESP Hostname Change

Post 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.

nmjb18
Posts: 22
Joined: Mon Apr 19, 2021 4:47 pm
Has thanked: 10 times
Been thanked: 1 time

Re: ESP Hostname Change

Post 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".

Post Reply