[GH-ISSUE #397] Add Custom Parameters #331

Closed
opened 2026-02-28 01:24:49 +03:00 by kerem · 6 comments
Owner

Originally created by @nimaaryamehr on GitHub (Aug 13, 2017).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/397

In this program, I want to get the TOKEN_NOTIFY parameter from the user on the configuration page
How to do it
I also read the parameter "Custom Parameters" but I did not notice anything

`
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>

const byte interruptPin = 2;

const char* BASEURI="http://telegramiotbot.com/api/notify?token=";
const char* TOKEN_NOTIFY="123456789"; " <=====================

bool interrupted=false;
/*
interrupt handler
/
void inputChanged(){
interrupted=true;
}
void notify(const char
token){
HTTPClient http;

http.begin(String(BASEURI) + token);

int httpCode = http.GET();

}

void setup() {

WiFiManager wifiManager;
//wifiManager.resetSettings();
wifiManager.autoConnect("SmartHome");

pinMode(interruptPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(interruptPin), inputChanged, RISING);

}

void loop() {
if(interrupted){
if((WiFi.status() == WL_CONNECTED)) {
notify(TOKEN_NOTIFY);
interrupted=false;
}
}
}

`

Originally created by @nimaaryamehr on GitHub (Aug 13, 2017). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/397 In this program, I want to get the TOKEN_NOTIFY parameter from the user on the configuration page How to do it I also read the parameter "Custom Parameters" but I did not notice anything ` #include <Arduino.h> #include <ESP8266WiFi.h> #include <ESP8266HTTPClient.h> #include <DNSServer.h> #include <ESP8266WebServer.h> #include <WiFiManager.h> const byte interruptPin = 2; const char* BASEURI="http://telegramiotbot.com/api/notify?token="; const char* TOKEN_NOTIFY="123456789"; " <===================== bool interrupted=false; /* interrupt handler */ void inputChanged(){ interrupted=true; } void notify(const char* token){ HTTPClient http; http.begin(String(BASEURI) + token); int httpCode = http.GET(); } void setup() { WiFiManager wifiManager; //wifiManager.resetSettings(); wifiManager.autoConnect("SmartHome"); pinMode(interruptPin, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(interruptPin), inputChanged, RISING); } void loop() { if(interrupted){ if((WiFi.status() == WL_CONNECTED)) { notify(TOKEN_NOTIFY); interrupted=false; } } } `
kerem 2026-02-28 01:24:49 +03:00
  • closed this issue
  • added the
    Question
    label
Author
Owner

@herostrat commented on GitHub (Sep 19, 2017):

Hey @nimaaryamehr,

as far as I could understand you want the user to write a token in your configuration to be able to work with it in the code.

You can find an example of this int the examples/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino

Notice that you need to define custom parameters see e.g. line 76

Than add this paramter to your instance of the wifimanager e.g. line 91

And after the user put the information in the form and the connection to the network is done you can get the data via getValue() (e.g. line 123) which copys the data in a char array.

I hope this helps.

Cheers

<!-- gh-comment-id:330668571 --> @herostrat commented on GitHub (Sep 19, 2017): Hey @nimaaryamehr, as far as I could understand you want the user to write a token in your configuration to be able to work with it in the code. You can find an example of this int the [examples/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino](https://github.com/tzapu/WiFiManager/blob/master/examples/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino) Notice that you need to define custom parameters see e.g. [line 76](https://github.com/tzapu/WiFiManager/blob/89af31245b98b05e7d89319746ef3bc29d7e965b/examples/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino#L76) Than add this paramter to your instance of the wifimanager e.g. [line 91](https://github.com/tzapu/WiFiManager/blob/89af31245b98b05e7d89319746ef3bc29d7e965b/examples/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino#L91) And after the user put the information in the form and the connection to the network is done you can get the data via getValue() (e.g. [line 123](https://github.com/tzapu/WiFiManager/blob/89af31245b98b05e7d89319746ef3bc29d7e965b/examples/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino#L123)) which copys the data in a char array. I hope this helps. Cheers
Author
Owner

@vaz83 commented on GitHub (Jul 13, 2018):

HI, i am also adding some parameters but i am noticing that the label of the field is now showing up, did this happened to anyone else =?

<!-- gh-comment-id:404973821 --> @vaz83 commented on GitHub (Jul 13, 2018): HI, i am also adding some parameters but i am noticing that the label of the field is now showing up, did this happened to anyone else =?
Author
Owner

@tablatronix commented on GitHub (Jul 13, 2018):

development version adds labels.... is that what you mean?

<!-- gh-comment-id:404980139 --> @tablatronix commented on GitHub (Jul 13, 2018): development version adds labels.... is that what you mean?
Author
Owner

@vaz83 commented on GitHub (Jul 14, 2018):

Sorry tablatronix, I was using an old version of the WM, i downloaded the latest development version so this issue is solved already :) thanks :)

<!-- gh-comment-id:405031237 --> @vaz83 commented on GitHub (Jul 14, 2018): Sorry tablatronix, I was using an old version of the WM, i downloaded the latest development version so this issue is solved already :) thanks :)
Author
Owner

@dontsovcmc commented on GitHub (Nov 28, 2019):

@tablatronix close, solved

<!-- gh-comment-id:559300324 --> @dontsovcmc commented on GitHub (Nov 28, 2019): @tablatronix close, solved
Author
Owner

@Robotical2 commented on GitHub (Dec 31, 2020):

Hi vaz83, can you please share which WM version you used for adding Custom Parameters.

<!-- gh-comment-id:752945088 --> @Robotical2 commented on GitHub (Dec 31, 2020): Hi vaz83, can you please share which WM version you used for adding Custom Parameters.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#331
No description provided.