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. Bug Reports
  3. Bug in SenseBenderDefault sketch

Bug in SenseBenderDefault sketch

Scheduled Pinned Locked Moved Bug Reports
8 Posts 4 Posters 1.8k 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.
  • TheoLT Offline
    TheoLT Offline
    TheoL
    Contest Winner
    wrote on last edited by
    #1

    I was wondering why my SenseBender kept reporting every minute, even though the temperature and humidity didn't change.

    It's a minor one. But in the sendTempHumidityMeasurements(bool force) method, the difference is determined by dividing with 100 and not 100.0 this causes a wrong rounding and always reports a difference higher than the treshhold. Resulting in a temperature report every minute. Even though the temperature hasn't changed much.

    corrected code.

    /*********************************************
     *
     * Sends temperature and humidity from Si7021 sensor
     *
     * Parameters
     * - force : Forces transmission of a value (even if it's the same as previous measurement)
     *
     *********************************************/
    void sendTempHumidityMeasurements(bool force)
    {
      bool tx = force;
      
      si7021_env data = humiditySensor.getHumidityAndTemperature();
      float oldAvgHum = raHum.getAverage();
      
      raHum.addValue(data.humidityPercent);
      
      float diffTemp = abs(lastTemperature - (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths)/100.0); // <-- fixed
      float diffHum = abs(oldAvgHum - raHum.getAverage());
    
      Serial.print(F("TempDiff :"));Serial.println(diffTemp);
      Serial.print(F("HumDiff  :"));Serial.println(diffHum); 
    
      if (isnan(diffHum)) tx = true; 
      if (diffTemp > TEMP_TRANSMIT_THRESHOLD) tx = true;
      if (diffHum >= HUMI_TRANSMIT_THRESHOLD) tx = true;
    
      if (tx) {
        measureCount = 0;
        float temperature = (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths) / 100.0;
         
        int humidity = data.humidityPercent;
        Serial.print("T: ");Serial.println(temperature);
        Serial.print("H: ");Serial.println(humidity);
        
        gw.send(msgTemp.set(temperature,1));
        gw.send(msgHum.set(humidity));
        lastTemperature = temperature;
        lastHumidity = humidity;
      }
    }
    

    ps. I'm sorry I don't have a github account.

    1 Reply Last reply
    1
    • mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by
      #2

      nice catch!

      TheoLT 1 Reply Last reply
      0
      • mfalkviddM mfalkvidd

        nice catch!

        TheoLT Offline
        TheoLT Offline
        TheoL
        Contest Winner
        wrote on last edited by
        #3

        @mfalkvidd Thanx! It took my a while, but got it.

        1 Reply Last reply
        0
        • TheoLT Offline
          TheoLT Offline
          TheoL
          Contest Winner
          wrote on last edited by
          #4

          Also, do I compile the Sketch for 8Mhz or 1Mhz?

          1 Reply Last reply
          0
          • hekH Offline
            hekH Offline
            hek
            Admin
            wrote on last edited by hek
            #5

            From what I can tell, this has already been fixed:

            https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/examples/SensebenderMicro/SensebenderMicro.ino#L248

            Back in October :)

            https://github.com/mysensors/Arduino/blame/development/libraries/MySensors/examples/SensebenderMicro/SensebenderMicro.ino#L248

            mfalkviddM 1 Reply Last reply
            0
            • hekH hek

              From what I can tell, this has already been fixed:

              https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/examples/SensebenderMicro/SensebenderMicro.ino#L248

              Back in October :)

              https://github.com/mysensors/Arduino/blame/development/libraries/MySensors/examples/SensebenderMicro/SensebenderMicro.ino#L248

              mfalkviddM Offline
              mfalkviddM Offline
              mfalkvidd
              Mod
              wrote on last edited by
              #6

              @hek so the real problem is too long release cycles, and/or not enough backporting?

              1 Reply Last reply
              0
              • hekH Offline
                hekH Offline
                hek
                Admin
                wrote on last edited by
                #7

                Yes! :anguished:

                1 Reply Last reply
                0
                • tbowmoT Offline
                  tbowmoT Offline
                  tbowmo
                  Admin
                  wrote on last edited by
                  #8

                  @TheoL

                  the sensebender is runing on 8Mhz as default. Originally I made so that it could switch to 1Mhz in order to lower the current consumption. But since we are sleeping for 99% of the time, where it's only the watchdog timer that is running, I don't see that much of a power savings running at 1Mhz, compared to 8Mhz.

                  In theory if running on 1Mhz the awaken time is also 8 times longer, than when it's running on 8Mhz.. So that can also contribute to a more "equal" power consumption.

                  So in short.. Compile for 8Mhz :)

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


                  11

                  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