-
Notifications
You must be signed in to change notification settings - Fork 14
/
03_wifi.js
26 lines (22 loc) · 685 Bytes
/
03_wifi.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var wifi = require("Wifi");
var WIFI_SSID = "<YOUR SSID>";
var WIFI_OPTIONS = {
password : "<YOUR PASSWORD>"
};
wifi.stopAP(); // disable Wi-Fi AP
wifi.connect(WIFI_SSID, WIFI_OPTIONS, function(err) {
if (err) {
console.log("ERROR: Connection failed, error: " + err);
} else {
console.log("INFO: Successfully connected");
console.log(wifi.getStatus());
console.log(wifi.getIP());
// set hostname and make the NodeMCU available
// through espruino.local (ping or for using the
// Espruino IDE over Wi-Fi
wifi.setHostname("espruino");
// save the Wi-Fi settings and they'll be used
// automatically at power-up.
wifi.save();
}
});