🎁📬❄️📦Adafruit Holiday Shipping Deadlines 2019: Please place all UPS 2 Day orders by 11am Monday, December 16 📦❄️📬🎁
0

ADAFRUIT_MQTT_Client Login and Pwd in loop()
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.
Please be positive and constructive with your questions and comments.

ADAFRUIT_MQTT_Client Login and Pwd in loop()

by jmontgomry on Thu Nov 07, 2019 8:07 am

I know that ADAFRUIT_MQTT_Client must be istantiated before setup()
but my MQTT_login and MQTT_password are stored in EEPROM and as
you know I can read from there only in setup() or loop().

How resolve this ?

This was asked before and there was no answer. Anyone?

jmontgomry
 
Posts: 5
Joined: Sun Feb 14, 2016 11:37 pm

Re: ADAFRUIT_MQTT_Client Login and Pwd in loop()

by brubell on Mon Nov 11, 2019 4:58 pm

You may want to switch to the Adafruit MQTT Library.

Could you try storing your Adafruit IO Username and Active Key in EEPROM, and then instantiating the MQTT client here:
https://github.com/adafruit/Adafruit_MQ ... 66.ino#L44

The MQTT client doesn't connect to Adafruit IO's MQTT server until the MQTT_connect function is called.
https://github.com/adafruit/Adafruit_MQ ... 6.ino#L111

What you might want to try is reading your credentials within the MQTT_connect function and create a new Adafruit_MQTT_Client in that function with the credentials read from EEPROM.

brubell
 
Posts: 649
Joined: Fri Jul 17, 2015 10:33 pm

Please be positive and constructive with your questions and comments.