How to set host name on Pico W?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
Jibun no kage
Posts: 144
Joined: Mon Jul 25, 2022 9:45 pm

How to set host name on Pico W?

Post by Jibun no kage » Wed Jul 27, 2022 1:30 pm

How to set host name on Pico W?

If theInterface is my network.WLAN object, neither of the following work, they both return 'unknown config param' exception...

theInterface.config(hostname=theHost)
theInterface.config(dhcp_hostname=theHost)

I create theHost string as 'picoXXXXXX' where I get the last octets of the MAC address. This quite frustrating that what is implemented in the ESP8266 and ESP32 support under MicroPython apparently is not implemented for RPi Pico? Please tell me that is not the case?

Nor can you query for the host name from the config method. I need the host name set, because I am going to use MQTT communication and using the ip address in MQTT topics as subscribed is just a horrible hack. What happens when the environment changes for example.

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: How to set host name on Pico W?

Post by scruss » Wed Jul 27, 2022 3:20 pm

You can't: Can't set hostname in AP mode · Issue #8906 · micropython/micropython

There's an open PR to fix this, but it hasn't yet been accepted.

(previously)

Jibun no kage
Posts: 144
Joined: Mon Jul 25, 2022 9:45 pm

Re: How to set host name on Pico W?

Post by Jibun no kage » Wed Jul 27, 2022 8:35 pm

Bummer, ok, so I guess I have to live with my mashed up host name, until this is addressed.

Post Reply