A simple method to get a wifi device connected to the local network

97 views
Skip to first unread message

Matthew Ford

unread,
Feb 12, 2015, 7:28:31 PM2/12/15
to devel...@arduino.cc
I was prompted by the discussion on IDE: Yun's not showing up in port menu
about getting wifi connection parameters into the device.
So I have put up a suggested process here

http://www.forward.com.au/pfod/pfodWifiConnect/pfodWifiConnect.html

This uses QR code, an Android app (setting up a temporary AP) and a
small library in the Arduino to save the network parameters.
The QR code tell the android app the settings for the temporary AP that
Arduino will try and connect to, in setup mode, get its real parameters.

Any comments/ suggestions welcome

matthew

Tom Igoe

unread,
Feb 13, 2015, 7:42:08 AM2/13/15
to devel...@arduino.cc
So if I read this right, you need a QR code on the device, then an Android device, then your computer? That seems like too many devices to connect, to me.

t.
> --
> You received this message because you are subscribed to the Google Groups "Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.

dirk swart

unread,
Feb 13, 2015, 9:12:15 AM2/13/15
to devel...@arduino.cc
Hi Matthew,

This looks very promising. I think that any method to bootstrap wifi connectivity is going to involve some hoops and another device (like a phone) - there seems to be no getting around that, (unless you plug in a cable I suppose, which makes the whole thing moot :). 

Any solution which is open source, and works 100% of the time is a big step forward.

Cheers
Dirk





matthew

--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.

Matthew Ford

unread,
Feb 13, 2015, 5:45:00 PM2/13/15
to devel...@arduino.cc
Hi Tom,
Note: this process is designed to make it easy (easier) for the user
(not being the programmer) to get the device connected to the network.

You only need the QR code (attached to the device) and an Android
mobile. So just one device, the android mobile.

You only need the computer to run the Arduino IDE to program the device
initially, before you give it to the user.
(This process is also useful for the programmer to move the device
between networks without needing to get the computer out again and
re-program)

matthew

Tom Igoe

unread,
Feb 13, 2015, 6:05:15 PM2/13/15
to devel...@arduino.cc

> On Feb 13, 2015, at 5:44 PM, Matthew Ford <matthe...@forward.com.au> wrote:
>
> Hi Tom,
> Note: this process is designed to make it easy (easier) for the user (not being the programmer) to get the device connected to the network.

OK. If you’re thinking end user devices, then you’re thinking of things where the aesthetics matter. Is there a way to hide the QR code?
>
> You only need the QR code (attached to the device) and an Android mobile. So just one device, the android mobile.

Can it work on other platforms too? I wouldn’t want to lock in people to one. That was one of the early points of Arduino as a whole, to be cross-platform on the desktop . We should be the same on the palmtop. How about an HTML5/Cordova solution that could work on any phone? Pretty sure QR discovery can be done that way, and would expand your user base a lot while remaining open source.

> You only need the computer to run the Arduino IDE to program the device initially, before you give it to the user.

But you need to discover the device before you program it, unless you rely on USB, per the earlier thread. So it could be useful to have a discovery process that works for both.
> (This process is also useful for the programmer to move the device between networks without needing to get the computer out again and re-program)

Exactly.


t.

Matthew Ford

unread,
Feb 13, 2015, 7:05:49 PM2/13/15
to devel...@arduino.cc
Hi Tom,
Thanks for the input.
See inline replies


On Feb 13, 2015, at 5:44 PM, Matthew Ford <matthe...@forward.com.au> wrote:

Hi Tom,
Note: this process is designed to make it easy (easier) for the user (not being the programmer) to get the device connected to the network.
OK. If you’re thinking end user devices, then you’re thinking of things where the aesthetics matter. Is there a way to hide the QR code? 

Put the QR code on the bottom of the device.  :-)

If you removed the QR code altogether and set a fixed SSID and passkey for the temporary setup Android AP, that would be a serious security flaw as anyone could sniff for this 'well known' SSID and passkey and then collect the real network SSID and password as it was being set to the device.

So it is important for security that the passkey for the temporary Android AP is random and not accessible without physical access to the device (i.e. access to the QR code)  For ultra security, don't attach the QR code to the device but store it elsewhere.  This is not necessary for general home and office use.

Of course there as other alternatives to the QR code, NFC for example or a BT connection, but that adds expense and development complexity.  One of the aims to to make this easy for the developer to implement as well.  Basically add the library and write two methods to suit the wifi hardware being used.


You only need the QR code (attached to the device) and an Android mobile.  So just one device, the android mobile.
Can it work on other platforms too?  I wouldn’t want to lock in people to one. That was one of the early points of Arduino as a whole, to be cross-platform on the desktop . We should be the same on the palmtop. How about an HTML5/Cordova solution that could work on any phone? Pretty sure QR discovery can be done that way, and would expand your user base a lot while remaining open source.

My main mobile programming experience is with Android,  feel free to port the process to any other phone.

"Android is by far the most dominant player with 81.9% of the market. The next closest players are iOS with 12.1% and Windows Phone with 3.6%." - See more at: http://www.dailytech.com/Gartner+Numbers+Show+Android+Holds+82+of+Worldwide+Smartphone+Market/article33748.htm#sthash.KwyetxPE.dpuf


You only need the computer to run the Arduino IDE to program the device initially, before you give it to the user.
But you need to discover the device before you program it, unless you rely on USB, per the earlier thread. So it could be useful to have a discovery process that works for both. 

Note: I am not 'programming' the device in the general sense, only configuring three constants in EEPROM:- the real network's  SSID, security type and passkey.

I am expecting the device, when in setup mode, to automatically connect to the temporary AP setup on the Android phone, using the programmed SSID and passkey that are on the QR code.  The Android app sets up a temporary AP using the parameters read from the QR code.

Generating random passkeys for each device (which the QR generator app will do)  will ensure only one device connects at a time, even if two happen to be put into set up mode at the same time, since the other devices' passkey will not match the temporary AP passkey (assuming WPA2 PSK)

Although setting the same passkey for multiple devices and configuring them all at the same time would not be a problem either.

If the AP point is using an OPEN network then multiple devices could connect at the same time and this would be a problem as the encrypted network password would decrypted incorrectly for all but one of them (assuming random encryption passkeys) 

So on reflection I should drop support for OPEN security on the temporary AP and insist on WPA2 PSK connections only.  This does not restrict the type of security that is configured for the real network, only how the setup connection is made.
(Thanks for raising that, I will update the design).

Randy Ferrell

unread,
Feb 13, 2015, 7:45:39 PM2/13/15
to devel...@arduino.cc
I found some boards to do wi-fi from a ttl serial port the chip on board does all the protocal have to look at the data sheet for them to tell you what protocal it does. havn't tryed to use them yet but they only cost 4.00 ea

Randy Ferrell

unread,
Feb 13, 2015, 7:49:57 PM2/13/15
to devel...@arduino.cc

Victor Aprea

unread,
Feb 13, 2015, 8:15:09 PM2/13/15
to Arduino Developers
Matt,

Can I check that I understand what you're suggesting?

(1) Each device is labelled with a QR code that reflects a unique Wi-Fi network security profile (SSID/SecurityType/Password) and that identical information is also stored on the device.
(2) The user opens your App, snaps a photo of the QR code, punches in the network security profile of the target network, and says "Go." At this point your App puts the phone into SoftAP mode configured as the QR-code network security profile. I actually didn't realize you could do this, but I'm not well versed in Android/IOS development, so am perfectly willing to take your word for it.
(3) The user puts the device into Provisioning mode using a button or whatever.
(4) The device connects to the QR code network (which now happens to be provided by your phone)
(5) The device gets the target network security profile from your phone (as you punched it in earlier) and stores it in EEPROM or whatever.
(6) You reset the device and it connects using its newly stored credentials thereafter, until such time as you repeat the process to change the stored network security profile. 

Do I have that right? I think it's an interesting approach for sure. Certainly worthy of more attention / scrutiny from the broader community.

Regards,
Vic


Victor Aprea // Wicked Device



matthew

--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.

Matthew Ford

unread,
Feb 13, 2015, 8:51:38 PM2/13/15
to devel...@arduino.cc
Yes that is correct.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.

--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.

Matthew Ford

unread,
Feb 13, 2015, 9:11:50 PM2/13/15
to devel...@arduino.cc
Nice price,
I have used a similar RN networks wifi add on board for FioV3
see http://www.forward.com.au/pfod/ArduinoProgramming/FioV3/index.html

However,  you are still faced with the problem of "how can the user (not you the programmer) connect this device to their network"
That is the problem I am trying to address with this method.

As a side issue, using this board with my proposed method is more complicated because changing the wifi board's configuration is via AT commands so you need to include some type AT response parser in the two configuration methods that the basic library will call to set up to connect to the temp Android AP and then to setup the real network parameters.

This was going to be one of examples when I get around to implementing this proposal.

matthew

Matthew Ford

unread,
Feb 15, 2015, 6:32:33 PM2/15/15
to devel...@arduino.cc

This my non-expert analysis of the security issues associated with using pfodWifiConnect to connect a device to the local network.

Comments welcome.

The critical piece of information to be protected is the password for the local network. Using pfodWifiConnect this password is entered into the Android mobile and then transferred to the device via a WPA2 PSK secured temporary wifi network.

