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 -
Saving last known good state, but not in EEPROM
Development • 30 Jan 2024, 18:46 • OldSurferDude 15 Jan 2025, 08:51 -
LAN8720A - will mysensors work with this module
Development • 13 Nov 2024, 17:06 • Marcin 15 Nov 2024, 10:59 -
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 -
PJON and Minicore not working
Development • 21 Mar 2025, 19:51 • Trand 21 Mar 2025, 19:51