Connecting Wemos D1 mini to wifi
Last time we looked at Getting started with the Wemos D1 mini. The natural follow up from that is to connect to wifi.
For this, in the Arduino IDE, create a new sketch. This will start you up with the
loop() methods. Above this add
#include <ESP8266WiFi.h> to add the wifi client for the ESP8266 chip which the Wemos D1 mini is based on.
Below this, lets set things up:
// Wifi creds. WiFiClient espClient; const char* ssid = "your wifi ssid"; const char* password = "YourWifiPa55word!";
This block first defines the wifi client, then sets your ssid and wifi password to two constants.
Now within the
setup() method you can add these two lines to first set the mode of the wifi client, then connect to wifi.
WiFi.mode(WIFI_STA); WiFi.begin(ssid, password);
It’s as simple as that!