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. My Project
  3. Sensebender Micro + button

Sensebender Micro + button

Scheduled Pinned Locked Moved My Project
sensebendersensebender micbutton
27 Posts 5 Posters 10.5k Views 8 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.
  • Pierre PP Pierre P

    @martinhjelmare there is a bug (for code bender and arduinoUI). It doesn't like siVolt. '"siVolt' was not declared in this scope"
    your code:

    /********************************************
     *
     * Sends battery information (battery percentage)
     *
     * Parameters
     * - force : Forces transmission of a value
     *
     *******************************************/
    void sendBattLevel(bool force)
    {
      if (force) lastBattery = -1;
      long vcc = readVcc();
      if (vcc != lastBattery) {
        lastBattery = vcc;
      siVolt = vcc / 1000;
    #ifdef BATT_SENSOR
        gw.send(msgBatt.set(siVolt));
    #endif
    
        // Calculate percentage
        vcc = min(vcc, 3000L); // vcc max is 3000
        vcc = vcc  - 1900; // subtract 1.9V from vcc, as this is the lowest voltage we will operate at
    
        long percent = vcc / 11.0;
        gw.sendBatteryLevel(percent);
        transmission_occured = true;
      }
    }
    
    /*******************************************
    

    old code

    /********************************************
     *
     * Sends battery information (battery percentage)
     *
     * Parameters
     * - force : Forces transmission of a value
     *
     *******************************************/
    void sendBattLevel(bool force)
    {
      if (force) lastBattery = -1;
      long vcc = readVcc();
      if (vcc != lastBattery) {
        lastBattery = vcc;
    
    #ifdef BATT_SENSOR
        gw.send(msgBatt.set(vcc));
    #endif
    
        // Calculate percentage
    
        vcc = vcc - 1900; // subtract 1.9V from vcc, as this is the lowest voltage we will operate at
        
        long percent = vcc / 14.0;
        gw.sendBatteryLevel(percent);
      }
    }
    

    How did you compil ?

    tbowmoT Offline
    tbowmoT Offline
    tbowmo
    Admin
    wrote on last edited by
    #5

    @Pierre-P

    You just need to declare siVolt as a float type

    float siVolt = vcc/100;
    #ifdef.... 
    
    
    Pierre PP 1 Reply Last reply
    0
    • tbowmoT tbowmo

      @Pierre-P

      You just need to declare siVolt as a float type

      float siVolt = vcc/100;
      #ifdef.... 
      
      
      Pierre PP Offline
      Pierre PP Offline
      Pierre P
      wrote on last edited by
      #6

      @tbowmo "call of overloaded 'set(float&)' is ambiguous"
      I don't know what it mean.
      And i don't know why the very first sketch is working for you and not for me ! :sweat_smile:

      /********************************************
       *
       * Sends battery information (battery percentage)
       *
       * Parameters
       * - force : Forces transmission of a value
       *
       *******************************************/
      void sendBattLevel(bool force)
      {
        if (force) lastBattery = -1;
        long vcc = readVcc();
        if (vcc != lastBattery) {
          lastBattery = vcc;
          float siVolt = vcc / 1000;
      #ifdef BATT_SENSOR
          gw.send(msgBatt.set(siVolt));
      #endif
      
          // Calculate percentage
          vcc = min(vcc, 3000L); // vcc max is 3000
          vcc = vcc  - 1900; // subtract 1.9V from vcc, as this is the lowest voltage we will operate at
      
          long percent = vcc / 11.0;
          gw.sendBatteryLevel(percent);
          transmission_occured = true;
        }
      }
      
      /*******************************************f```

      No quote, no forum notification (else, the mail box ring every minutes !). Thanks, and have a very good MySensors day !

      martinhjelmareM 1 Reply Last reply
      0
      • Pierre PP Pierre P

        @tbowmo "call of overloaded 'set(float&)' is ambiguous"
        I don't know what it mean.
        And i don't know why the very first sketch is working for you and not for me ! :sweat_smile:

        /********************************************
         *
         * Sends battery information (battery percentage)
         *
         * Parameters
         * - force : Forces transmission of a value
         *
         *******************************************/
        void sendBattLevel(bool force)
        {
          if (force) lastBattery = -1;
          long vcc = readVcc();
          if (vcc != lastBattery) {
            lastBattery = vcc;
            float siVolt = vcc / 1000;
        #ifdef BATT_SENSOR
            gw.send(msgBatt.set(siVolt));
        #endif
        
            // Calculate percentage
            vcc = min(vcc, 3000L); // vcc max is 3000
            vcc = vcc  - 1900; // subtract 1.9V from vcc, as this is the lowest voltage we will operate at
        
            long percent = vcc / 11.0;
            gw.sendBatteryLevel(percent);
            transmission_occured = true;
          }
        }
        
        /*******************************************f```
        martinhjelmareM Offline
        martinhjelmareM Offline
        martinhjelmare
        Plugin Developer
        wrote on last edited by
        #7

        @Pierre-P

        Sorry that was my addition and I haven't actually tested the siVolt thing yet. Everything else works though. But I don't see why it shouldn't work if you declare it properly first.

        1 Reply Last reply
        0
        • Pierre PP Offline
          Pierre PP Offline
          Pierre P
          wrote on last edited by Pierre P
          #8

          BATT_SENSOR si declared.
          ... I think msgBatt is not.
          Does it should be here ?

          // Sensor messages
          MyMessage msgHum(CHILD_ID_HUM, V_HUM);
          MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
          

          Wait not it's just under:

          #ifdef BATT_SENSOR
          MyMessage msgBatt(BATT_SENSOR, V_VOLTAGE);
          #endif
          

          No quote, no forum notification (else, the mail box ring every minutes !). Thanks, and have a very good MySensors day !

          martinhjelmareM 1 Reply Last reply
          0
          • Pierre PP Pierre P

            BATT_SENSOR si declared.
            ... I think msgBatt is not.
            Does it should be here ?

            // Sensor messages
            MyMessage msgHum(CHILD_ID_HUM, V_HUM);
            MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
            

            Wait not it's just under:

            #ifdef BATT_SENSOR
            MyMessage msgBatt(BATT_SENSOR, V_VOLTAGE);
            #endif
            
            martinhjelmareM Offline
            martinhjelmareM Offline
            martinhjelmare
            Plugin Developer
            wrote on last edited by martinhjelmare
            #9

            @Pierre-P

            It's declared three lines below, inside the ifdefine.

            Try declaring siVolt outside the if block in the battery function.

            Edit: Scrap the last suggestion.

            1 Reply Last reply
            0
            • Pierre PP Offline
              Pierre PP Offline
              Pierre P
              wrote on last edited by
              #10

              If I undefine: //#define BATT_SENSOR 199
              it's working.
              But your code still not 100% so we have to find why.
              But... but, i think i'm making a mistake: yes i plan to use 3volts power. But, i don't want it as a sensor ! I wan't it as a battery level like the very first SensebenderMicro sketch. So... I have to undefine BATT_SENSOR ? And i will not have it set to 3Vcc=100% ?
              0_1453547060579_jeedom-004.png

              No quote, no forum notification (else, the mail box ring every minutes !). Thanks, and have a very good MySensors day !

              martinhjelmareM iotcrazyI 2 Replies Last reply
              0
              • Pierre PP Pierre P

                If I undefine: //#define BATT_SENSOR 199
                it's working.
                But your code still not 100% so we have to find why.
                But... but, i think i'm making a mistake: yes i plan to use 3volts power. But, i don't want it as a sensor ! I wan't it as a battery level like the very first SensebenderMicro sketch. So... I have to undefine BATT_SENSOR ? And i will not have it set to 3Vcc=100% ?
                0_1453547060579_jeedom-004.png

                martinhjelmareM Offline
                martinhjelmareM Offline
                martinhjelmare
                Plugin Developer
                wrote on last edited by
                #11

                @Pierre-P

                Might you need to specify decimals if sending float as message. If you want to try, add a second argument with an integer number for decimals.
                https://github.com/mysensors/Arduino/blob/1.5.3/libraries/MySensors/MyMessage.cpp#L212

                1 Reply Last reply
                0
                • Pierre PP Offline
                  Pierre PP Offline
                  Pierre P
                  wrote on last edited by
                  #12

                  Sorry i'm lost. I'm not as good for now.
                  (you may already see that)

                  No quote, no forum notification (else, the mail box ring every minutes !). Thanks, and have a very good MySensors day !

                  martinhjelmareM 1 Reply Last reply
                  0
                  • Pierre PP Pierre P

                    Sorry i'm lost. I'm not as good for now.
                    (you may already see that)

                    martinhjelmareM Offline
                    martinhjelmareM Offline
                    martinhjelmare
                    Plugin Developer
                    wrote on last edited by martinhjelmare
                    #13

                    @Pierre-P

                    void sendBattLevel(bool force)
                    {
                      if (force) lastBattery = -1;
                      long vcc = readVcc();
                      if (vcc != lastBattery) {
                        lastBattery = vcc;
                        float siVolt = vcc / 1000;
                    #ifdef BATT_SENSOR
                        gw.send(msgBatt.set(siVolt, 2));
                    #endif
                    
                        // Calculate percentage
                        vcc = min(vcc, 3000L); // vcc max is 3000
                        vcc = vcc  - 1900; // subtract 1.9V from vcc, as this is the lowest voltage we will operate at
                    
                        long percent = vcc / 11.0;
                        gw.sendBatteryLevel(percent);
                        transmission_occured = true;
                      }
                    }
                    
                    1 Reply Last reply
                    0
                    • Pierre PP Offline
                      Pierre PP Offline
                      Pierre P
                      wrote on last edited by
                      #14

                      oh...:no_mouth:
                      Just need to say use "2" decimals in the message and it's ok...

                      The compilation work !
                      I'll try this afternoon the difference between #define BATT_SENSOR 199 and //#define BATT_SENSOR 199

                      Thanks for your help !

                      No quote, no forum notification (else, the mail box ring every minutes !). Thanks, and have a very good MySensors day !

                      1 Reply Last reply
                      0
                      • Pierre PP Offline
                        Pierre PP Offline
                        Pierre P
                        wrote on last edited by
                        #15

                        0_1453549809864_jeedom-005.png
                        Voltage is not good (it's a new 3Vcc button cell) and batterie pourcentage is at 76%

                        The battery voltage is not just minus 0.3V...

                        No quote, no forum notification (else, the mail box ring every minutes !). Thanks, and have a very good MySensors day !

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

                          @Pierre-P

                          The measurement method is not accurate at all. It relies on an internal reference that can vary in value between boards (I can't remember the accuracy of it at the moment)

                          If you don't want the battery voltage, then uncomment the #define for BATT_SENSOR in the top of the sketch, and move the float siVolt = vcc/1000; to be within the #ifdef BATT_SENSOR like:

                          #ifdef BATT_SENSOR
                              float siVolt = vcc / 1000;
                              gw.send(msgBatt.set(siVolt, 2));
                          #endif
                          
                          

                          Now it should compile, and send battery percentage as the standard sensebender sketch.

                          1 Reply Last reply
                          0
                          • Pierre PP Offline
                            Pierre PP Offline
                            Pierre P
                            wrote on last edited by
                            #17

                            I personaly think that it's quite good. When powered by FTDI, it found 3.00V.
                            And I have only add the "//" to BATT_SENSOR and it work good.
                            (you inverted the thing in the message just above).

                            Thanks again for you help.
                            Now i work very good and very fast. I just have to check for adding an antenna to the controller.

                            No quote, no forum notification (else, the mail box ring every minutes !). Thanks, and have a very good MySensors day !

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

                              @Pierre-P

                              The FTDI probably supplies the board with 3.3V and not 3V..

                              1 Reply Last reply
                              0
                              • alexsh1A Offline
                                alexsh1A Offline
                                alexsh1
                                wrote on last edited by
                                #19

                                @Pierre-P How do you find the battery life please? I am planning to fit Sensebender with nrf24l01+ SMD and CR2032, but I wonder how long the battery is going to survive? Appreciate if depends on your sketch, but given one is conservative (i.e. no need to send temp/hum every 30-60 sec, but probably every 5-10mins or so), what's your estimate please?

                                1 Reply Last reply
                                0
                                • Pierre PP Offline
                                  Pierre PP Offline
                                  Pierre P
                                  wrote on last edited by
                                  #20

                                  I can't tell you for the moment, I haven't check the real voltage of the CR2032 at the beginning. I'll try to make two mesure between 30 days.
                                  But my sketch is 1800000ms or 30min sleeping (if no-one press the button). Because it's a redundant information, my Jeedom controler have a meteo plugin who's working good. (i'll use it for the mini-night-temperature to have a message if there is glass on my car's windows).

                                  No quote, no forum notification (else, the mail box ring every minutes !). Thanks, and have a very good MySensors day !

                                  1 Reply Last reply
                                  0
                                  • Pierre PP Pierre P

                                    If I undefine: //#define BATT_SENSOR 199
                                    it's working.
                                    But your code still not 100% so we have to find why.
                                    But... but, i think i'm making a mistake: yes i plan to use 3volts power. But, i don't want it as a sensor ! I wan't it as a battery level like the very first SensebenderMicro sketch. So... I have to undefine BATT_SENSOR ? And i will not have it set to 3Vcc=100% ?
                                    0_1453547060579_jeedom-004.png

                                    iotcrazyI Offline
                                    iotcrazyI Offline
                                    iotcrazy
                                    wrote on last edited by
                                    #21

                                    @Pierre-P you controller image looks great . What controller is it ?

                                    Pierre PP 1 Reply Last reply
                                    0
                                    • iotcrazyI iotcrazy

                                      @Pierre-P you controller image looks great . What controller is it ?

                                      Pierre PP Offline
                                      Pierre PP Offline
                                      Pierre P
                                      wrote on last edited by
                                      #22

                                      @iotcrazy It is Jeedom, you can find some information here: http://www.mysensors.org/controller/jeedom
                                      It use an RPI2 if you ant to make it yourself, and a major version will come during the week !

                                      No quote, no forum notification (else, the mail box ring every minutes !). Thanks, and have a very good MySensors day !

                                      1 Reply Last reply
                                      0
                                      • alexsh1A Offline
                                        alexsh1A Offline
                                        alexsh1
                                        wrote on last edited by
                                        #23

                                        @martinhjelmare Any idea why siVolt is reporting values rounding up to either 2V or 3V in Domoticz? All I'd like to have is something like 2.9V

                                        martinhjelmareM 1 Reply Last reply
                                        0
                                        • alexsh1A alexsh1

                                          @martinhjelmare Any idea why siVolt is reporting values rounding up to either 2V or 3V in Domoticz? All I'd like to have is something like 2.9V

                                          martinhjelmareM Offline
                                          martinhjelmareM Offline
                                          martinhjelmare
                                          Plugin Developer
                                          wrote on last edited by martinhjelmare
                                          #24

                                          @alexsh1

                                          How are you calculating and sending it? Did you change to float? There was a bug in my original sketch.

                                          Make sure at least one of the operands is a float in the division.

                                          float siVolt = vcc / 1000.0;
                                          
                                          alexsh1A 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          9

                                          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