Can't change Node ID



  • 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;
    }
    }

    }


  • Mod

    @Newzwaver said in Can't change Node ID:

    #define MY__ID 9 /

    I'd look here for your problem



  • 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?


  • Mod

    I meant the define is wrong


  • Hero Member

    try

    #define MY_NODE_ID 9
    
    

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



  • Thanks, that worked.


Log in to reply
 

Suggested Topics

15
Online

11.4k
Users

11.1k
Topics

112.7k
Posts