Back to overview 4.2

Wlan configuration

The Connectinos wlan access point will work out of the box. But in most cases you want to either connect the Connectino to your network or at least change some of the access point settings. For many cases it should be easier to just use the Website or Smartphone App, but for dependent wlan settings or checking the connection on the fly you can choose the ConnectinoWlan-module from our Library.

In every example we added a debug-output, that of course is not needed to work with the module. It is always essential to include the ConnectinoWlan-module, to initialize an instance of the module and to setup the StxSerial. The software automatically starts the start()-function and runs the code, and you can use the loop() to continuously execute functions or test parameters. For our examples we just want to run our functions once.

For the following codes you can observe status changes on the station and access point status LEDs.

Be aware! If you misconfigure your wlan-settings it is possible you can’t connect to your Connectino anymore. In those cases you can upload your corrected sketch via USB.

Connect your wlan

At first we show how to connect to your local network.

Download example: ConnectinoWlan.ino

	#include <ConnectinoWlan.h> // include the ConnectinoWlan-library
	#include <SoftwareSerial.h> // include to generate some output

	// initialize the wlan-module on the UART
	ConnectinoWlan wlan = ConnectinoWlan(StxSerial);

	// initialize the outputpins for serial outputs
	SoftwareSerial debug = SoftwareSerial(8,9);

	void setup(){
	// enable the uart and add communication via wlan-module
	StxSerial.begin();
	StxSerial.add(wlan);

	debug.begin(9600); // start the serial output

	// check if you are connected
	if(wlan.isConnected())
		debug.println("You already setup your Wlan.");
	else
		debug.println("At start your wlan is not connected.");

	// connect to a network with your password, security
	// and block until it is connected.
	// the security modes are CONNECTINO_WLAN_SECURITY_<YOUR SECURITY>
	// with <YOUR SECURITY> is one of: OPEN, WEP, WPA, WPA2, WPA2_MIX
	wlan.connect("YOUR SSID", "YOUR P455W0RD", CONNECTINO_WLAN_SECURITY_WPA, true);

	// check if you are connected
	if(wlan.isConnected())
		debug.println("You successfully connected");
	else
		debug.println("Well... wrong password? wrong security? wrong ssid?");

	// if you want to disconnect
	wlan.disconnect();

	void loop(){
	}

List Wlan

You can also scan for wlan-networks in the area and get the list of found networks.

	#include <ConnectinoWlan.h> // include the ConnectinoWlan-library
	#include <SoftwareSerial.h> // include to generate some output

	// initialize the wlan-module on the UART
	ConnectinoWlan wlan = ConnectinoWlan(StxSerial);

	// initialize the outputpins for serial outputs
	SoftwareSerial debug = SoftwareSerial(8,9);

	void setup(){
	// enable the uart and add communication via wlan-module
	StxSerial.begin();
	StxSerial.add(wlan);

	debug.begin(9600); // start the serial output

	while(!wlan.isConnected()); // wait until connected
	
	wlan.scanNetwork();
	delay(7000); // wait for the scan to be done
	
	uint8_t num = 0; 
	wlan.getApList(&num); // get number of networks from IoT controller
	apInfo_t apList[num]; // generate array to store networkinformations in
	wlan.getApList(&num, apList); // get networks informations from IoT controller

	// print networks informations for all found networks
	for(int i = 0; i < num; i++)
	{
		debug.print("SSID: ");
		debug.println(apList[i].ssid);
		debug.print("Security: ");
		debug.println(apList[i].security);
		debug.print("Signal strength: ");
		debug.println(apList[i].signal);
		debug.print("Radio channel: ");
		debug.println(apList[i].channel);
	}

	void loop(){
	}

To get a list of all networks, at first you need to start a scan on the IoT controller and wait some seconds for it to finish. Afterwards you can ask the controller how many networks he found and initiate a structure to save the information in. Then you get the network information and finally print the array.

Access Point

A Connectino that has not been configured comes with an enabled access point. You can open and close this access point as you can enable or disable the whole wlan-module.

	#include <ConnectinoWlan.h> // include the ConnectinoWlan-library
	#include <SoftwareSerial.h> // include to generate some output

	// initialize the wlan-module on the UART
	ConnectinoWlan wlan = ConnectinoWlan(StxSerial);

	// initialize the outputpins for serial outputs
	SoftwareSerial debug = SoftwareSerial(8,9);

	void setup(){
	// enable the uart and add communication via wlan-module
	StxSerial.begin();
	StxSerial.add(wlan);

	debug.begin(9600); // start the serial output

	wlan.disable();

	wlan.enable();

	wlan.closeAccessPoint();

	// open access point and block while it is not open
	wlan.openAccessPoint(true);

	void loop(){
	}

You can run each of these methods alone, this is just an example on how easy those tasks are.

TUTORIALS