Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. Can't change Node ID

Can't change Node ID

Scheduled Pinned Locked Moved Troubleshooting
6 Posts 3 Posters 2.4k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Newzwaver
    wrote on last edited by
    #1

    HI Everyone,

    This is the fridge sensor that Bulldog and Pete B put together, I had it working but since the vera update any new mysensors loading always load with the same node id even when i try to change it manually as in the sketch below, any idea what I am doing wrong? The node loads only as 254 node......

    Please help.

    #include <DallasTemperature.h>
    #include <OneWire.h>
    #include <Bounce2.h>

    //MySensors configuration options
    #define MY_DEBUG //Uncomment to enable MySensors related debug messages (additional debug options are below)
    #define MY_RADIO_NRF24 // Enable and select radio type attached
    #define MY__ID 9 //Manually set the ID here. Comment out to auto assign
    #include <MySensors.h>

    #define SKETCH_NAME "White Refrigerator Monitor"
    #define SKETCH_VERSION "1.1b"

    #define DWELL_TIME 20 //value used in all wait calls (in milliseconds) this allows for radio to come back to power after a transmission, ideally 0

    #define ONE_WIRE_BUS 3 // Pin where dallas sensors are connected
    #define TEMPERATURE_PRECISION 12 //The resolution of the sensor

    OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
    DallasTemperature dallasTemp(&oneWire); // Pass our oneWire reference to Dallas Temperature.

    //MySensor gw;
    unsigned long tempDelay = 225000;
    float lastTemperature[2];
    unsigned long tempMillis;
    bool metric = false;

    // arrays to hold device addresses
    DeviceAddress dallasAddresses[] = {
    {0x28, 0xFF, 0x4F, 0x87, 0x70, 0x17, 0x4, 0x9D}, //Freezer Address -- 1 Modify for your sensors
    {0x28, 0xFF, 0x25, 0x59, 0x70, 0x17, 0x4, 0x25} //Fridge Address -- 2 Modify for your sensors
    };

    //Set up debouncer (used for door sensors)
    Bounce debouncer[] = {
    Bounce(),
    Bounce()
    };

    //Make sure to match the order of doorPins to doorChildren.
    //The pins on your Arduino
    int doorPins[] = {4, 5};
    //The child ID that will be sent to your controller
    int doorChildren[] = {32, 33};
    //Freezer temp will be Child 0 and Fridge temp will be Child 1

    //used to keep track of previous values contact sensor values
    uint8_t oldValueContact[] = {1, 1};

    uint8_t doorLedPins[] = {6, 7};

    // Initialize temperature message
    MyMessage dallasMsg(0, V_TEMP);
    MyMessage doorMsg(0, V_TRIPPED);

    void presentation()
    {
    // Send the sketch version information to the gateway
    sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);

    // Register all sensors to gw (they will be created as child devices)
    // Present temp sensors to controller
    for (uint8_t i = 0; i < 2; i++) {
    present(i, S_TEMP);
    wait(DWELL_TIME);
    }
    // Present door sensors to controller
    for (uint8_t i = 0; i < 2; i++) {
    present(doorChildren[i], S_DOOR);
    wait(DWELL_TIME);
    }
    }

    void setup()
    {
    // Startup OneWire
    dallasTemp.begin();

    // set the temp resolution
    for (uint8_t i = 0; i < 2; i++) {
    dallasTemp.setResolution(dallasAddresses[i], TEMPERATURE_PRECISION);
    }

    // // Startup and initialize MySensors library. Set callback for incoming messages.
    // gw.begin(NULL, NODE_ID);
    //
    // // Send the sketch version information to the gateway and Controller
    // gw.sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);

    //Set up door contacts & LEDs
    for (uint8_t i = 0; i < 2; i++) {

    // Setup the pins & activate internal pull-up
    pinMode(doorPins[i], INPUT_PULLUP);
    
    // Activate internal pull-up
    //digitalWrite(doorPins[i], HIGH);
    
    // After setting up the button, setup debouncer
    debouncer[i].attach(doorPins[i]);
    debouncer[i].interval(700); //This is set fairly high because when my door was shut hard it caused the other door to bounce slightly and trigger open.
    
    //Set up LEDs
    pinMode(doorLedPins[i], OUTPUT);
    digitalWrite(doorLedPins[i], LOW);
    

    }

    }

    void loop()
    {
    unsigned long currentMillis = millis();

    if (currentMillis - tempMillis > tempDelay) {
    // Fetch temperatures from Dallas sensors
    dallasTemp.requestTemperatures();

    // Read temperatures and send them to controller
    for (uint8_t i = 0; i < 2; i++) {
    
      // Fetch and round temperature to one decimal
      float temperature = static_cast<float>(static_cast<int>((metric ? dallasTemp.getTempC(dallasAddresses[i]) : dallasTemp.getTempF(dallasAddresses[i])) * 10.)) / 10.;
      // Only send data if temperature has changed and no error
      if (lastTemperature[i] != temperature && temperature != -127.00) {
    
        // Send in the new temperature
        send(dallasMsg.setSensor(i).set(temperature, 1));
        lastTemperature[i] = temperature;
      }
    }
    tempMillis = currentMillis;
    

    }

    for (uint8_t i = 0; i < 2; i++) {
    debouncer[i].update();
    // Get the update value
    uint8_t value = debouncer[i].read();
    if (value != oldValueContact[i]) {
    // Send in the new value
    send(doorMsg.setSensor(doorChildren[i]).set(value == HIGH ? "1" : "0"));
    digitalWrite(doorLedPins[i], value);
    oldValueContact[i] = value;
    }
    }

    }

    gohanG 1 Reply Last reply
    0
    • N Newzwaver

      HI Everyone,

      This is the fridge sensor that Bulldog and Pete B put together, I had it working but since the vera update any new mysensors loading always load with the same node id even when i try to change it manually as in the sketch below, any idea what I am doing wrong? The node loads only as 254 node......

      Please help.

      #include <DallasTemperature.h>
      #include <OneWire.h>
      #include <Bounce2.h>

      //MySensors configuration options
      #define MY_DEBUG //Uncomment to enable MySensors related debug messages (additional debug options are below)
      #define MY_RADIO_NRF24 // Enable and select radio type attached
      #define MY__ID 9 //Manually set the ID here. Comment out to auto assign
      #include <MySensors.h>

      #define SKETCH_NAME "White Refrigerator Monitor"
      #define SKETCH_VERSION "1.1b"

      #define DWELL_TIME 20 //value used in all wait calls (in milliseconds) this allows for radio to come back to power after a transmission, ideally 0

      #define ONE_WIRE_BUS 3 // Pin where dallas sensors are connected
      #define TEMPERATURE_PRECISION 12 //The resolution of the sensor

      OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
      DallasTemperature dallasTemp(&oneWire); // Pass our oneWire reference to Dallas Temperature.

      //MySensor gw;
      unsigned long tempDelay = 225000;
      float lastTemperature[2];
      unsigned long tempMillis;
      bool metric = false;

      // arrays to hold device addresses
      DeviceAddress dallasAddresses[] = {
      {0x28, 0xFF, 0x4F, 0x87, 0x70, 0x17, 0x4, 0x9D}, //Freezer Address -- 1 Modify for your sensors
      {0x28, 0xFF, 0x25, 0x59, 0x70, 0x17, 0x4, 0x25} //Fridge Address -- 2 Modify for your sensors
      };

      //Set up debouncer (used for door sensors)
      Bounce debouncer[] = {
      Bounce(),
      Bounce()
      };

      //Make sure to match the order of doorPins to doorChildren.
      //The pins on your Arduino
      int doorPins[] = {4, 5};
      //The child ID that will be sent to your controller
      int doorChildren[] = {32, 33};
      //Freezer temp will be Child 0 and Fridge temp will be Child 1

      //used to keep track of previous values contact sensor values
      uint8_t oldValueContact[] = {1, 1};

      uint8_t doorLedPins[] = {6, 7};

      // Initialize temperature message
      MyMessage dallasMsg(0, V_TEMP);
      MyMessage doorMsg(0, V_TRIPPED);

      void presentation()
      {
      // Send the sketch version information to the gateway
      sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);

      // Register all sensors to gw (they will be created as child devices)
      // Present temp sensors to controller
      for (uint8_t i = 0; i < 2; i++) {
      present(i, S_TEMP);
      wait(DWELL_TIME);
      }
      // Present door sensors to controller
      for (uint8_t i = 0; i < 2; i++) {
      present(doorChildren[i], S_DOOR);
      wait(DWELL_TIME);
      }
      }

      void setup()
      {
      // Startup OneWire
      dallasTemp.begin();

      // set the temp resolution
      for (uint8_t i = 0; i < 2; i++) {
      dallasTemp.setResolution(dallasAddresses[i], TEMPERATURE_PRECISION);
      }

      // // Startup and initialize MySensors library. Set callback for incoming messages.
      // gw.begin(NULL, NODE_ID);
      //
      // // Send the sketch version information to the gateway and Controller
      // gw.sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);

      //Set up door contacts & LEDs
      for (uint8_t i = 0; i < 2; i++) {

      // Setup the pins & activate internal pull-up
      pinMode(doorPins[i], INPUT_PULLUP);
      
      // Activate internal pull-up
      //digitalWrite(doorPins[i], HIGH);
      
      // After setting up the button, setup debouncer
      debouncer[i].attach(doorPins[i]);
      debouncer[i].interval(700); //This is set fairly high because when my door was shut hard it caused the other door to bounce slightly and trigger open.
      
      //Set up LEDs
      pinMode(doorLedPins[i], OUTPUT);
      digitalWrite(doorLedPins[i], LOW);
      

      }

      }

      void loop()
      {
      unsigned long currentMillis = millis();

      if (currentMillis - tempMillis > tempDelay) {
      // Fetch temperatures from Dallas sensors
      dallasTemp.requestTemperatures();

      // Read temperatures and send them to controller
      for (uint8_t i = 0; i < 2; i++) {
      
        // Fetch and round temperature to one decimal
        float temperature = static_cast<float>(static_cast<int>((metric ? dallasTemp.getTempC(dallasAddresses[i]) : dallasTemp.getTempF(dallasAddresses[i])) * 10.)) / 10.;
        // Only send data if temperature has changed and no error
        if (lastTemperature[i] != temperature && temperature != -127.00) {
      
          // Send in the new temperature
          send(dallasMsg.setSensor(i).set(temperature, 1));
          lastTemperature[i] = temperature;
        }
      }
      tempMillis = currentMillis;
      

      }

      for (uint8_t i = 0; i < 2; i++) {
      debouncer[i].update();
      // Get the update value
      uint8_t value = debouncer[i].read();
      if (value != oldValueContact[i]) {
      // Send in the new value
      send(doorMsg.setSensor(doorChildren[i]).set(value == HIGH ? "1" : "0"));
      digitalWrite(doorLedPins[i], value);
      oldValueContact[i] = value;
      }
      }

      }

      gohanG Offline
      gohanG Offline
      gohan
      Mod
      wrote on last edited by
      #2

      @Newzwaver said in Can't change Node ID:

      #define MY__ID 9 /

      I'd look here for your problem

      1 Reply Last reply
      1
      • N Offline
        N Offline
        Newzwaver
        wrote on last edited by
        #3

        Hi
        Thanks and I have changed the ID as follows;
        #define MY__ID 9 //Manually set the ID here. Comment out to auto assign
        //#define MY__ID 9 //Manually set the ID here. Comment out to auto assign

        No matter what i do I still get node 254,. Still most be something I am missing, any ideas?

        1 Reply Last reply
        0
        • gohanG Offline
          gohanG Offline
          gohan
          Mod
          wrote on last edited by
          #4

          I meant the define is wrong

          1 Reply Last reply
          0
          • Boots33B Offline
            Boots33B Offline
            Boots33
            Hero Member
            wrote on last edited by
            #5

            try

            #define MY_NODE_ID 9
            
            

            You can also use the ClearEepromConfig sketch from the MySensors examples to reset your arduino saved settings.

            1 Reply Last reply
            0
            • N Offline
              N Offline
              Newzwaver
              wrote on last edited by
              #6

              Thanks, that worked.

              1 Reply Last reply
              1

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              10

              Online

              11.9k

              Users

              11.2k

              Topics

              113.4k

              Posts


              Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • MySensors
              • OpenHardware.io
              • Categories
              • Recent
              • Tags
              • Popular