Wifi Manager

Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Locked
User avatar
litamin
 
Posts: 16
Joined: Mon Jan 04, 2021 1:10 pm

Wifi Manager

Post by litamin »

Hi all, is there a way to add a Wifi Manager of sorts to the Adafruit.io code? I don't want to have my Wifi credentials hardcoded, but rather have the ESP32 I'm using create an access point with a portal where you can enter you the SSID and password. There are many so called Wifi Managers out there that do this, but I don't quite understand how to implement it into my Adafruit.io code. Any suggestions or tutorials?

Hint: I'm not a pro coder nor wifi/connectivity expert.

User avatar
eherrada
 
Posts: 161
Joined: Thu Jan 04, 2018 4:59 pm

Re: Wifi Manager

Post by eherrada »

This may be what you're looking for: https://www.arduino.cc/reference/en/lib ... fimanager/

Not sure how you'd go about that if you're using CircuitPython. There's probably a way, but I'm not entirely sure if anyone has done it before.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Wifi Manager

Post by adafruit_support_mike »

I don’t know of any existing codebase for that, but it’s definitely possible.

To create an access point, use wifi.radio.start_ap():

https://circuitpython.readthedocs.io/en ... o.start_ap

Then you can run a basic webserver to collect the connection info, call wifi.radio.stop_ap(), and call wifi.radio.connect() with the information given:

https://circuitpython.readthedocs.io/en ... io.connect

User avatar
litamin
 
Posts: 16
Joined: Mon Jan 04, 2021 1:10 pm

Re: Wifi Manager

Post by litamin »

Thank you for your response. I think however that my point did not make it across. And also I'm not using circuitpython, just plain regular Arduino. :)

Clarification:
I have used Wifi managers before (like the one linked by @dherrada), but the way they work is that they take care of everything that has to do with connecting to the wifi network. Any other code, like in our case Adafruit.io code, can only be run *AFTER* the wifi connection has already been made.
But when I use the basic examples of Adafruit.io, they all include the line :

Code: Select all

AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
..which is a "all in one" solution for connecting to the wifi network AND then connecting to adafruit.io. But I only want the latter part. Because when using a Wifi manager, it already connects me to the Wifi network.

Do you understand my issue? I am looking for a way to connect to Adafruit.io and all its services without the Wifi network connection part.

User avatar
brubell
Learn User Page
 
Posts: 2010
Joined: Fri Jul 17, 2015 10:33 pm

Re: Wifi Manager

Post by brubell »

The Adafruit IO Arduino library handles the network connection and mqtt connection for you, it may not be the best solution for what you're trying to do.

If you are using a wifi manager library - you'd want to use a MQTT library such as Adafruit MQTT or Arduino MQTT and connect it to the Adafruit IO MQTT API: https://io.adafruit.com/api/docs/mqtt.h ... o-mqtt-api

User avatar
litamin
 
Posts: 16
Joined: Mon Jan 04, 2021 1:10 pm

Re: Wifi Manager

Post by litamin »

I see, ok then I'll take a look at that.

I presume this means that I can no longer use the Adafruit IO library functions like the below ones?
- feedname->get(); - to get the latest message
- feedname->save("message"); - to upload a new message
- feedname->onMessage(handleMessage); - to automatically get the latest message

User avatar
brubell
Learn User Page
 
Posts: 2010
Joined: Fri Jul 17, 2015 10:33 pm

Re: Wifi Manager

Post by brubell »

I presume this means that I can no longer use the Adafruit IO library functions like the below ones?
Correct, you'll need to make these MQTT API calls directly, from the MQTT library.

Locked
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.

Return to “Internet of Things: Adafruit IO and Wippersnapper”