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. Controllers
  3. Domoticz
  4. Is it possible to send s_weight to domoticz?

Is it possible to send s_weight to domoticz?

Scheduled Pinned Locked Moved Domoticz
9 Posts 3 Posters 2.4k 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.
  • Cliff KarlssonC Offline
    Cliff KarlssonC Offline
    Cliff Karlsson
    wrote on last edited by
    #1

    Is it possible to send s_weight to domoticz? I want to add a FSR preassure/force sensor but I don't understand if I need to convert the "weight/force" to something else before sending the data to domoticz.

    Boots33B 1 Reply Last reply
    0
    • Cliff KarlssonC Cliff Karlsson

      Is it possible to send s_weight to domoticz? I want to add a FSR preassure/force sensor but I don't understand if I need to convert the "weight/force" to something else before sending the data to domoticz.

      Boots33B Offline
      Boots33B Offline
      Boots33
      Hero Member
      wrote on last edited by
      #2

      @Cliff-Karlsson It is shown as supported here.

      Have you tried to send some data and nothing is showing in domoticz?

      1 Reply Last reply
      1
      • Cliff KarlssonC Offline
        Cliff KarlssonC Offline
        Cliff Karlsson
        wrote on last edited by
        #3

        I tried copy/pasting the code that I have found for the FSR sensor but I still have not learned how to create my own sensor-sketches. I tried this and the sensor presentation gets reported to domoticz and it reacts to preassure. But it always shows 1g and it is also flooding the log with messages even where it is some constant weight on it. I just want it to report on change.

        Can anyone tell me what needs to be modified to make it work?

        const int FSR_PIN = A0; // Pin connected to FSR/resistor divider
        
        // Measure the voltage at 5V and resistance of your 3.3k resistor, and enter
        // their value's below:
        const float VCC = 3.28; // Measured voltage of Ardunio 5V line
        const float R_DIV = 3230.0; // Measured resistance of 3.3k resistor
        #define MY_RADIO_NRF24
        
        #include <MySensors.h>
        #include <SPI.h>
        #define CHILD_ID 1   // Id of the sensor child
        
        
        MyMessage msg(CHILD_ID, V_WEIGHT);
        
        void setup() 
        {
         
          pinMode(FSR_PIN, INPUT);
        }
        
        
        void presentation()
        {
        sendSketchInfo("Force Sensor", "1.0");    
        
        present(CHILD_ID, S_WEIGHT);
        }
        
        void loop()
        {
            int fsrADC = analogRead(FSR_PIN);
          // If the FSR has no pressure, the resistance will be
          // near infinite. So the voltage should be near 0.
          if (fsrADC != 0) // If the analog reading is non-zero
          {
            // Use ADC reading to calculate voltage:
            float fsrV = fsrADC * VCC / 1023.0;
            // Use voltage and static resistor value to 
            // calculate FSR resistance:
            float fsrR = R_DIV * (VCC / fsrV - 1.0);
           // Serial.println("Resistance: " + String(fsrR) + " ohms");
            // Guesstimate force based on slopes in figure 3 of
            // FSR datasheet:
            float force;
            float fsrG = 1.0 / fsrR; // Calculate conductance
            // Break parabolic curve down into two linear slopes:
            if (fsrR <= 600) 
              force = (fsrG - 0.00075) / 0.00000032639;
            else
              force =  fsrG / 0.000000642857;
            //Serial.println("Force: " + String(force) + " g");
            //Serial.println();
        send(msg.set(String(force)));
            delay(500);
          }
          else
          {
            // No pressure detected
          }   
        }
        
        
        AWIA 1 Reply Last reply
        0
        • Cliff KarlssonC Cliff Karlsson

          I tried copy/pasting the code that I have found for the FSR sensor but I still have not learned how to create my own sensor-sketches. I tried this and the sensor presentation gets reported to domoticz and it reacts to preassure. But it always shows 1g and it is also flooding the log with messages even where it is some constant weight on it. I just want it to report on change.

          Can anyone tell me what needs to be modified to make it work?

          const int FSR_PIN = A0; // Pin connected to FSR/resistor divider
          
          // Measure the voltage at 5V and resistance of your 3.3k resistor, and enter
          // their value's below:
          const float VCC = 3.28; // Measured voltage of Ardunio 5V line
          const float R_DIV = 3230.0; // Measured resistance of 3.3k resistor
          #define MY_RADIO_NRF24
          
          #include <MySensors.h>
          #include <SPI.h>
          #define CHILD_ID 1   // Id of the sensor child
          
          
          MyMessage msg(CHILD_ID, V_WEIGHT);
          
          void setup() 
          {
           
            pinMode(FSR_PIN, INPUT);
          }
          
          
          void presentation()
          {
          sendSketchInfo("Force Sensor", "1.0");    
          
          present(CHILD_ID, S_WEIGHT);
          }
          
          void loop()
          {
              int fsrADC = analogRead(FSR_PIN);
            // If the FSR has no pressure, the resistance will be
            // near infinite. So the voltage should be near 0.
            if (fsrADC != 0) // If the analog reading is non-zero
            {
              // Use ADC reading to calculate voltage:
              float fsrV = fsrADC * VCC / 1023.0;
              // Use voltage and static resistor value to 
              // calculate FSR resistance:
              float fsrR = R_DIV * (VCC / fsrV - 1.0);
             // Serial.println("Resistance: " + String(fsrR) + " ohms");
              // Guesstimate force based on slopes in figure 3 of
              // FSR datasheet:
              float force;
              float fsrG = 1.0 / fsrR; // Calculate conductance
              // Break parabolic curve down into two linear slopes:
              if (fsrR <= 600) 
                force = (fsrG - 0.00075) / 0.00000032639;
              else
                force =  fsrG / 0.000000642857;
              //Serial.println("Force: " + String(force) + " g");
              //Serial.println();
          send(msg.set(String(force)));
              delay(500);
            }
            else
            {
              // No pressure detected
            }   
          }
          
          
          AWIA Offline
          AWIA Offline
          AWI
          Hero Member
          wrote on last edited by
          #4

          @Cliff-Karlsson you should not convert the value to String but send it as float. (look at the 'setters' in the API)

          1 Reply Last reply
          0
          • Cliff KarlssonC Offline
            Cliff KarlssonC Offline
            Cliff Karlsson
            wrote on last edited by
            #5

            Ok, I will change that. But why is the sensor flooding the gateway?

            AWIA Boots33B 2 Replies Last reply
            0
            • Cliff KarlssonC Cliff Karlsson

              Ok, I will change that. But why is the sensor flooding the gateway?

              AWIA Offline
              AWIA Offline
              AWI
              Hero Member
              wrote on last edited by
              #6

              @Cliff-Karlsson the sensor is sending messages each 500 ms (0.5 seconds) which is pretty much...
              You can increase the value and report only when change (and include a threshold) . Take a look at the different examples for humidity and temperature for a "how to"

              1 Reply Last reply
              0
              • Cliff KarlssonC Cliff Karlsson

                Ok, I will change that. But why is the sensor flooding the gateway?

                Boots33B Offline
                Boots33B Offline
                Boots33
                Hero Member
                wrote on last edited by
                #7

                @Cliff-Karlsson May I ask what sort of device are you building? Does it need to give the weight reading or simply need to let you know if there is a change.

                Cliff KarlssonC 1 Reply Last reply
                0
                • Boots33B Boots33

                  @Cliff-Karlsson May I ask what sort of device are you building? Does it need to give the weight reading or simply need to let you know if there is a change.

                  Cliff KarlssonC Offline
                  Cliff KarlssonC Offline
                  Cliff Karlsson
                  wrote on last edited by
                  #8

                  @Boots33

                  I am trying to build a bed occupancy sensor so you are correct I don't really need the exact weight to be reported all the time. But I want to understand how to get the sensor to work correctly if I find another scenario to use it in. Also it would be much easier to test out the bed-occupancy sensor if I can monitor it directly from domoticz when trying different placements to be able to place it in the best spot.

                  Boots33B 1 Reply Last reply
                  0
                  • Cliff KarlssonC Cliff Karlsson

                    @Boots33

                    I am trying to build a bed occupancy sensor so you are correct I don't really need the exact weight to be reported all the time. But I want to understand how to get the sensor to work correctly if I find another scenario to use it in. Also it would be much easier to test out the bed-occupancy sensor if I can monitor it directly from domoticz when trying different placements to be able to place it in the best spot.

                    Boots33B Offline
                    Boots33B Offline
                    Boots33
                    Hero Member
                    wrote on last edited by Boots33
                    #9

                    @Cliff-Karlsson An interesting project. As you don't need to know the weight that will make the sketch much simpler. You can just use the raw ADC values to work out the best threshold for when the bed is occupied.

                    Try the sketch below and see if you get meaningful results . Depending on your voltage divider you should get a value between 0 and 1023 sent every 2 seconds.

                    /**
                     * weightTester
                     */
                    
                    // Enable debug prints to serial monitor
                    #define MY_DEBUG 
                    
                    // Enable and select radio type attached
                    #define MY_RADIO_NRF24
                    
                    #include <SPI.h>
                    #include <MySensors.h>  
                    
                    #define CHILD_ID_WEIGHT 0
                    
                    int inPin = 3 ;                      // change this to the analog pin you are using
                    int forceReading = 0;                //placeholder for the analog readings
                    unsigned long waitTime = 2000;      //  time between message sends (in milliseconds)
                    MyMessage msg(CHILD_ID_WEIGHT, V_WEIGHT);
                    
                    void setup(){
                    
                    }
                    void presentation()  {
                      // Send the sketch version information to the gateway and Controller
                      sendSketchInfo("Weight Test", "1.0");
                    
                      // Register all sensors to gateway (they will be created as child devices)
                      present(CHILD_ID_WEIGHT, S_WEIGHT);
                    }
                    
                    void loop()      
                    {     
                      forceReading = analogRead(inPin);
                      send(msg.set(forceReading));
                      #ifdef MY_DEBUG
                       Serial.println(forceReading);
                      #endif 
                      wait(waitTime);
                    }
                    
                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    42

                    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