Suspending the node

  • 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;
      // Setup locally attached sensors
    void loop()      
      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: ");
      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: ");
      sleep(SLEEP_TIME); //sleep a bit
      // Send locally attached sensor data here

  • @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.

  • 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

  • @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.

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

  • This post is deleted!

  • @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.

Log in to reply

Suggested Topics

  • 3
  • 2
  • 1
  • 10
  • 2
  • 24