There are three obvious attack vectors:-

I) The device being connected has been compromised and after captures the password (as it should) but then re-transmits it once it can. This issue is on the same level as installing any compromised hardware/software. So it is important to be confident of the manufacture of the device you are configuring.

II) The Android mobile running pfodWifiConnect has been been compromised by spyware with sniffs the keystrokes as you enter the network password and then re-transmits it once it can. As you can see from looking at the open source pfodWifiConnect code, the network password is only held in memory by the pfodWifiConnect app and not saved anywhere.

This narrows the attack vector. So it is important to use an Android mobile free from any such spyware. Removing all apps and doing a clean install of the OS will help, as will dedicating just one mobile to configuration. That mobile, not being in general use, is much less likely to be infected.

III) Anyone who can access the QR code can read the password for the temporary pfodWifiConnect network which transfers the real network's password. It is assumed that using the pfodQRpsk application to generate the random passwords, a different one for each device, prevents any one just guessing it.

Having that temporary pfodWifiConnect network password would allow a malicious person to sniff the temporary pfodWifiConnect network and collect the real network's password. This attack vector is very narrow both in time and location. The sniff can only occur while the device is being configured and only within a short range due to the low power of the Android mobile's AccessPoint and the attacker needs to have physical access to the device with the QR code attached in order to read the pfodWifiConnect's temporary network password.

An obvious means to carry out this type of attack is for a malicious person to arrive with a new 'toy' from a reputable manufacture that needs to be connected to the network to run. The malicious person gives it to you to connect, using pfodWifiConnect, making a point of not looking while you enter the real network password. However having scanned the QR code before arriving, their mobile is sniffing the pfodWifiConnect temporary network and captures the real networks password.

So Beware of Geeks bearing Gifts.

Victor Aprea

unread,
Feb 16, 2015, 10:56:07 AM2/16/15
to Arduino Developers
Are there any IOS developers on the list (or friends of the list) that can comment about whether the whole phone as a temporary SoftAP aspect of this notional process is possible on Apple products?

Cheers,
Vic

Victor Aprea // Wicked Device

Arnav Gupta

unread,
Feb 16, 2015, 12:34:21 PM2/16/15
to devel...@arduino.cc

With my highly limited experience... I think apps do not have access to directly switch on the phone's hotspot on iOS

