Vera luup engine rebooting.



  • After adding the sensors to vera edge I started to get random luup engine reboots i am not sure what i need to do to fix that issue. I am using RPI3 ethernet gateway. can one of u seasoned veterans take a look and see if i need to make any adjustments on the code side please. it also says controller did not repond under ALTUI.

    #define MY_DEBUG 
    #define MY_RADIO_NRF24
    #include <SPI.h>
    #include <MySensors.h>
    #include <DHT.h>
    
    #define DIGITAL_INPUT_WATER_SENSOR 5 // Digital input did you attach your soil sensor.
    
    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 1
    #define CHILD_ID_MOT 2   // Id of the sensor child
    #define CHILD_ID_LIGHT 3
    #define CHILD_ID_WAT 4      // Child id for Motion
    
    #define LIGHT_SENSOR_PIN A0 //Ambient light sensor reading 
    #define WATER_LEAK_PIN 5
    #define HUMIDITY_SENSOR_DIGITAL_PIN 4
    #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)
    
    DHT dht;
    float lastTemp;
    float lastHum;
    boolean metric = true; 
    uint16_t lastlux;
    
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    MyMessage msgMot(CHILD_ID_MOT, V_TRIPPED);
    MyMessage msgWat(CHILD_ID_WAT, V_TRIPPED);
    MyMessage msgLight(CHILD_ID_LIGHT,  V_LIGHT_LEVEL);
    int lastWaterValue = -1; 
    int lastLightLevel;
    
    void setup()  
    { 
      dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
      pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
      pinMode(DIGITAL_INPUT_WATER_SENSOR, INPUT);
      pinMode(LIGHT_SENSOR_PIN, INPUT);   
    } 
     
     void presentation()
    {   
      // Send the Sketch Version Information to the Gateway
      sendSketchInfo("Humidity/Motion", "1.0");
     
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID_HUM, S_HUM);
      present(CHILD_ID_TEMP, S_TEMP);
      present(CHILD_ID_MOT, S_MOTION);
      present(CHILD_ID_WAT, S_MOISTURE);
      present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);  
    }
    
    void loop()
    {
      // Read digital motion value
        bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
    
        Serial.println(tripped);
        send(msgMot.set(tripped?"1":"0"));  // Send tripped value to gw
    
       
      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);
        }
        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;
          send(msgHum.set(humidity, 1));
          Serial.print("H: ");
          Serial.println(humidity);
      
    }
    
    int WaterValue = digitalRead(DIGITAL_INPUT_WATER_SENSOR); // 1 = Not triggered, 0 = In water
    if (WaterValue != lastWaterValue) {
    Serial.println(WaterValue);
    if (WaterValue==0)
    {
    Serial.println("Water!!!");
    send(msgWat.set("Water"));
    }
    else
    {
    Serial.println("No Water");
    send(msgWat.set("No Water")); // Send tripped when water detected
    lastWaterValue = WaterValue;
    
    }
         // Read lux from TEMT6000
       uint16_t lightLevel = analogRead(LIGHT_SENSOR_PIN);  // 1000/1024
      if (int(lightLevel - lastLightLevel) > 5 || int(lastLightLevel - lightLevel) > 5) {
          send(msgLight.setSensor(CHILD_ID_LIGHT).set(lightLevel,1));
         }
     }
     // Sleep until interrupt comes in on motion sensor. Send update every two minute.
        sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
    }
    
    

Log in to reply
 

Suggested Topics

  • 1
  • 3
  • 1
  • 5
  • 1

16
Online

11.4k
Users

11.1k
Topics

112.7k
Posts