My recent fascination with the Wemos D1 Mini (ESP8266) devices has been very enlightening. These devices are very capable and there is so much reusable code out there for them that programming them is made very easy.
One thing that I’ve recently been trying to figure out is how to change the default hostname when they join a WIFI network, by default they join as ESP_xxxxxx where the x’s are the last 6 characters of the MAC address of the device. This isn’t very useful when you have 3 or 4 of these. I figured there must be a way of changing this and there is.
It took quite a bit of digging and picking bits of code from many discussions on many forums. So, I’ll pull it all together here in hopes you’ll find this page and find it useful.
So, how is it done? Pretty simple, the following bits of code need to be added to your code and I’ll include some functioning code that I currently use. See the comments in the code for where these should go, and look at my full script.
This is my full code for my Wemos D1 mini + DHT22 + Thingspeak
Please feel free to use the above code and share. This code was taken from a number of sources and combined to do what I needed it for.