Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. How to auto reboot node every 24 hours ?

How to auto reboot node every 24 hours ?

Scheduled Pinned Locked Moved Development
15 Posts 3 Posters 8.0k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • scalzS Offline
    scalzS Offline
    scalz
    Hardware Contributor
    wrote on last edited by scalz
    #6

    @carmelo42

    • interesting question is which Mysensors version are you using? because v2 should be (or at least in short term) is more robust, there are procedure to reconnect etc in the lib (I know that some jeedom user prefers older version ;) )

    During Sleep mode:
    Watchdog is used by sleep(x ms). But not used with sleep forever (deep sleep). As you're using sleep(x ms), it should handle that during the sleeping period.

    During the wake up:
    if it's not enabled, look at the links above. But as described, you will need to put your wdt_reset in your main loop or other places, so if there would be some eternal loop or whatever, it would reset as expected (because of non call of wdt_reset).
    But if your sketch is still working, but lost comm because you would use older version lib, then wdt reset will still be called, and no reset, and you won't get back your comm..

    Shortly:

    • if it's comm related, sure wdt is a good point, but better to update lib
    • if it's sketch related, there may be something blocking somewhere which is not great practice (blocking loop in sketch or in a lib used), in this case wdt will be helpful.
    • if it's hardware related, wdt will also be helpful; you could use an external watchog board in this case
    1 Reply Last reply
    0
    • carlekiC Offline
      carlekiC Offline
      carleki
      wrote on last edited by
      #7

      I will try the v2.0 !
      Juste flash my gateway with the new sketch ?
      Can v1.5.4 nodes and v2.0 nodes work with 2.0 gateway ?

      May be it's quite simply to upgrade to v2.0 and my freeze problems will be solved ...

      1 Reply Last reply
      0
      • scalzS Offline
        scalzS Offline
        scalz
        Hardware Contributor
        wrote on last edited by
        #8

        @carmelo42
        hehe :)
        in fact it's better to run everything with 2.0, beta version (gw and nodes).

        I understand that from a user point of view (with a network quite stable), there can be some apprehension.. plus for the moment the ctrler plugin does not have all the types yet.
        But maybe if you're a warrior you could give a try and see if it improves. Perhaps try simple with a gw+a node and change freq/channel and test on your computer..

        What i can say, compared to <2), is v2 (beta has more commits) is optimized (memory&process), mechanism for better comm reliability, and more debug msg (but they don't look the same as v1.x).
        And the lib is always improving, for the better! no ads hihi :blush:

        Look at the docs for changes in sketch between 1.5 and 2.x. nothing fancy, and you will see that with v2 your sketch readibility has been improved. yeah!
        I hope that will help!

        1 Reply Last reply
        1
        • carlekiC Offline
          carlekiC Offline
          carleki
          wrote on last edited by carleki
          #9

          Ok !

          I will update all my sensors + gw to 2.0 and test it with my sensors (as long as the outside temperatures won't go below 15°C all day I don't need to have my boiler functionnal so I can do some tests :)

          If it's ok I stay with 2.0, if not I can go back to 1.5.4 ;)

          I'm using just temperature nodes, relay actuator nodes and distance nodes : so all the code is available on mysensors website with 2.0 ;)

          1 Reply Last reply
          0
          • carlekiC Offline
            carlekiC Offline
            carleki
            wrote on last edited by
            #10

            @scalz do you know if it's possible to have 1.5.4 and 2.0 in my Arduino IDE ?

            1 Reply Last reply
            0
            • carlekiC Offline
              carlekiC Offline
              carleki
              wrote on last edited by
              #11

              I have installed lib 2.0 on my linux virtual machine. When I try to compile temperature node with battery monitoring here is what I got :

              
              
              /tmp/ccQR5mwk.ltrans1.ltrans.o: In function `loop':
              ccQR5mwk.ltrans1.o:(.text+0x6d4): undefined reference to `Vcc::Read_Volts()'
              /tmp/ccQR5mwk.ltrans2.ltrans.o: In function `global constructors keyed to 65535_0_tempbatv2.ino.cpp.o.2373':
              ccQR5mwk.ltrans2.o:(.text.startup+0x98): undefined reference to `Vcc::Vcc(float)'
              collect2: error: ld returned 1 exit status
              exit status 1
              Error compiling for board Arduino Pro or Pro Mini.
              

              My 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.
               *
               *******************************
               *
               * DESCRIPTION
               *
               * Example sketch showing how to send in DS1820B OneWire temperature readings back to the controller
               * http://www.mysensors.org/build/temp
               */
              
              
              // Enable debug prints to serial monitor
              //#define MY_DEBUG 
              
              // Enable and select radio type attached
              #define MY_RADIO_NRF24
              //#define MY_RADIO_RFM69
              
              #include <SPI.h>
              #include <MySensors.h>  
              #include <DallasTemperature.h>
              #include <OneWire.h>
              #include <Vcc.h>
              
              #define COMPARE_TEMP 0 // Send temperature only if changed? 1 = Yes 0 = No
              #define ID_BatPcnt 1
              #define ID_Bat 2
              
              //const float VccMin   = 1.6;             // Vcc mini attendu, en Volts.
              //const float VccMax   = 3.06;           // Vcc Maximum attendu, en Volts (2 piles AA neuves)
              //const float VccCorrection = 2.52/2.6; // calibration : Vcc mesuré au multimètre / Vcc mesuré par l'Arduino par vcc.Read_Volts() dans sketch 1/2
              //Vcc vcc(VccCorrection);
              
              static const float VccMin = 1.6;        // Minimum expected Vcc level, in Volts. (0.6V for 1 AA Alkaline)
              static const float VccMax = 3.3;        // Maximum expected Vcc level, in Volts. (1.5V for 1 AA Alkaline)
              static const float VccCorrection = 2.52 / 2.6;  // Measured Vcc by multimeter divided by reported Vcc
              Vcc vcc(VccCorrection);
              
              #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
              #define MAX_ATTACHED_DS18B20 16
              unsigned long SLEEP_TIME = 900000; // Sleep time between reads (in milliseconds)
              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;
              bool receivedConfig = false;
              bool metric = true;
              MyMessage msgBAT_PCNT(ID_BatPcnt,V_VAR1); // on utilise le type V_VAR1 pour le % de charge des piles
              MyMessage msgBAT(ID_Bat,V_VAR2);          // on utilise le type V_VAR2 pour la tension des piles
              // Initialize temperature message
              MyMessage msg(0,V_TEMP);
              
              void before()
              {
                // Startup up the OneWire library
                sensors.begin();
              }
              
              void setup()  
              { 
                // requestTemperatures() will not block current thread
                sensors.setWaitForConversion(false);
              }
              
              void presentation() {
                // Send the sketch version information to the gateway and Controller
                sendSketchInfo("Temperature Sensor", "1.1");
              
                // Fetch the number of attached temperature sensors  
                numSensors = sensors.getDeviceCount();
              
                // Present all sensors to controller
                present(ID_BatPcnt, S_CUSTOM);  // type S_CUSTOM pour le capteur "% de charge"
                present(ID_Bat, S_CUSTOM);      // type S_CUSTOM pour le capteur "tension"
                for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {   
                   present(i, S_TEMP);
                }
              }
              
              void loop()     
              {     
                // mesure de Vcc
                    float v = vcc.Read_Volts();
                    // calcul du % de charge batterie
                    float p = 100 * ((v - VccMin) / (VccMax - VccMin));
                    // On envoie les données des capteurs et de l'état de la batterie au Gateway
                    //gw.sendBatteryLevel(p);  // Inutile...
                    send(msgBAT_PCNT.set(p, 1)); // 1 décimale
                    send(msgBAT.set(v, 3));      // 2 décimales
                // 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)
                sleep(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(msg.setSensor(i).set(temperature,1));
                    // Save new temperatures for next compare
                    lastTemperature[i]=temperature;
                  }
                }
                sleep(SLEEP_TIME);
              }
              

              I understand there is a problem with Vcc and vcc float ... but ...

              1 Reply Last reply
              0
              • scalzS Offline
                scalzS Offline
                scalz
                Hardware Contributor
                wrote on last edited by scalz
                #12

                @carmelo42
                your sketch is compiling well for me. Check your arduino and mysensors lib install (save your Mydoc\Arduino folder if you're not sure)

                1 Reply Last reply
                0
                • carlekiC Offline
                  carlekiC Offline
                  carleki
                  wrote on last edited by
                  #13

                  ok ....

                  it is not the 1st time I have problems with lib MYS lib install ... I have done this :

                  on a fresh linux install, DL the Arduino IDE 1.6.5, in the IDE menu, DL the MYS libraries and DallasSensors Temp lib ...

                  Is this the wrong way ?

                  1 Reply Last reply
                  0
                  • scalzS Offline
                    scalzS Offline
                    scalz
                    Hardware Contributor
                    wrote on last edited by scalz
                    #14

                    weird! that's normally easy. I can't tell you about linux though, i'm using windows.
                    Arduino 1.6.8 min for me. do you also use Mysensors beta? (it's better for the moment)
                    For dallastemp, i don't remember, what i can tell you is that your sketch compiled on my machine. and i have not the latest dev version for the moment.
                    Could you try to compile a simple sketch with no external lib for the moment (like the relay sketch with no button for beginning)? so you will be able to know if it's your arduino/mysensors install.

                    1 Reply Last reply
                    0
                    • carlekiC Offline
                      carlekiC Offline
                      carleki
                      wrote on last edited by
                      #15

                      I finally have found the problem : I had only Vcc.h in my VCC folder ... So the .cpp file was misisng !!

                      --> noob alert :)

                      1 Reply Last reply
                      1
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      19

                      Online

                      11.7k

                      Users

                      11.2k

                      Topics

                      113.1k

                      Posts


                      Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • MySensors
                      • OpenHardware.io
                      • Categories
                      • Recent
                      • Tags
                      • Popular