Home | pfodApps/pfodDevices | WebStringTemplates | Java/J2EE | Unix | Torches | Superannuation | | About Us

Forward Logo (image)      

pfodWifiConfig for WildFire
Simple Wifi Network Configuration

by Matthew Ford 18rh March 2015 (originally posted 3rd March 2015)
© Forward Computing and Control Pty. Ltd. NSW Australia
All rights reserved.

How to configure your WildFire
for any WiFi network

without re-programming


This page describes how developers can to use pfodWifiConfig to allow their WildFire device to be configured for any Wifi network without re-programming. Two supporting Arduino libraries are needed pfodWifiConfig.zip and pfodWifiConfig_WildFire.zip

For a general description of pfodWifiConfigV1, see pfodWifiConfig. Read that page first before continuing here.

See Quick Start for using pfodWifiConfigV1 Android App for how config using the free Android app.
See Configuration of pfodWifiConfig™ Wifi devices using Telnet for an example of using telent to configure your device.

Why use pfodWifiConfig for a CC3000 chip?

i) pfodWifiConfig is open source so you can modify it as you need.
ii) pfodWifiConfig does more then just get you connected to the network.

pfodWifiConfigV1 also allows your user to configure the rest of the device. If your device runs as a Server, you can set the portNo the server listens on. If your device runs as a Client, you can set the host to connect to. If your Client device needs a login username and passwork, pfodWifiConfig prompts the user to set this as well.

Developer Setup to use pfodWifiConfigV1.

This section describes how to prepare your WildFire to use pfodWifiConfigV1. First read the pfodWifiConfig page for detail of how the system works.

Preparing the QR code image

First prepare the QR code that will contain the details of the temporary Wifi network that will be used to configure your WildFire. See pfodQRpsk for details on downloading and running the application.

Here is an example generated QR code.

A sample image is shown below. The file name is
pfodWifiConfigV1_the generated key.PNG


The scanned text is from this image is

That is
Network SSID: pfodWifiConfigV1
Security: WPA2-PSK
Password: plyWtEDk6uZ0yfmAEM5wMc
Connect to PortNo: 23
website: www.pfod.com.au

Generate your own QR image and attach it to your device and insert the password into your code (see below). This tutorial will use this QR image, and its password as an example.

Coding WildFire for pfodWifiConfigV1

You need to download and install two libraries, pfodWifiConfig.zip which contains all the common code and the pfodWifiConfig_WildFire.zip library which has the specialized code for WildFire. Install these using Arduino's Sketch → Import Library → Add Library function.

Under Examples → pfodWifiConfig_WildFire there is an example file pfodWifiConfig_WildFire_WifiWebServer.ino
At the top of that file you will find the additional code needed.

Include the libraries

#include "pfodWifiConfig.h"
#include "pfodWifiConfig_WildFire.h"

Add the settings for pfodWifiConfigV1

pfodWifiConfig_WildFire pfodWifiConfig;
// =============== start of pfodWifiConfigionV1 settings ==============
// update this define with the password from your QR code
// http://www.forward.com.au/pfod/pfodWifiConfig/pfodQRpsk.html
#define pfodWifiConfigPASSWORD "CBP1JvFTJVeB7BTMGmVcRb"
// the ssid is pfodWifiConfigV1 and the port is 23 -- set by pfodQRpsk program

// note pfodSecurity uses 19 bytes of eeprom usually starting from 0 so
// start the eeprom address from 20 for configureWifiConnect
int eepromAddress = 20;
int wifiSetup_pin = 4; // name the input pin for setup mode detection D4
// =============== end of pfodWifiConfigionV1 settings ==============

These settings define the password (same one as in your generated QR image) for the temporary pfodWifiConfig network.

The eepromAddress is the starting address in EEPROM where the user's network configuration will be stored. The static constant pfodWifiConfig::EEPROM_USAGE contains the maximum number of EEPROM bytes used by the library starting at eepromAddress.

The wifiSetup_pin is the digital input to check to see if we should start in configuration mode. If that pin is LOW, the sketch starts pfodWifiConfigionV1 otherwise it uses the configuration parameters stored in EEPROM to connect to the real network.

Then at the top of setup() add the following lines

  //============ pfodWifiConfigV1 config ====================
  // see if config button is pressed
 pinMode(wifiSetup_pin, INPUT_PULLUP);
 if (digitalRead(wifiSetup_pin) == LOW) {
 digitalWrite(LED, HIGH); // show we are in setup mode
#ifdef DEBUG
 Serial.println(F("Starting pfodWifiConfigV1"));
 // connect to temporary wifi network for setup
 // the features determine the format of the {set...} command
 uint16_t ipSources = pfodFeatures::DHCP; 
// bit or these together pfodFeatures::DHCP|pfodFeatures::STATIC_IP if both are available
    uint16_t security = pfodFeatures::WPA2; 
// bit or these together e.g. pfodFeatures::OPEN | pfodFeatures::WPA2
    pfodFeatures::SERVER, security, ipSources );
    // configureWifiConfig never returns.  Need to reboot afterwards
  //============ end pfodWifiConfigV1 config ====================

This code sets the wifiSetup_pin as an input with a pullup and then checks if it is being held LOW (pulled to GND). If it is LOW then configureWifiConfig() is called to connect to the temporary pfodWifiConfig network using the settings which should match those in the QR code image and to start a server on listening on port 23 for the configuration message.

The pfodFeatures class (in pfodWifiConfig.h) defines the various constants for the mode, security and ipSources.

Version 1 defines a set of features a device may support. For pfodWifiConfigV1 the possible features are:-
Mode: Server|Client|ClientLogin
IPsource: DHCP|staticIP

NOTE: The call to configureWifiConfig() never returns. So the user needs to power cycle the device after configuration to run it normally.

Below this setup code add the lines

  // else button was not pressed continue to load the stored network settings
  digitalWrite(LED, LOW);
  //else use configured setttings from EEPROM
  // use these local vars
  char ssid[pfodWifiConfig::MAX_SSID_LEN + 1]; // allow for null
  char password[pfodWifiConfig::MAX_PASSWORD_LEN + 1];
  char staticIP[pfodWifiConfig::MAX_STATICIP_LEN + 1];
  uint16_t portNo = 0;
  uint16_t security = 0;
  uint16_t ipSource = 0;
  byte mode = 0;

  pfodWifiConfig.loadNetworkConfigFromEEPROM(eepromAddress, &mode,
      (char*)ssid, pfodWifiConfig::MAX_SSID_LEN + 1, (char*)password, pfodWifiConfig::MAX_PASSWORD_LEN + 1,
      &security, &portNo, &ipSource, (char*)staticIP, pfodWifiConfig::MAX_STATICIP_LEN + 1);

  server = WildFire_CC3000_Server(portNo);
  if (!cc3000.begin())  {
  if (!cc3000.connectToAP(ssid, password, WLAN_SECURITY)) {

  //  etc ….... rest of setup() here

This code, and the rest of the sketch, is run if the wifiSetup_pin is not grounded (LOW). It calls loadNetworkConfigFromEEPROM() to load the user configured network settings from EEPROM and connect to their network.

The complete code for sketch is here. That is all that is required by the developer.


That's all that is required to connect your WildFire board to any user's network without re-programming it each time.

pfodWifiConfig and pfodQRpskare trademarks of Forward Computing and Control Pty. Ltd.
TM is a trademark of Google Inc. For use of the Arduino name see http://arduino.cc/en/Main/FAQ

The General Purpose Android/Arduino Control App.
pfodDevice™ and pfodApp™ are trade marks of Forward Computing and Control Pty. Ltd.

Forward home page link (image)

Contact Forward Computing and Control by
©Copyright 1996-2020 Forward Computing and Control Pty. Ltd. ACN 003 669 994