How to select a network and incorporate that selection into a sketch

All -

I have an existing sketch that monitors temperature and other conditions in a greenhouse. The data is collected and then posted to an IOT website (Carriots).

Within the sketch I manually "hard code" the Network SSID and Password to allow the WiFI101 connection to be made.

I want to make this product available to other users and do not want to "hard code" their specific network ID and Password into unique sketches that will only work for them on a single network.

Is there a way to allow the user to select an available network by using some combination of the ScanNetworks sketch and WebServer code to assign one of the available networks to a variable that is read within the existing header section of the sketch.

I have looked at using the Serial Monitor ... or perhaps a local Webpage with a "submit" button ... but don't really see a simple solution. I have even seen some Bluetooth apps that submit code to turn lights on and off ... thinking that could be a way to send the network name and password to Arduino.

Just a little lost and looking for advice to educate myself further. My understanding of Client / Server and HTML forms combined with the Arduino IDE is growing, but not at the level of figuring this out.

Thanks in advance for the help.

Hardware - Arduino MKR1000 with WiFi101 library
Environment - Mac OS X El Capitan 10.11.6
Arduino IDE 1.6.11

Should be possible.

You can present the output of the ScanNetworks sketch to the user (e.g. via serial); just put a number/letter in front of each entry. The user can select that number/letter and you can store the details of the selected network in non-volatile memory (not sure about the options in a MKR1000) and extract that information in setup().

No experience with the MKR1000.

This library is intended for the esp8266 and can be used to set the initial configuration of wlan credentials.
It works by creating an access point and web server which the user connects to. It may give you an idea how to proceed with your system.

Thank you both for the suggestions. The idea of opening the serial monitor and displaying a list from ScanNetworks seems straightforward, however, I don't think the user could input any password text without some sort of interface. Perhaps I am just not clear on how to pass information from the serial interface to the Arduino board. If you think that would work, I will look for a tutorial on that subject.

It would be nice if I could simply open a "submit form" webpage that would prompt for the SSID and Password, then substitute the user input for some existing variables that were called in the header setup of the program. Has that been done for any of the Arduino WiFi network programs?

The esp8266 WiFiManager is a very well constructed Library, and I am sure with enough time I could understand the code well enough to incorporate pieces of it into my sketch. I do not fully understand the concept of being an "Access Point".

On a related note ... the MRK1000 has no option for an external antenna. Does anyone have suggestions for how to improve the range of this device. Line of sight is not always clear when working in outdoor locations with trees and buildings. Perhaps using two boards? One mounted on a pole acting as an "access point" for the other board which controls all the sensors and reports the data?

Any other thoughts would be welcomed.

I don't think the user could input any password text without some sort of interface.

What do you think the serial monitor is :slight_smile: