Is it possible to send s_weight to domoticz?
-
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.
-
@Cliff-Karlsson It is shown as supported here.
Have you tried to send some data and nothing is showing in domoticz?
-
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 } }
-
@Cliff-Karlsson you should not convert the value to String but send it as float. (look at the 'setters' in the API)
-
Ok, I will change that. But why is the sensor flooding the gateway?
-
@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"
-
@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.
-
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.
-
@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); }