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. Troubleshooting
  3. Suspending the node

Suspending the node

Scheduled Pinned Locked Moved Troubleshooting
7 Posts 2 Posters 75 Views 2 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.
  • RobertR Offline
    RobertR Offline
    Robert
    wrote on last edited by
    #1

    I have 10 DHT sensors. From time to time a few lost suggestion, each time the same. In one of them I uploaded a watchdog, it worked a bit and also crashed. The one with the watchdog causes errors. Compilation is going well.

    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    // Enable RS485 transport layer
    #define MY_RS485
    
    // Define this to enables DE-pin management on defined pin
    #define MY_RS485_DE_PIN 2
    
    // Set RS485 baud rate to use
    #define MY_RS485_BAUD_RATE 9600
    
    // Enable this if RS485 is connected to a hardware serial port
    //#define MY_RS485_HWSERIAL Serial1
    #define MY_NODE_ID 2
    #include <SPI.h>
    #include <MySensors.h>  
    #include <DHT.h>  
    #include <avr/wdt.h>
    
    // Set this to the pin you connected the DHT's data pin to
    #define DHT_DATA_PIN 3
    unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
    
    #define CHILD_ID_HUM 1
    #define CHILD_ID_TEMP 2
    
    DHT dht;
    float lastTemp;
    float lastHum;
    boolean metric = true; 
    
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    
    void presentation()  
    { 
      // Send the sketch version information to the gateway
      sendSketchInfo("TemperatureAndHumidity", "1.1");
      
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID_HUM, S_HUM);
      present(CHILD_ID_TEMP, S_TEMP);
    }
    
    void setup()  
    { 
      dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor 
      metric = getControllerConfig().isMetric;
      wdt_enable(WDTO_2S);
      // Setup locally attached sensors
    }
    
    void loop()      
    {  
      delay(dht.getMinimumSamplingPeriod());
    
      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);
      }
    
      sleep(SLEEP_TIME); //sleep a bit
      wdt_reset();
      // Send locally attached sensor data here
    }
    
    skywatchS 1 Reply Last reply
    0
    • RobertR Robert

      I have 10 DHT sensors. From time to time a few lost suggestion, each time the same. In one of them I uploaded a watchdog, it worked a bit and also crashed. The one with the watchdog causes errors. Compilation is going well.

      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Enable RS485 transport layer
      #define MY_RS485
      
      // Define this to enables DE-pin management on defined pin
      #define MY_RS485_DE_PIN 2
      
      // Set RS485 baud rate to use
      #define MY_RS485_BAUD_RATE 9600
      
      // Enable this if RS485 is connected to a hardware serial port
      //#define MY_RS485_HWSERIAL Serial1
      #define MY_NODE_ID 2
      #include <SPI.h>
      #include <MySensors.h>  
      #include <DHT.h>  
      #include <avr/wdt.h>
      
      // Set this to the pin you connected the DHT's data pin to
      #define DHT_DATA_PIN 3
      unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
      
      #define CHILD_ID_HUM 1
      #define CHILD_ID_TEMP 2
      
      DHT dht;
      float lastTemp;
      float lastHum;
      boolean metric = true; 
      
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      
      void presentation()  
      { 
        // Send the sketch version information to the gateway
        sendSketchInfo("TemperatureAndHumidity", "1.1");
        
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID_HUM, S_HUM);
        present(CHILD_ID_TEMP, S_TEMP);
      }
      
      void setup()  
      { 
        dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor 
        metric = getControllerConfig().isMetric;
        wdt_enable(WDTO_2S);
        // Setup locally attached sensors
      }
      
      void loop()      
      {  
        delay(dht.getMinimumSamplingPeriod());
      
        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);
        }
      
        sleep(SLEEP_TIME); //sleep a bit
        wdt_reset();
        // Send locally attached sensor data here
      }
      
      skywatchS Offline
      skywatchS Offline
      skywatch
      wrote on last edited by skywatch
      #2

      @Robert In order to use the watchdog you need the correct bootloader, which bootloader are you using?

      Also, if your sensors are connected with dupont connectors then these can work loose over time due to thermal expansion and contraction. Dupont connectors are really for quick development and not as good as a soldered joint for deployment. At a push you could try hot glue to hold them in place.

      1 Reply Last reply
      0
      • RobertR Offline
        RobertR Offline
        Robert
        wrote on last edited by
        #3

        Joints should be ok, use thermal glue. I don't know what the bootloader is. This is the arduino pro mini. Atmega 328P 5v 16mhz processor. AVrisp mkII programmer

        skywatchS 1 Reply Last reply
        0
        • RobertR Robert

          Joints should be ok, use thermal glue. I don't know what the bootloader is. This is the arduino pro mini. Atmega 328P 5v 16mhz processor. AVrisp mkII programmer

          skywatchS Offline
          skywatchS Offline
          skywatch
          wrote on last edited by
          #4

          @Robert You need to know what bootloader you are using and if it supports the watchdog timer function. The default ones from China generally don't support watchdog , so you will need to burn a bootloader that supports watchdog.

          1 Reply Last reply
          0
          • RobertR Offline
            RobertR Offline
            Robert
            wrote on last edited by
            #5

            Which bootloader should I use? Is it necessary in my case? Does users mysensors change the bootloader?

            skywatchS 2 Replies Last reply
            0
            • RobertR Robert

              Which bootloader should I use? Is it necessary in my case? Does users mysensors change the bootloader?

              skywatchS Offline
              skywatchS Offline
              skywatch
              wrote on last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • RobertR Robert

                Which bootloader should I use? Is it necessary in my case? Does users mysensors change the bootloader?

                skywatchS Offline
                skywatchS Offline
                skywatch
                wrote on last edited by skywatch
                #7

                @Robert said in Suspending the node:

                Which bootloader should I use?

                Only you can decide the best one for what you want.

                Is it necessary in my case?

                I would say yes it is if you want WDT to operate.

                Does users mysensors change the bootloader?

                That depends on the need case for each individual requirement. Some do, some don't. The ones that do have a specific reason for doing so, like fota or wdt.

                Mysensors has its' own bootloader and I believe that it supports WDT. Optiboot is another popular one but I don't personally know if it supports WDT.

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


                15

                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