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 2.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.
  • T Offline
    T 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!

      T 1 Reply Last reply
      0
      • mfalkviddM mfalkvidd

        nice catch!

        T Offline
        T 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
        • T Offline
          T 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
          • H Offline
            H 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
            • H 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
              • H Offline
                H Offline
                hek
                Admin
                wrote on last edited by
                #7

                Yes! :anguished:

                1 Reply Last reply
                0
                • T Offline
                  T 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

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  10

                  Online

                  12.1k

                  Users

                  11.2k

                  Topics

                  113.4k

                  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