No Sleep is driving me crazy!



  • I folloed the api and have done what I believe to be correct, but obviously isn't as I get a compile warning.

    So why does this fail to work at the end of the loop?

     int8_t sleep(int 1, int FALLING, unsigned long SLEEP_TIME);
    

    See here for api instructions I followed.... https://www.mysensors.org/download/sensor_api_20#sleeping

    Thanks for any pointers here.....


  • Mod

    @skywatch what is the return value of the sleep function?
    Are you perhaps using an esp8266?


  • Mod

    @skywatch and, as always, which mySensors version are you using...



  • I am using mysensors 2.1.1 which I believe is the latest one.

    But I get a compiler error with arduino IDE 1.8.3 when I add the line exactly as shown above. I have treid various combinations to try and solve the issue, but that's as far as I can get.

    It might be a library issue as I had that earlier this week! Here is the error output as it appears after compilation check

    C:\Users\captain\Documents\Arduino\MYS-Cinema-0.1\MYS-Cinema-0.1.ino: In function 'void loop()':
    
    MYS-Cinema-0.1:130: error: expected ',' or '...' before numeric constant
    
       int8_t smartSleep(int 1, int FALLING, unsigned long ms=27000);
    
                             ^
    
    Multiple libraries were found for "SPI.h"
     Used: C:\Program Files (x86)\Arduino1.8.3\hardware\arduino\avr\libraries\SPI
     Not used: C:\Users\captain\Documents\Arduino\libraries\SPI
    Multiple libraries were found for "Wire.h"
     Used: C:\Program Files (x86)\Arduino1.8.3\hardware\arduino\avr\libraries\Wire
     Not used: C:\Users\captain\Documents\Arduino\libraries\Wire
    exit status 1
    expected ',' or '...' before numeric constant
    

    The set up is pro-mini with htu21DF, NRF24L01+, Door sensor.

    You might see what the problem is from that!

    Thanks for your time.


  • Mod

    @skywatch start by upgrading to development branch (2.2.0 beta) as sleep and interrupts is broken in 2.1.x



  • @skywatch are you trying to compile this piece of code:
    int8_t sleep(int 1, int FALLING, unsigned long SLEEP_TIME);

    ?
    because this is not a valid c code ...


  • Mod

    @skywatch try changing to

    int8_t sleepReturn = smartSleep(1, FALLING, 27000);
    Serial.println(sleepReturn);
    


  • Do I replace 2.1.1 with dev or add it over the top? The contents are different comparing the two.

    And can someone please add this 'broken' bit to the API so others don't waste hours of their time too.



  • @mfalkvidd

    Thanks this does compile OK (the value of examples) - But wiil it work as expected if sleep is broken in 2.1.1?

    int8_t smartSleep(1, FALLING, 27000); 
    

    Also, is this all that is needed for the interrupt to work or do I need to declare it as I would in an arduino sketch?

    thanks



  • Secret then is it?


  • Mod

    @skywatch I think you are confusing "secret" with "unknown".


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.