mysensor error-handling missing ?



  • I have a big problem and can't get it solved..

    I want to use some error-handling to my sensor-devices but it seems to be it's not available or i am doing something wrong 😎

    For example: If you want to make a program for a distance-sensor (arduino) which must work STANDALONE and if installed: also with a NRF24L01 using Mysensors.h -
    the program doesn't work at all if the NRF24L01 is not installed.. (I have tested it).

    When the sensor is powered on without NRF24L01 installed, I see this in the logs:

    0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.0
    3 TSM:INIT
    4 TSF:WUR:MS=0
    11 !TSM:INIT:TSP FAIL
    12 TSM:FAIL:CNT=1
    14 TSM:FAIL:PDT
    10016 TSM:FAIL:RE-INIT
    10018 TSM:INIT
    10024 !TSM:INIT:TSP FAIL
    10028 TSM:FAIL:CNT=2
    10029 TSM:FAIL:PDT

    When the sensor is powered with NRF24L01 installed but without available gateway (I use Domoticz), same issue.
    When the sensor is powered with NRF24L01 installed AND available gateway, it works great !

    I have looked everywhere, but didn't found a way to fix this.

    I hope somebody can help and show us how to fix this...

    😉 Arthur

    Look below for an example:

    ======================

    #include <NewPing.h>

    #include <TM1638.h>
    // define a module on data pin 2, clock pin 3 and strobe pin 4
    TM1638 module(2, 3, 4);

    byte dots = 1;
    long value = 0x1234ABCD;

    // Enable debug prints
    #define MY_DEBUG

    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69

    #include <SPI.h>
    #include <MySensors.h>

    #define CHILD_ID 1
    #define TRIGGER_PIN 6 // Arduino pin tied to trigger pin on the ultrasonic sensor.
    #define ECHO_PIN 5 // Arduino pin tied to echo pin on the ultrasonic sensor.
    #define MAX_DISTANCE 150 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
    unsigned long SLEEP_TIME = 500; // Sleep time between reads (in milliseconds)

    NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
    MyMessage msg(CHILD_ID, V_DISTANCE);
    int lastDist;
    bool metric = true;

    void setup()
    {
    if (Serial.available()) {
    Serial.begin(115200);
    }
    // metric = getControllerConfig().isMetric;

    // display a hexadecimal number and set the left 4 dots
    //module.setDisplayToHexNumber(0x1234ABCD, 0x00);
    module.setDisplayToString("ZOUTVAT");

    delay(3000);

    }

    void presentation() {
    // Send the sketch version information to the gateway and Controller
    sendSketchInfo("Waterontharder-zoutvat", "1.0");

    if (Serial) {
    // Register all sensors to gw (they will be created as child devices)
    present(CHILD_ID, S_DISTANCE);
    }
    }

    void loop()
    {
    int dist = metric?sonar.ping_cm():sonar.ping_in();
    if (Serial) {
    Serial.print("Ping: ");
    Serial.print(dist); // Convert ping time to distance in cm and print result (0 = outside set distance range)
    Serial.println(metric?" cm":" in");
    } else {
    sendSketchInfo("Wireless error", "1.0");
    delay(3000);
    }

    module.setDisplayToDecNumber(dist, 1 << 6, false);

    if (dist != lastDist) {
    send(msg.set(dist));
    lastDist = dist;
    }

    sleep(SLEEP_TIME);
    }


  • Mod

    Why would you want to power a mysensors node without the radio module?



  • @gohan

    In this way you can make a sensor-device which can be used as Mysensor Node AND you can use it as stand-alone sensor-device: for example, you can add a Display, buzzer or/and leds to the device and use it in a Mysensor-environment but also as a standalone device where no Mysensor-environment is used.

    I want to make such a sensor-device which will measure the level of a can, the device will get a display which will show the level and a buzzer which must make noise when the level is too low. Would be nice if the same sensor-device could also be used as Mysensor-node. Everything with the same sensor-device and software..

    Beside the above thing, error-handling is always importent, for example: if the Mysensor node as a problem (faulty radio) or the Mysensor gateway has an issue: in these cases you could warn with a blinking red led on the Mysensor-node.. Because it seems to be there is no error-handling in Mysensors available, you must spend more time to find the problem,

    That's why error-handling is very usefull and should be used.


  • Mod

    Well a sensor without the radio is like a plain stand alone arduino, that you coould program without the mysensors library, so no need to load a library that is not used.

    Regarding GW failure, there is

    #define MY_TRANSPORT_WAIT_READY_MS
    

    where you can specify how long it has to wait for a gw connection before moving on with the code.


  • Mod

    In addition to gohan's suggestion you might want to look at the error led option. It is described in the serial gateway example.



  • "#define MY_TRANSPORT_WAIT_READY_MS 100" worked indeed !

    An error-handling is better but this is already nice, my prototype is running now with and without Mysensor-gateway active.

    I will look at the error led option too,

    Thanks !!

    😉 Arthur


Log in to reply
 

Suggested Topics

12
Online

11.4k
Users

11.1k
Topics

112.7k
Posts