Field initialization of product

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Field initialization of product

Postby mzimmers » Thu Sep 06, 2018 10:40 pm

Hi all -

The time has come for me to devise a method for the customer to provision the products he gets from my company. At a minimum, he needs to enter a SSID and PSK, so the device can join a Wifi network.

The current thinking in the company is that this is best handled via a serial interface (using a USB-UART cable), and a dedicated app running on a PC. Ideally we'd use the same connector that we use at the factory to flash the device with our application.

1. if anyone has a better idea, I'm entirely open to suggestions.
2. assuming this is a viable approach, what can be done to silence the console?
3. can I expect any problems with using this port? Currently my app doesn't see anything that I'm writing to it. I've just begun to experiment, so it's entirely possible that I'm not doing it right, but I want to make sure that this approach is at least feasible.

Thanks.

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

Re: Field initialization of product

Postby loboris » Fri Sep 07, 2018 7:19 am

You can use BT (RFCOMM) for the same functionality.
If you want to use the default serial port, you should supress the ROM bootloader messages by holding GPIO15 at ground during power on and disable or redirect ESP_LOGx. Nothing will be output on the default serial port and you can use UART0 in the application.

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Field initialization of product

Postby fly135 » Fri Sep 07, 2018 6:14 pm

I handle this using BLE. I can't afford to lose the memory to run BLE in my normal application, so I store a state variable in NVS and reboot between configured (SSID and PWD assigned) and nonconfigured (BLE) mode. Of course you will have to write a phone app to do the configuration.

John A

mikemoy
Posts: 599
Joined: Fri Jan 12, 2018 9:10 pm

Re: Field initialization of product

Postby mikemoy » Sat Sep 08, 2018 11:38 am

I handled this by turning on AP mode when a certain combo of buttons is pressed on power up. I have a 4x4 keypad on my project but a button can work, or you can turn it on for 30 seconds at power up and if no connection then turn it back off.

You can then set your own SSID name like "you company name" or "the gizmos name". They can then simply whip out their phone or laptop, and connect to it's Wi-Fi. Open their browser and go to its IP addess and you serve up a web page asking for their network info.
Use this info and turn off AP mode, and go to station mode to then connect to their wifi.

I found this approach simplest because for me, creating a web page was far easier then a phone app.

tommeyers
Posts: 184
Joined: Tue Apr 17, 2018 1:51 pm
Location: Santiago, Dominican Republic

Re: Field initialization of product

Postby tommeyers » Sat Sep 08, 2018 1:45 pm

Take a google look at "esp touch" and also the code examples.

I use an AP that is active for the first 5 minutes and setting the values using preferences.h. The AP is a bit bulky and fragile. It could be cleaner by reading a button or switch to choose if AP is active.

https://www.espressif.com/en/products/s ... /resources

Tom Meyers
IT Professional, Maker
Santiago, Dominican Republic

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: Field initialization of product

Postby mzimmers » Mon Sep 10, 2018 4:42 pm

Thanks to all for the helpful ideas. I'm going to try ESP-TOUCH, as it seems closest to what I'm looking for.

I've tried using the example in the user's manual, but I'm getting a startup problem:

Code: Select all

Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.
The only code executed so far is this:

Code: Select all

    esp_smartconfig_set_type(SC_TYPE_ESPTOUCH);
    esp_smartconfig_start(sc_callback);
Any idea what I'm doing wrong?

EDIT: evidently, the problem was that I hadn't started wifi yet. I'm not sure what the right call sequence here is, though. I get the
SC_STATUS_FIND_CHANNEL event, but then the system hangs.

tommeyers
Posts: 184
Joined: Tue Apr 17, 2018 1:51 pm
Location: Santiago, Dominican Republic

Re: Field initialization of product

Postby tommeyers » Mon Sep 10, 2018 11:59 pm

I can send you some complete working code that implements a web server / access point that runs for 5 minutes concurrently with a station connection for mqtt.

It is what I am using for deploying IoT sensor nodes. It also uses the preferences library for saving the preferences and generates the html for the preferences. It accommodates the initial case where there are no preferences.

Tom Meyers
IT Professional, Maker
Santiago, Dominican Republic

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: Field initialization of product

Postby mzimmers » Tue Sep 11, 2018 3:13 pm

Hi Tom -

Thank you for the code sample. I misunderstood you, though -- I thought you were referring to a sample that made use of the smartconfig facility. I'd prefer to pursue that option, at least for now. If I can't get that to work, I'll revisit other options.

tommeyers
Posts: 184
Joined: Tue Apr 17, 2018 1:51 pm
Location: Santiago, Dominican Republic

Re: Field initialization of product

Postby tommeyers » Tue Sep 11, 2018 3:50 pm

All is good.

You inspired me to look at BT for configuration and today I am studying that. Chrome browser can use a BT connection. So I am looking at BT + Chrome. I like the idea that I don't need to have an app but just a browser. I also like that I can separate BT for config interaction and debug output messages and WiFi for the MQTT connection. I found that using WiFi for STA + AP required a lot of care and then the Espressif ESP32 firmware tries to use it too.

Tom Meyers
IT Professional, Maker
Santiago, Dominican Republic

tommeyers
Posts: 184
Joined: Tue Apr 17, 2018 1:51 pm
Location: Santiago, Dominican Republic

Re: Field initialization of product

Postby tommeyers » Sat Sep 15, 2018 6:37 pm

I followed up of the BT config. Here are some notes:

1) BTSerial could be used for configuration. A real simple configuration interface can be written where espserial is active on the ESP32 and the Arduino Serial Monitor connects to the ESP32 via the BT ComPort. I did that on my laptop using a usb to BT device (tiny USB device). That simple interface could operate just like the serial i/f. But if more than a dumb terminal program was used then a more usable GUI i/f could be written.

2) It is possible to interface Google Chrome applications; I installed the ESPruino app and used it to interact with com3
(Serial/USB) and com4 (Serial/BT). The source is available on GitHub.

3) There is a tool for BT WiFi configuration including an Android app see: https://www.espressif.com/sites/default ... ide_en.pdf

I like the idea of using BTSerial; it is simple to activate and I can easily interact with it using something as simple as a dumbterminal program.

I have been using a AP/Web Server in my code to set preferences like SSID, PWD, IP,... That created much more complicated code and it was fragile. Now BTSerial for config and WiFi STA/MQTT.

Tom Meyers
IT Professional, Maker
Santiago, Dominican Republic

Who is online

Users browsing this forum: No registered users and 103 guests