ConnectNoEncryption

Description


In this example is shown how to connect to an unencrypted WiFi network using the WiFi Link library on the Arduino STAR OTTO.

Warning:
Use the Arduino IDE 1.8.x  and import the WiFi Link library using the Library Manager.

WiFi Link library


Hardware


Circuit


Connect the board to PC
Fronte Arduino STAR OTTO


Code


Now, modify the below sketch inserting the name of your network and after upload the code using Arduino IDE.

Note:

You can use directly the WiFi Link examples present into IDE but remember you to replace the Serial with SerialUSB.

Warning:

Use the Arduino IDE 1.8.x and check that you have already downloaded the corresponding platform (Arduino STM32F4 Boards) from the Board Manager

/*

This example connects to an unencrypted Wifi network.
Then it prints the MAC address of the board,
the IP address obtained, and other network details.

Circuit:
* Arduino Primo or STAR OTTO or Uno WiFi Developer Edition (with WiFi Link firmware running)

created 13 July 2010
by dlf (Metodo2 srl)
modified 31 May 2012
by Tom Igoe
modified 10 March 2017
by Sergio Tomasello and Andrea Cannistrá
*/

#include <WiFiLink.h>
#define Serial SerialUSB

char ssid[] = "yourNetwork"; // the name of your network
int status = WL_IDLE_STATUS; // the Wifi radio's status

void setup() {
//Initialize serial and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

//Check if communication with the wifi module has been established
if (WiFi.status() == WL_NO_WIFI_MODULE_COMM) {
Serial.println("Communication with WiFi module not established.");
while (true); // don't continue:
}

// connect to Wifi network:
WiFi.begin(ssid);
// wait 10 seconds for connection:
delay(10000);

// print out the data:
printCurrentNet();
printWifiData();
}

void loop() {
// check the network connection once every 10 seconds:
delay(10000);
printCurrentNet();
}

void printWifiData() {
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
Serial.println(ip);

// print your MAC address:
byte mac[6];
WiFi.macAddress(mac);
Serial.print("MAC address: ");
Serial.print(mac[5], HEX);
Serial.print(":");
Serial.print(mac[4], HEX);
Serial.print(":");
Serial.print(mac[3], HEX);
Serial.print(":");
Serial.print(mac[2], HEX);
Serial.print(":");
Serial.print(mac[1], HEX);
Serial.print(":");
Serial.println(mac[0], HEX);

// print your subnet mask:
IPAddress subnet = WiFi.subnetMask();
Serial.print("NetMask: ");
Serial.println(subnet);

// print your gateway address:
IPAddress gateway = WiFi.gatewayIP();
Serial.print("Gateway: ");
Serial.println(gateway);
}

void printCurrentNet() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());

// print the MAC address of the router you're attached to:
byte bssid[6];
WiFi.BSSID(bssid);
Serial.print("BSSID: ");
Serial.print(bssid[5], HEX);
Serial.print(":");
Serial.print(bssid[4], HEX);
Serial.print(":");
Serial.print(bssid[3], HEX);
Serial.print(":");
Serial.print(bssid[2], HEX);
Serial.print(":");
Serial.print(bssid[1], HEX);
Serial.print(":");
Serial.println(bssid[0], HEX);

// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.println(rssi);

// print the encryption type:
byte encryption = WiFi.encryptionType();
Serial.print("Encryption Type:");
Serial.println(encryption, HEX);
}

Output

Open the Serial Monitor and check  if the board is been connected to your network.

Connect No Encryption Output