Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom mqtt parameters. #669

Closed
keerthikumaran opened this issue Apr 10, 2019 · 11 comments · Fixed by #680
Closed

custom mqtt parameters. #669

keerthikumaran opened this issue Apr 10, 2019 · 11 comments · Fixed by #680

Comments

@keerthikumaran
Copy link

Hi,
I am working with the custom parameters for mqtt credentials like the WiFi manger.
I need help in adding the MQTT SERVER, PORT, USER NAME AND PASSWORD as a autoconnect custom FS Parameters.
I have used the same code as given and the libraries too..

@crankyoldgit
Copy link
Owner

I'm assuming you are trying to add this to the IRMQTTServer example code. It just uses the standard WifiManager library.

Have you tried looking at the example code for WifiManager on how to do this?
e.g.
https://github.com/tzapu/WiFiManager/blob/master/examples/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino

@keerthikumaran
Copy link
Author

I added WIFIMANGER library code accordingly and the json file is not opening to write and save the parameters for the future usage. MQTT connects for the first time with the autoconnectFSparameters, and once when the nodemcu is reset the MQTT parameters are not assigned but the SSID and PASSWORD is read and the mcu gets connected to the wifi.

@crankyoldgit
Copy link
Owner

I'm not sure. Perhaps ask on the WifiManager issues page(s)?

As their example code uses SPIFFS, did you add a partition for it in the build/target options in the Arduino IDE?

@keerthikumaran
Copy link
Author

keerthikumaran commented Apr 16, 2019

Ok @crankyoldgit will ask WifiManager page.

Ya I added 1M SPIFFS. And I am clearing the memory every time I upload the code.
Thamks for your help.

@crankyoldgit
Copy link
Owner

crankyoldgit commented Apr 16, 2019

Did you try the example code I linked earlier? i.e. Just to test you've got all the correct build settings.

Sadly, I don't personally have experience with saving stuff to the eeprom/flash on the ESP8266. But, please let me know what you find out, as I'm keen to add that functionality at some point.

@keerthikumaran
Copy link
Author

I have tried the wifimanger code alone and it works fine when it comes to the integration part the json file is not opening to write the parameters in it.
I have attached the screenshot of the serial output screen.

Screenshot from 2019-04-16 18-02-26

TEXT ON SERIAL SCREEN:

*WM: Handle root
*WM: WiFi save
*WM: Parameter
*WM: server
*WM: 192.168.43.1
*WM: Parameter
*WM: port
*WM: 1883
*WM: Parameter
*WM: auth
*WM: hello
*WM: Sent wifi save page
*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Connection result:
*WM: 3
Should save config
connected...yeey :)
saving config
opening file to write.
{"mqtt_server":"192.168.43.1","mqtt_port":"1883","auth_token":"hello"}local ip
192.168.43.131
*WM: freeing allocated params!
0000199.959: MDNS responder started
0000199.960: HTTP server started
0000199.964: client mqtt not connected, trying to connect
0000199.964: Attempting MQTT connection to 192.168.43.1:1883topic : hello...
0000200.146: connected.
0000200.147: Subscription OK to
0000200.148: successful client mqtt connection
0000222.881: Incoming IR message sent to MQTT: 3,31CE00FF,32
0000224.194: Incoming IR message sent to MQTT: 3,FFFFFFFFFFFFFFFF,0
rl�l⸮⸮|�⸮c�⸮N� ⸮�$⸮�p⸮r⸮�⸮�⸮{⸮"⸮ c⸮⸮Nn⸮�dNN⸮⸮⸮ B�p⸮cd �rlp⸮N⸮�� �⸮ l ⸮⸮ #�n⸮|�d⸮ ⸮p�⸮⸮oo⸮�l⸮⸮�d �⸮��no $ ���or⸮⸮⸮o��b ⸮�$�s⸮⸮o� # ⸮�l⸮2d⸮p�⸮�⸮⸮{$⸮⸮o⸮�
⸮⸮H⸮뫹ѥ⸮⸮⸮FS...
mounted file system
reading config file
opened config file
{"mqtt_server":"192.168.43.1","mqtt_port":"1883","auth_token":"hello"}
parsed json
load json config ... SUCESS
custom_mqtt_server
*WM: Adding parameter
*WM: server
*WM: Adding parameter
*WM: port
*WM: Adding parameter
*WM: auth
*WM:
*WM: AutoConnect
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster
*WM: Connection result:
*WM: 3
*WM: IP Address:
*WM: 192.168.43.131
connected...yeey :)
local ip
192.168.43.131
*WM: freeing allocated params!
0000008.496: MDNS responder started
0000008.497: HTTP server started
0000008.498: client mqtt not connected, trying to connect
0000008.498: Attempting MQTT connection to 192.168.43.1:1883topic : hello...
0000008.648: connected.
0000008.649: Subscription OK to
0000008.650: successful client mqtt connection

@crankyoldgit
Copy link
Owner

Do you have a link to the code you are using?

@keerthikumaran
Copy link
Author

no @crankyoldgit I dont have a link for my code.

@crankyoldgit
Copy link
Owner

Without code to test/debug, I can't really help you.

@keerthikumaran
Copy link
Author

this is my code.

mqtt_irblaster.zip

@keerthikumaran
Copy link
Author

I figured out where I was wrong.
Thanks for your help.

crankyoldgit added a commit that referenced this issue Apr 24, 2019
* Add mqtt server, port, username & password to WifiManager settings.
* Save a `/config.json` file into the SPIFFS to store these over reboots.
* Bucketloads of debugging added.

Testing seems to show it works.

Fixes #669
crankyoldgit added a commit that referenced this issue Apr 24, 2019
- Use WifiManager to do the one-time setup for the program.
  e.g. Set MQTT parameters, HTTP passwords, hostnames etc.
  This should allow a fairly standard build (except for GPIOs) for most
  people.
- Move hardcoded examples to their own page.
- Lots of hacks to try to reduce heap fragmentation/memory use.
- Move user config settings to IRMQTTServer.h file.
- General code cleanup and grouping.
- Bump version. Almost ready for release.

NOTE: Previous users may need to fully wipe/reset the SPIFFS/WifiManager settings
      by visiting `http://<your_esp8266's_ip_address>/reset`

Fixes #669
crankyoldgit added a commit that referenced this issue Apr 24, 2019
…ngs. (#680)

This should allow a fairly standard build (except for GPIOs) for most people.
- Add mqtt server, port, username & password for mqtt/http and hostname, prefix to WifiManager settings.
  * Saves a `/config.json` file into the SPIFFS to store these over reboots.
- Move hard-coded examples to their own page.
- Lots of hacks to try to reduce heap fragmentation/memory use.
- Move user config settings to `IRMQTTServer.h` file.
- General code cleanup and grouping.
- Bump version. Almost ready for release.
- Bucket loads of debugging added.

Testing seems to show it works (running on my main device)

**WARNING**: Previous users may need to fully wipe/reset the SPIFFS/WifiManager settings
                   by visiting `http://<your_esp8266's_ip_address>/reset` prior to or after update.

Fixes #669
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants