user-1: I've been reading a lot on the ESP8266, but still my understanding is shaky. I have the Arduino IDE running on a PC, which uses wires to connect to the ESP8266 via a USB device (Device Manager > Ports (COM & LPT) > Silicon Labs CP210x USB to UART Bridge). This is how I uploaded a simple sketch to the ESP8266.
It works and has been installed in the wall. I'm happy and relieved to complete the project... except for one small thing: I noticed that it shows up on WiFi. I can connect to it without a password, with a "Limited" connection. After that I'm lost, but I wonder if someone who knows what they are doing can use this unsecured connection to hack my install. I'd like to disable the WiFi, if possible, since I'm not using it.
The worst part is my learning curve now starts over. I thought that when my sketch gets uploaded, it replaces the original firmware. Now "firmware" is an elusive concept. I keep thinking that it shows up on WiFi because of something running in firmware. My sketch hasn't any code for WiFi. What am I missing/do I have wrong?

user-1: You control WiFi using wifi.setmode(). 
ESP8266's WiFi is very versatil. You can be a client and/or an access point. You can get your IP from DHCP or static.
Per default, ESP8266 start in STATIONAP mode (as client and access point).
This is the pertinent part from the official page
wifi.setmode()
Configures the WiFi mode to use. NodeMCU can run in one of four WiFi modes:

Station mode, where the NodeMCU device joins an existing network
Access point (AP) mode, where it creates its own network that others can join
Station + AP mode, where it both creates its own network while at the same time being joined to another existing network
WiFi off 

When using the combined Station + AP mode, the same channel will be used for both networks as the radio can only listen on a single channel.
Note
WiFi configuration will be retained until changed even if device is turned off.
Syntax
wifi.setmode(mode[, save])

Parameters
mode value should be one of
    wifi.STATION for when the device is connected to a WiFi router. This is often done to give the device access to the Internet.
    wifi.SOFTAP for when the device is acting only as an access point. This will allow you to see the device in the list of WiFi networks (unless you hide the SSID, of course). In this mode your computer can connect to the device, creating a local area network. Unless you change the value, the NodeMCU device will be given a local IP address of 192.168.4.1 and assign your computer the next available IP address, such as 192.168.4.2.
    wifi.STATIONAP is the combination of wifi.STATION and wifi.SOFTAP. It allows you to create a local WiFi connection and connect to another WiFi router.
    wifi.NULLMODE changing WiFi mode to NULL_MODE will put wifi into a low power state similar to MODEM_SLEEP, provided wifi.nullmodesleep(false) has not been called.

save choose whether or not to save wifi mode to flash
    true WiFi mode configuration will be retained through power cycle. (Default)
    false WiFi mode configuration will not be retained through power cycle.

Returns
current mode after setup
Example
wifi.setmode(wifi.STATION);

See also
wifi.getmode() wifi.getdefaultmode()

user69543: Many esp8266 devices by default start in (WIFI_AP) SoftAP mode, and will appear as a wifi network access point, waiting for stations to connect.
User code in any sketch, should explicitly set wifi to the appropriate mode. If you do not need wifi, set the wifi mode off. To do this with the Arduino IDE, an esp8266 must run a sketch at least once that includes the wifi class to use its .mode() method.
#include <ESP8266WiFi.h>

void setup() {
   Serial.begin(115200);
   WiFi.mode(WIFI_OFF);
   if (WiFi.getMode() == WIFI_OFF)
      Serial.println(F("\nWifi mode is WIFI_OFF, until it is explicitly changed"));
}

The mode setting persists across power on and restart/reset cycles, until user code specifies a different mode. So once run on the esp8266, the all the lines above (except setup()) could optionally be removed from subsequent sketches uploaded to the esp8266, and the wifi will remain off.
Firmware is lower-level software that runs between the hardware and your higher-level sketch. Many esp8266 came with Espressif firmware and a sketch installed.
If you are concerned about energy consumption, investigate waking up the esp8266 with the radio disabled, eg.
ESP.deepSleepInstant (microseconds, WAKE_RF_DISABLED);


user27050: This is the best solution I have found so far (source: GitHub gist)
The two functions below are all you need to toggle your WiFi chip. The huge advantage of using these is that they work without having to invoke an ESP.deepsleep() call. 
Mind you, if you have already done an ESP.deepsleep(time, WAKE_RF_DISABLED) that means that your WiFi chip has been disabled altogether, and calling WiFiOn() will NOT be able to toggle it back ON. In this case you MUST do ESP.deepsleep(time, WAKE_RF_DEFAULT). But once you WiFi chip has been re-enabled, you can call WiFiOn() and WiFiOff() as many times as you please, they will work fine.
extern "C" {
    #include "user_interface.h"  // Required for wifi_station_connect() to work
}

