{DEV} Multi-Sensor Node goes into boot loop



  • Hi,

    I'm trying to make a multi-sensor node for my porch. I want the sensor to have a Temp/Motion/LUX sensors and have used the Dallas temp sensor and BH1750 Lux sensor for this project. I have tested the individual components on their own, and each of them works (not with the MySensors library but on their own).

    I am using the 2.0 DEV branch and trying to combine the example sketches for the above sensors into one. I can compile fine, but when I try to boot, I go into a boot loop with the Arduino. This is the output from the Serial window after enabling Debug:

    Starting sensor (RNNNA-, 2.0.0-beta)
    TSM:INIT
    TSM:RADIO:OK
    TSP:ASSIGNID:OK (ID=21)
    TSM:FPAR
    TSP:MSG:SEND 21-21-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 4-4-21 s=255,c=3,t=8,pt=1,l=1,sg=0:2
    TSP:MSG:FPAR RES (ID=4, dist=2)
    TSP:MSG:PAR OK (ID=4, dist=3)
    TSP:MSG:READ 0-0-21 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSP:MSG:READ 2-2-21 s=255,c=3,t=8,pt=1,l=1,sg=0:2
    TSP:MSG:FPAR RES (ID=2, dist=2)
    TSP:MSG:READ 14-14-21 s=255,c=3,t=8,pt=1,l=1,sg=0:1
    TSP:MSG:FPAR RES (ID=14, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=21)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 21-21-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    TSP:CHKUPL:FAIL (hops=255)
    !TSM:UPL:FAIL
    TSM:FPAR
    TSP:MSG:SEND 21-21-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 4-4-21 s=255,c=3,t=8,pt=1,l=1,sg=0:2
    TSP:MSG:FPAR RES (ID=4, dist=2)
    TSP:MSG:PAR OK (ID=4, dist=3)
    TSP:MSG:READ 0-0-21 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSP:MSG:READ 2-2-21 s=255,c=3,t=8,pt=1,l=1,sg=0:2
    TSP:MSG:FPAR RES (ID=2, dist=2)
    TSP:MSG:READ 14-14-21 s=255,c=3,t=8,pt=1,l=1,sg=0:1
    TSP:MSG:FPAR RES (ID=14, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=21)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 21-21-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    TSP:CHKUPL:FAIL (hops=255)
    !TSM:UPL:FAIL
    TSM:FPAR
    TSP:MSG:SEND 21-21-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 4-4-21 s=255,c=3,t=8,pt=1,l=1,sg=0:2
    TSP:MSG:FPAR RES (ID=4, dist=2)
    TSP:MSG:PAR OK (ID=4, dist=3)
    TSP:MSG:READ 0-0-21 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSP:MSG:READ 2-2-21 s=255,c=3,t=8,pt=1,l=1,sg=0:2
    TSP:MSG:FPAR RES (ID=2, dist=2)
    TSP:MSG:READ 14-14-21 s=255,c=3,t=8,pt=1,l=1,sg=0:1
    TSP:MSG:FPAR RES (ID=14, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=21)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 21-21-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    TSP:CHKUPL:FAIL (hops=255)
    !TSM:UPL:FAIL
    TSM:FPAR
    TSP:MSG:SEND 21-21-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 4-4-21 s=255,c=3,t=8,pt=1,l=1,sg=0:2
    TSP:MSG:FPAR RES (ID=4, dist=2)
    TSP:MSG:PAR OK (ID=4, dist=3)
    TSP:MSG:READ 2-2-21 s=255,c=3,t=8,pt=1,l=1,sg=0:2
    TSP:MSG:FPAR RES (ID=2, dist=2)
    TSP:MSG:READ 14-14-21 s=255,c=3,t=8,pt=1,l=1,sg=0:1
    TSP:MSG:FPAR RES (ID=14, dist=1)
    TSP:MSG:PAR OK (ID=14, dist=2)
    TSP:MSG:READ 0-0-21 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=21)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 21-21-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    TSP:CHKUPL:FAIL (hops=255)
    !TSM:UPL:FAIL
    TSM:FPAR
    TSP:MSG:SEND 21-21-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 2-2-21 s=255,c=3,t=8,pt=1,l=1,sg=0:2
    TSP:MSG:FPAR RES (ID=2, dist=2)
    TSP:MSG:PAR OK (ID=2, dist=3)
    TSP:MSG:READ 14-14-21 s=255,c=3,t=8,pt=1,l=1,sg=0:1
    TSP:MSG:FPAR RES (ID=14, dist=1)
    TSP:MSG:PAR OK (ID=14, dist=2)
    TSP:MSG:READ 4-4-21 s=255,c=3,t=8,pt=1,l=1,sg=0:2
    TSP:MSG:FPAR RES (ID=4, dist=2)
    TSP:MSG:READ 0-0-21 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=21)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 21-21-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    TSP:CHKUPL:FAIL (hops=255)
    !TSM:UPL:FAIL
    TSM:FPAR
    TSP:MSG:SEND 21-21-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 2-2-21 s=255,c=3,t=8,pt=1,l=1,sg=0:2
    TSP:MSG:FPAR RES (ID=2, dist=2)
    TSP:MSG:PAR OK (ID=2, dist=3)
    TSP:MSG:READ 14-14-21 s=255,c=3,t=8,pt=1,l=1,sg=0:1
    TSP:MSG:FPAR RES (ID=14, dist=1)
    TSP:MSG:PAR OK (ID=14, dist=2)
    TSP:MSG:READ 4-4-21 s=255,c=3,t=8,pt=1,l=1,sg=0:2
    TSP:MSG:FPAR RES (ID=4, dist=2)
    TSP:MSG:READ 0-0-21 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=21)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 21-21-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    TSP:CHKUPL:FAIL (hops=255)
    !TSM:UPL:FAIL
    TSM:FPAR
    TSP:MSG:SEND 21-21-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 2-2-21 s=255,c=3,t=8,pt=1,l=1,sg=0:2
    TSP:MSG:FPAR RES (ID=2, dist=2)
    TSP:MSG:PAR OK (ID=2, dist=3)
    TSP:MSG:READ 14-14-21 s=255,c=3,t=8,pt=1,l=1,sg=0:1
    TSP:MSG:FPAR RES (ID=14, dist=1)
    TSP:MSG:PAR OK (ID=14, dist=2)
    TSP:MSG:READ 4-4-21 s=255,c=3,t=8,pt=1,l=1,sg=0:2
    TSP:MSG:FPAR RES (ID=4, dist=2)
    TSP:MSG:READ 0-0-21 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=21)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 21-21-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    TSP:CHKUPL:FAIL (hops=255)
    !TSM:UPL:FAIL
    TSM:FPAR
    TSP:MSG:SEND 21-21-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 2-2-21 s=255,c=3,t=8,pt=1,l=1,sg=0:2
    TSP:MSG:FPAR RES (ID=2, dist=2)
    TSP:MSG:PAR OK (ID=2, dist=3)
    TSP:MSG:READ 14-14-21 s=255,c=3,t=8,pt=1,l=1,sg=0:1
    TSP:MSG:FPAR RES (ID=14, dist=1)
    TSP:MSG:PAR OK (ID=14, dist=2)
    TSP:MSG:READ 4-4-21 s=255,c=3,t=8,pt=1,l=1,sg=0:2
    TSP:MSG:FPAR RES (ID=4, dist=2)
    TSP:MSG:READ 0-0-21 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=21)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 21-21-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    TSP:CHKUPL:FAIL (hops=255)
    !TSM:UPL:FAIL
    TSM:FPAR
    TSP:MSG:SEND 21-21-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 2-2-21 s=255,c=3,t=8,pt=1,l=1,sg=0:2
    TSP:MSG:FPAR RES (ID=2, dist=2)
    TSP:MSG:PAR OK (ID=2, dist=3)
    TSP:MSG:READ 14-14-21 s=255,c=3,t=8,pt=1,l=1,sg=0:1
    TSP:MSG:FPAR RES (ID=14, dist=1)
    TSP:MSG:PAR OK (ID=14, dist=2)
    TSP:MSG:READ 4-4-21 s=255,c=3,t=8,pt=1,l=1,sg=0:2
    TSP:MSG:FPAR RES (ID=4, dist=2)
    TSP:MSG:READ 0-0-21 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=21)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 21-21-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    

    And this is the sketch:

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Henrik Ekblad
     * 
     * DESCRIPTION
     * Motion Sensor example using HC-SR501 
     * http://www.mysensors.org/build/motion
     *
     */
    
    // Enable debug prints
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    #define MY_NODE_ID 21
    #include <SPI.h>
    #include <MySensors.h>
    #include <DallasTemperature.h>
    #include <OneWire.h>
    #include <BH1750.h>
    #include <Wire.h>
    
    
    unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
    #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
    #define ONE_WIRE_BUS 4 // Pin where dallase sensor is connected 
    #define MAX_ATTACHED_DS18B20 16
    OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
    DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. 
    float lastTemperature[MAX_ATTACHED_DS18B20];
    int numSensors=0;
    boolean receivedConfig = false;
    boolean metric = true;
    
    
    #define CHILD_ID_MOTION 1   // Id of the sensor child
    #define CHILD_ID_TEMP 2   // ID of Temperature Sensor
    #define CHILD_ID_LUX 3  // ID of Lux Sensor
    
    BH1750 lightSensor;
    
    // Initialize motion message
    MyMessage msgMotion(CHILD_ID_MOTION, V_TRIPPED);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    MyMessage msgLux(CHILD_ID_LUX, V_LIGHT_LEVEL);
    
    uint16_t lastlux;
    
    void setup()  
    {  
      pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
      lightSensor.begin();
      // Startup up the OneWire library
      sensors.begin();
      // requestTemperatures() will not block current thread
      sensors.setWaitForConversion(false);
      
    }
    
    void presentation()  {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("yes", "1.0");
    
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID_MOTION, S_MOTION);
      present(CHILD_ID_TEMP, S_TEMP);
      present(CHILD_ID_LUX, S_LIGHT_LEVEL);
    }
    
    void loop()     
    {     
      // Read digital motion value
      boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; 
            
      Serial.println(tripped);
      send(msgMotion.set(tripped?"1":"0"));  // Send tripped value to gw 
    
      {     
      uint16_t lux = lightSensor.readLightLevel();// Get Lux value
      Serial.println(lux);
      if (lux != lastlux) {
          send(msgLux.set(lux));
          lastlux = lux;
      }
    
       // Fetch temperatures from Dallas sensors
      sensors.requestTemperatures();
    
      // query conversion time and sleep until conversion completed
      int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
      // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
      wait(conversionTime);
    
      // Read temperatures and send them to controller 
      for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
     
        // Fetch and round temperature to one decimal
        float temperature = static_cast<float>(static_cast<int>((getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
     
        // Only send data if temperature has changed and no error
        #if COMPARE_TEMP == 1
        if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
        #else
        if (temperature != -127.00 && temperature != 85.00) {
        #endif
     
          // Send in the new temperature
          send(msgTemp.setSensor(i).set(temperature,1));
          // Save new temperatures for next compare
          lastTemperature[i]=temperature;
        }
      }
    
      // Sleep until interrupt comes in on motion sensor. Send update every two minute.
      sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
    }
    }
    
    


  • Same thing here. I am using MQTT gateway.

    #include <string.h>
    #define __FILENAME__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
    #define SKETCH_NAME __FILENAME__
    #define SKETCH_DATE __DATE__
    
    #define MY_DEBUG
    #define MY_RADIO_NRF24
    #define MY_NODE_ID 100
    
    #include <SPI.h>
    #include <MySensors.h>
    #include <Wire.h>
    #include <SI7021.h>
    
    
    Starting sensor (RNNNA-, 2.0.0-beta)
    TSM:INIT
    TSM:RADIO:OK
    TSP:ASSIGNID:OK (ID=100)
    TSM:FPAR
    TSP:MSG:SEND 100-100-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 100-100-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 0-0-100 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=100)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 100-100-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    TSP:CHKUPL:FAIL (hops=255)
    !TSM:UPL:FAIL
    TSM:FPAR
    TSP:MSG:SEND 100-100-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 100-100-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 0-0-100 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=100)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 100-100-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    TSP:CHKUPL:FAIL (hops=255)
    !TSM:UPL:FAIL```


  • Ok, 2.0 looks like to be stable now (-> Master branch) We both struggle at point "CHKUPL" which means "Check Uplink". So, maybe our Gateway has to be updated too. I will give it a try...

    https://github.com/mysensors/MySensors/blob/986389b12591917ecbc44021c63a2cdf6f8c8222/core/MyTransport.cpp#L250



  • Nope. Recompiled MQTT Gateway: Node error persists... CHKUPL:Fail



  • Hm, MQTTGateway only comes up on PC, not on USB power supply. And it is not presenting itself, but sendig local DHT values.



  • MY_DEBUG disabled, MQTT Gateway comes up on regular power. Bug?



  • Well, 2.0 seems buggy. Now my Node is trying to find its parent. Funny, because I told him which to use:

    #define MY_DEBUG
    #define MY_RADIO_NRF24
    #define MY_NODE_ID 10
    #define MY_PARENT_NODE_ID 0
    #define MY_PARENT_NODE_IS_STATIC
    
    Starting sensor (RNNNA-, 2.0.0)
    TSM:INIT
    TSM:RADIO:OK
    TSP:ASSIGNID:OK (ID=10)
    TSM:FPAR
    TSP:MSG:SEND 10-10-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 10-10-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 10-10-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 10-10-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    !TSM:FPAR:FAIL
    !TSM:FAILURE
    TSM:PDT
    

  • Admin

    @rollercontainer We need to look into that - that's not the anticipated behaviour. Please submit an issue on git and we will investigate further. Thanks for the feedback.



  • hi @rollercontainer

    Thanks for looking into this with me. I had some more luck believe it or not after upgrading to 2.0.0 on my Gateway. Using the same sketch as I posted for my node, and updating my ESP8266 Gateway to the 2.0 sketch solved the reboot issue. Only problem now is the DallasTemperature sensor does not seem to be registering with the gateway.

    Of curious notice, when I looked through the example sketches in the new MySensors 2.0 Library, i did not see an example sketch for the DallasTemperature sensors this time around.


  • Mod

    @drock1985 said:

    Of curious notice, when I looked through the example sketches in the new MySensors 2.0 Library, i did not see an example sketch for the DallasTemperature sensors this time around.

    For maintenance reasons, examples depending on external libraries have been removed in 2.0.0, to be placed in a separate repository (work in progress).



  • Getting there.... I had to re-add the OneWire, Wire and DallasTemperature sensor and make a few modifications to the sketch, but I have the beginnings now and it is showing up properly in Home-Assistant and responding nicely. I'm off to make supper, but the only thing I can see needing to modify big time is adding "send temp on change only" and getting the temp to show to a decimal place.

    Here is the sketch for now:

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Henrik Ekblad
     * 
     * DESCRIPTION
     * Motion Sensor example using HC-SR501 
     * http://www.mysensors.org/build/motion
     *
     */
    
    // Enable debug prints
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    #define MY_NODE_ID 21
    #include <SPI.h>
    #include <MySensors.h>
    #include <DallasTemperature.h>
    #include <OneWire.h>
    #include <BH1750.h>
    #include <Wire.h>
    
    
    unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
    #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
    #define ONE_WIRE_BUS 4 // Pin where dallase sensor is connected 
    #define MAX_ATTACHED_DS18B20 16
    OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
    DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. 
    float lastTemperature[MAX_ATTACHED_DS18B20];
    int numSensors=0;
    boolean receivedConfig = false;
    boolean metric = true;
    
    
    #define CHILD_ID_MOTION 1   // Id of the sensor child
    #define CHILD_ID_TEMP 2   // ID of Temperature Sensor
    #define CHILD_ID_LUX 3  // ID of Lux Sensor
    
    BH1750 lightSensor;
    
    // Initialize motion message
    MyMessage msgMotion(CHILD_ID_MOTION, V_TRIPPED);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    MyMessage msgLux(CHILD_ID_LUX, V_LIGHT_LEVEL);
    
    uint16_t lastlux;
    
    void setup()  
    {  
      pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
      lightSensor.begin();
      // Startup up the OneWire library
      sensors.begin();
      // requestTemperatures() will not block current thread
      sensors.setWaitForConversion(false);
      
    }
    
    void presentation()  {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("yes", "1.0");
    
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID_MOTION, S_MOTION);
      present(CHILD_ID_TEMP, S_TEMP);
      present(CHILD_ID_LUX, S_LIGHT_LEVEL);
    }
    
    void loop()     
    {     
      // Read digital motion value
      boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; 
            
      Serial.println(tripped);
      send(msgMotion.set(tripped?"1":"0"));  // Send tripped value to gw 
    
      {     
      uint16_t lux = lightSensor.readLightLevel();// Get Lux value
      Serial.println(lux);
      if (lux != lastlux) {
          send(msgLux.set(lux));
          lastlux = lux;
      }
    
       // Fetch temperatures from Dallas sensors
      sensors.requestTemperatures();
    
    
        // Fetch and round temperature to one decimal
        int temperature = (((sensors.getTempCByIndex(0)) * 10.)) / 10.;
     
          // Send in the new temperature
          send(msgTemp.set(temperature));
        }
      
    
      // Sleep until interrupt comes in on motion sensor. Send update every two minute.
      sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
    }
    
    
    

  • Hero Member

    @drock1985 I had similar problems with the failure messages. After an upgrade of my repeater it functions again. Development seems to have some issues with backward compatibility. Hard to reproduce the errors..



  • @AWI

    Ah, never thought about that. I do have a node/repeater still on 1.5 running. Thanks; now I know my next project.


  • Hardware Contributor

    @rollercontainer said:

    TSP:CHKUPL:FAIL (hops=255)
    !TSM:UPL:FAIL
    

    Did you end up finding what was the problem?
    I have the same errors on new nodes compiled with the stable release. It was working fine on the dev branch before, and my old sensors still works, but not the new ones...

    Edit:
    I had to revert to https://github.com/mysensors/MySensors/tree/244f79771acb60588c6b4fd6dd0fa4b5daf4cb64
    June 26th commit break everything for me. Unfortunately a lot of changes were made this day...



  • read above again:
    Gateway 2.0.0beta with Node 2.0.0 = UPL:FAIL (which means UPLink)
    Gateway 2.0.0 with Node 2.0.0 = FPAR:FAIL (which means FindPARent)

    my error is reported to github, maybe you should do this too with yours?
    https://github.com/mysensors/MySensors/issues


  • Hardware Contributor

    Oh, so just switching from beta to 2.0 master "fixed" UPL:FAIL by switching it to a FPAR:FAIL?
    I thought you did some fixes and then ended up with another error, my bad. Github it is I guess...



  • I am not a coder, just a user. So I am not able to fix errors here.



  • @emc2 said:

    @rollercontainer said:

    TSP:CHKUPL:FAIL (hops=255)
    !TSM:UPL:FAIL
    

    Did you end up finding what was the problem?
    I have the same errors on new nodes compiled with the stable release. It was working fine on the dev branch before, and my old sensors still works, but not the new ones...

    Edit:
    I had to revert to https://github.com/mysensors/MySensors/tree/244f79771acb60588c6b4fd6dd0fa4b5daf4cb64
    June 26th commit break everything for me. Unfortunately a lot of changes were made this day...

    Thank you, had the same problem, replaced it with the files from the 26th and got it working.


  • Hardware Contributor

    @mitchell Glad it was useful.
    Do you also have a Raspberry Pi Gateway with the radio module directly on the GPIO? It seems the problem come from here, issue can now be tracked on https://github.com/mysensors/Raspberry/issues/31

    Also if needed you can replace core/MyHwESP8266.h and core/MyMainESP8266.cpp with the release version so you can use an ESP8266 device too.



  • @emc2 Indeed on a Raspberry with direct connection. Thank you for the link, I will follow the progress.



  • I found out that adding a sleep(10) between 2 consecutive 'send' does help a lot


Log in to reply
 

Suggested Topics

  • 1
  • 10
  • 2
  • 198
  • 2
  • 2

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts