New MS node creates lots of random sensors, as well as actual sensors [Domoticz]



  • A load of components I ordered have arrived, and I'm busying myself building new MySensors nodes for my Domoticz setup.

    I'm using DHT11, PIR, and LDR on one board, using the 3in1 sketch from here: https://forum.mysensors.org/topic/404/3-in-1-humidity-temp-and-motion with the MySensors Light Sensor example sketch from the library.

    This is my version:

    //this is as per the forum 3 in 1, but with ldr
    //node id set msnuslly to 10
    
    #include <SPI.h>
    #include <MySensor.h>  
    #include <DHT.h>  
    
    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 1
    #define CHILD_ID_MOT 2   // Id of the sensor child
    #define HUMIDITY_SENSOR_DIGITAL_PIN 4
    
    //ldr stuff
    #define CHILD_ID_LIGHT 3
    #define LIGHT_SENSOR_ANALOG_PIN A1
    //
    
    #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    #define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
    
    
    unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
    
    MySensor gw;
    //ldr stuff
    MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
    int lastLightLevel;
    //
    
    DHT dht;
    float lastTemp;
    float lastHum;
    boolean metric = true; 
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    MyMessage msgMot(CHILD_ID_MOT, V_TRIPPED);
    
    void setup()  
    { 
      gw.begin(NULL,10,false);
      dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
    
      // Send the Sketch Version Information to the Gateway
      gw.sendSketchInfo("Humidity/Motion", "1.0");
    
    
     pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
     
      // Register all sensors to gw (they will be created as child devices)
      gw.present(CHILD_ID_HUM, S_HUM);
      gw.present(CHILD_ID_TEMP, S_TEMP);
      gw.present(CHILD_ID_MOT, S_MOTION);
    
      //ldr stuff
      gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
      //
       
      metric = gw.getConfig().isMetric;
    }
    
    void loop()      
    
    {  
      // Read digital motion value
      boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; 
            
      Serial.println(tripped);
      gw.send(msgMot.set(tripped?"1":"0"));  // Send tripped value to gw 
      
      delay(dht.getMinimumSamplingPeriod());
    
      float temperature = dht.getTemperature();
      if (isnan(temperature)) {
          Serial.println("Failed reading temperature from DHT");
      } else if (temperature != lastTemp) {
        lastTemp = temperature;
        if (!metric) {
          temperature = dht.toFahrenheit(temperature);
        }
        gw.send(msgTemp.set(temperature, 1));
        Serial.print("T: ");
        Serial.println(temperature);
      }
      
      float humidity = dht.getHumidity();
      if (isnan(humidity)) {
          Serial.println("Failed reading humidity from DHT");
      } else if (humidity != lastHum) {
          lastHum = humidity;
          gw.send(msgHum.set(humidity, 1));
          Serial.print("H: ");
          Serial.println(humidity);
      }
    
      //ldr stuff
      int lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23; 
      Serial.print("Light Level: ");
      Serial.println(lightLevel);
      if (lightLevel != lastLightLevel) {
          gw.send(msg.set(lightLevel));
          lastLightLevel = lightLevel;
      }
        // end light measurement
    
      //
     
      // Sleep until interrupt comes in on motion sensor. Send update every two minute. 
      gw.sleep(INTERRUPT,CHANGE, SLEEP_TIME);
    }
    
    

    The sensors appear in Domoticz, and work fine. The next day, a load of additional, random sensors appear:

    0_1489518405146_upload-c805f67c-06e6-4447-afbe-7487134783c2

    Has anybody experienced this before? Does my code look OK? Thanks so much for any help!



  • Domoticz > Settings > uncheck "Accept new Hardware Devices". Don't forget to click Apply Settings.


  • Mod

    @HarryDutch
    I had mine checked all the time but I never had this problem



  • These do look like spurious sensors created by my most recent node, for some reason. Rather than nodes from my neighbours being picked up, or similar.

    Incidentally, the actual sensors on this node have stopped updating in Domoticz since the random sensors have appeared.

    This is what my USB Serial MySensors gateway sees. Using library 1.5.1.

    0_1489540411689_upload-1fbefdde-6316-4d5a-9fc3-2c2d89bb975c


  • Mod

    Just wondering why you haven't updated the mysensors library



  • Because it would require updating my Gateway which is in a somewhat inaccessible place right now. That's running 1.5.1 which is when I started playing with MySensors.

    There's no way I can update it over the air, or somesuch, is there?


  • Mod

    @velkrosmaak unless it's an esp8266, I don't think you can



  • This particular one is running on an Arduino Duemilanove, but the sensor and gateway are both using the same library version (1.5.1) so that should be all good, no?


Log in to reply
 

Suggested Topics

52
Online

11.4k
Users

11.1k
Topics

112.6k
Posts