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 -
Counting Incoming and Outgoing Messages from a Gateway
Development • 10 Dec 2024, 21:57 • Trand 14 Dec 2024, 20:23 -
MQTT-Help me understand about the MQTT Gateway.
Development • 2 Mar 2025, 01:44 • dpcons 12 Mar 2025, 23:39 -
Sending offset to node
Development • 31 Jan 2025, 00:59 • bsl88k 4 Feb 2025, 12:14 -
Radio waking up for no reason.
Development • 4 Jul 2020, 21:09 • Sasquatch 15 Jan 2025, 08:33 -
Home Assistant/MySensors quirks
Development • 29 days ago • OldSurferDude 29 days ago