#include <Arduino.h>
#include <ESP8266WiFi.h>

#define FPM_SLEEP_MAX_TIME 0xFFFFFFF

void WiFiOn();
void WiFiOff();

//------------------------------------------------------------------------------

void setup() {

    WiFiOn();
    delay(5000);
    WiFiOff();
    delay(5000);
    ESP.deepSleep(1e6 * 10, WAKE_RF_DEFAULT); // sleep 10 seconds

}

void loop() {
    ;
}
//------------------------------------------------------------------------------

void WiFiOn() {

    wifi_fpm_do_wakeup();
    wifi_fpm_close();

    //Serial.println("Reconnecting");
    wifi_set_opmode(STATION_MODE);
    wifi_station_connect();
}


void WiFiOff() {

    //Serial.println("diconnecting client and wifi");
    //client.disconnect();
    wifi_station_disconnect();
    wifi_set_opmode(NULL_MODE);
    wifi_set_sleep_type(MODEM_SLEEP_T);
    wifi_fpm_open();
    wifi_fpm_do_sleep(FPM_SLEEP_MAX_TIME);

}


user1576: 
To turn of the WiFi add the WiFi library and use WiFi.forceSleepBegin();

Firmware is the program/sketch that controls a MicroController Unit aka MCU (and in this case a Arduino).
Best explanation I know is here: https://en.wikipedia.org/wiki/Firmware



-1: <p>I've been reading a lot on the ESP8266, but still my understanding is shaky. I have the Arduino IDE running on a PC, which uses wires to connect to the ESP8266 via a USB device (Device Manager > Ports (COM &amp; LPT) > Silicon Labs CP210x USB to UART Bridge). This is how I uploaded a simple sketch to the ESP8266.</p>

<p>It works and has been installed in the wall. I'm happy and relieved to complete the project... except for one small thing: I noticed that it shows up on WiFi. I can connect to it without a password, with a "Limited" connection. After that I'm lost, but I wonder if someone who knows what they are doing can use this unsecured connection to hack my install. I'd like to disable the WiFi, if possible, since I'm not using it.</p>

<p>The worst part is my learning curve now starts over. I thought that when my sketch gets uploaded, it replaces the original firmware. Now "firmware" is an elusive concept. I keep thinking that it shows up on WiFi because of something running in firmware. My sketch hasn't any code for WiFi. What am I missing/do I have wrong?</p>
 -1: <p>You control WiFi using <code>wifi.setmode()</code>. </p>

<p>ESP8266's WiFi is very versatil. You can be a client and/or an access point. You can get your IP from DHCP or static.</p>

<p>Per default, ESP8266 start in STATIONAP mode (as client and access point).</p>

<p>This is the pertinent part from the official <a href="https://nodemcu.readthedocs.io/en/master/en/modules/wifi/#wifisetmode" rel="nofollow noreferrer">page</a></p>

<p><strong>wifi.setmode()</strong></p>

<p>Configures the WiFi mode to use. NodeMCU can run in one of four WiFi modes:</p>

<ul>
<li><p>Station mode, where the NodeMCU device joins an existing network</p></li>
<li><p>Access point (AP) mode, where it creates its own network that others can join</p></li>
<li><p>Station + AP mode, where it both creates its own network while at the same time being joined to another existing network</p></li>
<li><p><strong>WiFi off</strong> </p></li>
</ul>

<p>When using the combined Station + AP mode, the same channel will be used for both networks as the radio can only listen on a single channel.</p>

<p><strong>Note</strong></p>

<p>WiFi configuration will be retained until changed even if device is turned off.</p>

<p><strong>Syntax</strong></p>

<pre><code>wifi.setmode(mode[, save])
</code></pre>

<p><strong>Parameters</strong></p>

<pre><code>mode value should be one of
    wifi.STATION for when the device is connected to a WiFi router. This is often done to give the device access to the Internet.
    wifi.SOFTAP for when the device is acting only as an access point. This will allow you to see the device in the list of WiFi networks (unless you hide the SSID, of course). In this mode your computer can connect to the device, creating a local area network. Unless you change the value, the NodeMCU device will be given a local IP address of 192.168.4.1 and assign your computer the next available IP address, such as 192.168.4.2.
    wifi.STATIONAP is the combination of wifi.STATION and wifi.SOFTAP. It allows you to create a local WiFi connection and connect to another WiFi router.
    wifi.NULLMODE changing WiFi mode to NULL_MODE will put wifi into a low power state similar to MODEM_SLEEP, provided wifi.nullmodesleep(false) has not been called.

save choose whether or not to save wifi mode to flash
    true WiFi mode configuration will be retained through power cycle. (Default)
    false WiFi mode configuration will not be retained through power cycle.
</code></pre>

<p><strong>Returns</strong></p>

<p>current mode after setup</p>

<p><strong>Example</strong></p>

<pre><code>wifi.setmode(wifi.STATION);
</code></pre>

<p><strong>See also</strong></p>

<p>wifi.getmode() wifi.getdefaultmode()</p>
 69543: <p>Many esp8266 devices by default start in (WIFI_AP) SoftAP mode, and will appear as a wifi network access point, waiting for stations to connect.</p>
<p>User code in any sketch, should explicitly set wifi to the appropriate mode. If you do not need wifi, set the wifi mode off. To do this with the Arduino IDE, an esp8266 must run a sketch at least once that includes the wifi class to use its .mode() method.</p>
<pre><code>#include &lt;ESP8266WiFi.h&gt;

void setup() {
   Serial.begin(115200);
   WiFi.mode(WIFI_OFF);
   if (WiFi.getMode() == WIFI_OFF)
      Serial.println(F(&quot;\nWifi mode is WIFI_OFF, until it is explicitly changed&quot;));
}
</code></pre>
<p>The mode setting persists across power on and restart/reset cycles, until user code specifies a different mode. So once run on the esp8266, the all the lines above (except setup()) could optionally be removed from subsequent sketches uploaded to the esp8266, and the wifi will remain off.</p>
<p>Firmware is lower-level software that runs between the hardware and your higher-level sketch. Many esp8266 came with <a href="https://github.com/espressif/ESP8266_NONOS_SDK" rel="nofollow noreferrer">Espressif firmware</a> and a sketch installed.</p>
<p>If you are concerned about energy consumption, investigate waking up the esp8266 with the radio disabled, eg.</p>
<pre><code>ESP.deepSleepInstant (microseconds, WAKE_RF_DISABLED);
</code></pre>
 27050: <p>This is the best solution I have found so far (source: GitHub <a href="https://gist.github.com/chaeplin/be4d9ca41a991aa327bb" rel="nofollow noreferrer">gist</a>)</p>

<p>The two functions below are all you need to toggle your WiFi chip. The huge advantage of using these is that they work without having to invoke an <code>ESP.deepsleep()</code> call. </p>

<p>Mind you, if you have already done an <code>ESP.deepsleep(time, WAKE_RF_DISABLED)</code> that means that your WiFi chip has been disabled altogether, and calling <code>WiFiOn()</code> will NOT be able to toggle it back ON. In this case you MUST do <code>ESP.deepsleep(time, WAKE_RF_DEFAULT)</code>. But once you WiFi chip has been re-enabled, you can call <code>WiFiOn()</code> and <code>WiFiOff()</code> as many times as you please, they will work fine.</p>

<pre><code>extern "C" {
    #include "user_interface.h"  // Required for wifi_station_connect() to work
}

#include &lt;Arduino.h&gt;
#include &lt;ESP8266WiFi.h&gt;

#define FPM_SLEEP_MAX_TIME 0xFFFFFFF

void WiFiOn();
void WiFiOff();

//------------------------------------------------------------------------------

void setup() {

    WiFiOn();
    delay(5000);
    WiFiOff();
    delay(5000);
    ESP.deepSleep(1e6 * 10, WAKE_RF_DEFAULT); // sleep 10 seconds

}

void loop() {
    ;
}
//------------------------------------------------------------------------------

void WiFiOn() {

    wifi_fpm_do_wakeup();
    wifi_fpm_close();

    //Serial.println("Reconnecting");
    wifi_set_opmode(STATION_MODE);
    wifi_station_connect();
}


void WiFiOff() {

    //Serial.println("diconnecting client and wifi");
    //client.disconnect();
    wifi_station_disconnect();
    wifi_set_opmode(NULL_MODE);
    wifi_set_sleep_type(MODEM_SLEEP_T);
    wifi_fpm_open();
    wifi_fpm_do_sleep(FPM_SLEEP_MAX_TIME);

}
</code></pre>
 1576: <ol>
<li><p>To turn of the WiFi add the WiFi library and use WiFi.forceSleepBegin();</p>
</li>
<li><p>Firmware is the program/sketch that controls a MicroController Unit aka MCU (and in this case a Arduino).</p>
<p>Best explanation I know is here: <a href="https://en.wikipedia.org/wiki/Firmware" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Firmware</a></p>
</li>
</ol>
