Changing Node ID at run time
-
Is it possible to change the node ID at run time in Setup???
ie: MY_NODE_ID
The way it looks now, it needs to be set prior to Setup or Loop being invoked using a:
#define MY_NODE_ID 10
I'm using an MQTT GW and would like each device to get its ID from a jumper on the board...
Thanks
-
Yes, it should be possible with something like this...
int8_t myNodeId; #define MY_NODE_ID myNodeId void before () { // read pins and set myNodeId }
-
Good idea, but it did not worked...
The node was at 10, so I set the myNodeId = 12 in before() function, node continued to use ID of 10, most likely from Flash.... before() might be running prior to initialization of all variables...
-
-
I have this working now, it was a setup issue on my part...
#define MY_NODE_ID myNodeId
int8_t myNodeId; #define MY_NODE_ID myNodeId void before () { // read I/O pins and set myNodeId myNodeId = 32; Serial.println( myNodeId ); }
1 out of 5
Suggested Topics
-
Arduino Celebrates 10 years (Malmö/Sweden)
Announcements • 29 Mar 2014, 17:08 • hek 29 Mar 2014, 17:08 -
Gateway without a radio
Development • 12 Jan 2025, 23:19 • OldSurferDude 14 Jan 2025, 22:07 -
Sending offset to node
Development • 31 Jan 2025, 00:59 • bsl88k 4 Feb 2025, 12:14 -
Home Assistant/MySensors quirks
Development • 17 Mar 2025, 02:35 • OldSurferDude 17 Mar 2025, 02:35 -
Radio waking up for no reason.
Development • 4 Jul 2020, 21:09 • Sasquatch 15 Jan 2025, 08:33 -
Adding Listen only device to my system.
Development • 26 Feb 2025, 00:39 • dpcons 26 Feb 2025, 06:26