Arnav Gupta
( http://championswimmer.in )
Sent from Android.
Pardon brevity and/or autocorrect errors.
   

Matthew Ford

unread,
Feb 16, 2015, 6:51:47 PM2/16/15
to devel...@arduino.cc
Maybe IOS users would have to do that step by hand.
i.e. scan the QR code and then copy and paste the settings into IOS softAP setting screen.

Maya Posch

unread,
Feb 17, 2015, 7:24:22 AM2/17/15
to devel...@arduino.cc
On iOS it's not possible to enable or configure the personal hotspot
functionality via a public API. One can do it on a jail-broken device
via the private APIs, but that's hardly suitable for this situation, I
think.

The easiest approach in my view would be to have the app provide the
info to punch into the personal hotspot UI of iOS itself based on the
scanned info from the QR tag, then enable it. This might require the
user to scribble some stuff down on paper or use the copy-paste
functionality (a few shades of infuriating on many touch-screens).

After setting things up like this the app can be set to listen on the
personal hotspot 'adapter' only and await the signal from the device.

Should be fairly newbie-friendly, I think.


Maya


On 2015-02-16 4:55 PM, Victor Aprea wrote:
> Are there any IOS developers on the list (or friends of the list) that
> can comment about whether the whole phone as a temporary SoftAP aspect
> of this notional process is possible on Apple products?
>
> Cheers,
> Vic
>
> Victor Aprea // Wicked Device
> victor...@wickeddevice.com <mailto:victor...@wickeddevice.com>
> T: @vicatcu <http://twitter.com/vicatcu/>
>> victor...@wickeddevice.com <mailto:victor...@wickeddevice.com>
>> T: @vicatcu <http://twitter.com/vicatcu/>
>>
>> On Thu, Feb 12, 2015 at 7:27 PM, Matthew Ford
>> <matthe...@forward.com.au <mailto:matthe...@forward.com.au>>
>> wrote:
>>
>> I was prompted by the discussion on IDE: Yun's not showing up
>> in port menu
>> about getting wifi connection parameters into the device.
>> So I have put up a suggested process here
>>
>> http://www.forward.com.au/pfod/pfodWifiConnect/pfodWifiConnect.html
>>
>> This uses QR code, an Android app (setting up a temporary AP)
>> and a small library in the Arduino to save the network parameters.
>> The QR code tell the android app the settings for the
>> temporary AP that Arduino will try and connect to, in setup
>> mode, get its real parameters.
>>
>> Any comments/ suggestions welcome
>>
>> matthew
>>
>> --
>> You received this message because you are subscribed to the
>> Google Groups "Developers" group.
>> To unsubscribe from this group and stop receiving emails from
>> it, send an email to developers+...@arduino.cc
>> <mailto:developers+...@arduino.cc>.
>>
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Developers" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to developers+...@arduino.cc
>> <mailto:developers+...@arduino.cc>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Developers" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to developers+...@arduino.cc
> <mailto:developers+...@arduino.cc>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to developers+...@arduino.cc
> <mailto:developers+...@arduino.cc>.

Ricardo JL Rufino

unread,
Feb 17, 2015, 9:51:42 AM2/17/15
to devel...@arduino.cc
One method that I found quite interesting was the EletricImp and involves just a photo resistor.


Basically the App encodes the connection information using a standard flashes of the mobile screen.







To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.

Victor Aprea

unread,
Feb 17, 2015, 10:23:14 AM2/17/15
to Arduino Developers
Ricardo,

https://electricimp.com/product/blinkup/ 

"... Electric Imp’s patented setup solution, BlinkUp ..."

Even if we went with "we don't need no stinkin' patents" mindset or whatever, it still requires adding hardware components and firmware to support the process and iOS/Android software on top of that. 

While it's an interesting approach, my opinion is that it's not a fruitful path to pursue for the open source hardware / Arduino community.

Kind Regards,
Vic

Victor Aprea // Wicked Device

Matthew Ford

unread,
Feb 26, 2015, 1:31:39 AM2/26/15
to devel...@arduino.cc
As a first step to implementing this method, I have published
pfodQRpsk.jar (and source code).
http://www.forward.com.au/pfod/pfodWifiConnect/pfodQRpsk.html

This java application generate a random WPA2 PSK key and saves a QR code
image file with the details


Matthew Ford

unread,
Mar 2, 2015, 10:19:09 AM3/2/15
to devel...@arduino.cc
While working the implementation of the supporting Arduino compatible library it become very convenient to test using telent.
So I have added the procedure for configuring via telnet.
This lets non-Android uses do the configuration also (although the Android app will still be the easiest method)

Quick Start for Users using Telnet – Version 1

These are the steps your user would follow to connect your pfodWifiConnect equipped device to their network using telnet.

  1. Scan the QR code attached to the Wi-Fi device using one of the scanning apps available for their mobile (either IOS or Android or Windows)

  2. Configure a temporary Access Point using the setting just scanned. IPhone, Android, Mac IOS and Windows all provide support for configuring an Access Point, although some are easier to configure than others.

  3. Turn the Wi-Fi device off and then turn it on while holding down the setup button. Keep the button held down for at least 5 seconds or until the device indicates it is in configuration mode.

  4. Find the IP address of the device on the temporary network. There are apps for IPhone and Android to do this and command lines in Mac IOS and Windows.

  5. Open a telnet program on any mobile or computer attached to the temporary network and connect to the device using the IP address just found and the portNo from the scanned data. This is usually done on the Access Point.

  6. In the telnet window type the configuration data in one the following format (Note: the characters ~ and } can not appear in any of the fields as they are a separator and terminator respectively)

    {set~<networkSSID>~<password> [ ~<portNo> [ ~<staticIP> [ ~<serverIP_or_HostName:portNo> [ ~<security> ]]]] }

    where the portNo, staticIP, security, serverIP_or_HostName and serverPortNo are optional but must appear in that order if they do.

If portNo is not specified or is set as 0, then port 80 is assumed for devices running as servers.
If staticIP is not specified or is set as 0.0.0.0 then DHCP is assumed. 
If serverIP_or_HostName:portNo is not specified then device can only run as a server.
If security is not specified then the string WPA2-PSK is assumed (For Version 1 this is the only supported option)

For example to configure a device connecting using WPA2 PSK and running as a server on port 4989 using DHCP for its IP send the command
{set~ssid~password~4989}

The device should respond with a message indicating the configuration has been accepted using the following format
{! <msg>}

If there is an error in the setting, invalid port or IP, etc then the device should respond with an error message using the format
{E~<msg>}



Matthew Ford

unread,
Mar 21, 2015, 1:30:37 AM3/21/15
to devel...@arduino.cc
I have completed pfodWifiConnectV1 Arduino libraries for WildFire
(CC3000) and LinkIt ONE boards
and have published them, with tutorials on how to use Telnet to make the
connection, here
http://www.forward.com.au/pfod/pfodWifiConnect/index.html

matthew


Reply all
Reply to author
Forward
0 new messages