Ankündigung

Einklappen
Keine Ankündigung bisher.

[Konnekting] Idee: BodenfeuchteSensor

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    #61
    @Eugen: Umpolen war glaub ich dazu da, dass der sensor länger hält.. Sonst nutzen sich die Elektroden über die Feuchtigkeitsbrücke und Salze im Boden mit der Zeit ab und funktionieren nicht mehr richtig bzw. verfälschen die Messung.

    Tipp: Google nutzen --> https://github.com/empierre/arduino/...oistSensor.ino

    Erstmal ohne KONNEKTING den Sensor testen ob plausible Werte kommen, wenn das funktioniert, KONNEKTING in den Sketch einbauen.

    Kommentar


      #62
      hast Du verschiedene Sensoren getestet? Die Watermark Sensoren sind sehr anfällig am Kontakt zwischen Kabel und Sensor zu reißen (z.B. wenn man beim ausgraben auch nur leicht am Kabel zieht).

      Kommentar


        #63
        Zitat von tuxedo Beitrag anzeigen
        @Eugen: Umpolen war glaub ich dazu da, dass der sensor länger hält.. Sonst nutzen sich die Elektroden über die Feuchtigkeitsbrücke und Salze im Boden mit der Zeit ab und funktionieren nicht mehr richtig bzw. verfälschen die Messung.
        Gleichstrom kann zu Elektromigration und anderen unschönen Effekten führen. Nicht wirklich gewollt, schon gar nicht bei Sensorik.

        Kommentar


          #64
          henfri hast du hier schon eine endgültige Lösung erarbeitet? Hab mir auch gerade einen Watermark geordert. Prinzipiell funktioniert das an einem Arduino plus 1 Widerstand? Oder muss man Hardware-mäßig auch noch was basteln?

          Ich würde dann den Arduino an den Raspi hängen, der via knxd mit dem Bus kommuniziert.
          Danke!

          Kommentar


            #65
            Hallo,

            Bei mir lag das Thema erstmal auf Eis.
            Würde aber o.g. Sketch von Github verwenden.


            Gruß,
            Hendrik

            Kommentar


              #66
              Und Hardware? Arduino uno+ widerstand?

              Kommentar


                #67
                Hallo,

                ich hab ein Konnekting Board, das ich nehmen würde. Aber von der Hardware her müsste es mit irgendeinem Arduino und Widerstand gehen. Ich glaube, oben in dem ino von Github steht auch was zur Hardware.

                Gruß,
                Hendrik

                Kommentar


                  #68
                  Hallo,

                  ich kann endlich Fortschitt berichten
                  bodenfeuchte1.png

                  Diese Schaltung verwende ich:
                  http://vanderleevineyard.com/vineyar...-sensor-reader

                  Hier der wesentliche Code:
                  Code:
                    for (i=0; i<NUM_READS; i++) {
                  
                      setupCurrentPath();      // Prepare the digital and analog pin values
                  
                      // Read 1 pair of voltage values
                      digitalWrite(activeDigitalPin, HIGH);                 // set the voltage supply on
                      delay(10);
                      supplyVoltage = analogRead(supplyVoltageAnalogPin);   // read the supply voltage
                      sensorVoltage = analogRead(sensorVoltageAnalogPin);   // read the sensor voltage
                      digitalWrite(activeDigitalPin, LOW);                  // set the voltage supply off  
                      delay(100); 
                  
                      // Calculate resistance and moisture percentage without overshooting 100
                      // the 0.5 add-term is used to round to the nearest integer
                      // Tip: no need to transform 0-1023 voltage value to 0-5 range, due to following fraction
                      //valueOf[i].resistance = long( float(knownResistor) * ( supplyVoltage - sensorVoltage ) / sensorVoltage + 0.5 );
                      r[i]                  = long( float(knownResistor) * ( supplyVoltage - sensorVoltage ) / sensorVoltage + 0.5 );
                      //Serial.print("R");
                      //Serial.println(r[i]);
                      //valueOf[i].moisture = min( int( pow( valueOf[i].resistance/31.65 , 1.0/-1.695 ) * 400 + 0.5 ) , 100 );
                      m[i]                = min( int( pow( r[i]/31.65 , 1.0/-1.695 ) * 400 + 0.5 ) , 100 );
                  //  valueOf[i].moisture = min( int( pow( valueOf[i].resistance/331.55 , 1.0/-1.695 ) * 100 + 0.5 ) , 100 );
                  
                    }
                  Gruß,
                  Hendrik

                  Kommentar


                    #69
                    Sehr schön, wollte mich auch endlich mal dran machen. Wie lange sind denn deine Leitungen?
                    Und.. gibt's auch unwesentlichen Code? Könntest du vielleicht das ganze Arduino File bereitstellen? Vielen Dank!

                    Kommentar


                      #70
                      Hallo,

                      ich bin gerade noch dabei das in Konnekting zumzusetzen. Noch ist es nur in Arduino.
                      Hier mein kompletter Code:
                      Code:
                      #include <RunningMedian.h>
                      
                      // "Vinduino" portable soil moisture sensor code V3.00
                      // Date December 31, 2012
                      // Reinier van der Lee and Theodore Kaskalis
                      // www.vanderleevineyard.com
                      
                      // include the library code only for LCD display version
                      #include <math.h>
                      
                      #define NUM_READS 20    // Number of sensor reads for filtering
                      
                      
                      const long FirstKnown = 2998;  // Constant value of known resistor in Ohms
                      const long SecondKnown = 3000;  // Constant value of known resistor in Ohms
                      
                      
                      RunningMedian samples = RunningMedian(NUM_READS*2);
                      
                      
                      long knownResistor;
                      int activeDigitalPin = 6;         // 6 or 7 interchangeably
                      int supplyVoltageAnalogPin;       // 6-ON: A0, 7-ON: A1
                      int sensorVoltageAnalogPin;       // 6-ON: A1, 7-ON: A0
                      
                      float avr;
                      float moisture;
                      
                      int supplyVoltage;                // Measured supply voltage
                      int sensorVoltage;                // Measured sensor voltage
                      
                      float r[NUM_READS*2];
                      
                      int i;                            // Simple index variable
                      
                      void setup() {
                        // initialize serial communications at 9600 bps:
                        Serial.begin(9600); 
                      
                        // initialize the digital pin as an output.
                        // Pin 6 is sense resistor voltage supply 1
                        pinMode(6, OUTPUT);    
                      
                        // initialize the digital pin as an output.
                        // Pin 7 is sense resistor voltage supply 2
                        pinMode(7, OUTPUT);   
                      
                        delay(500);   
                      }
                      
                      void loop() {
                      
                        // read sensor, filter, and calculate resistance value
                        // Noise filter: median filter
                        samples.clear();
                        for (i=0; i<NUM_READS*2; i++) {
                      
                          setupCurrentPath();      // Prepare the digital and analog pin values
                      
                          // Read 1 pair of voltage values
                          digitalWrite(activeDigitalPin, HIGH);                 // set the voltage supply on
                          delay(10);
                          supplyVoltage = analogRead(supplyVoltageAnalogPin);   // read the supply voltage
                          sensorVoltage = analogRead(sensorVoltageAnalogPin);   // read the sensor voltage
                          digitalWrite(activeDigitalPin, LOW);                  // set the voltage supply off  
                          delay(100); 
                      
                          // Calculate resistance and moisture percentage without overshooting 100
                          // the 0.5 add-term is used to round to the nearest integer
                          // Tip: no need to transform 0-1023 voltage value to 0-5 range, due to following fraction
                          //valueOf[i].resistance = long( float(knownResistor) * ( supplyVoltage - sensorVoltage ) / sensorVoltage + 0.5 );
                          r[i]                  = long( float(knownResistor) * ( supplyVoltage - sensorVoltage ) / sensorVoltage + 0.5 );
                          samples.add(r[i]);
                          //Serial.print("R");
                          //Serial.println(r[i]);
                          //valueOf[i].moisture = min( int( pow( valueOf[i].resistance/31.65 , 1.0/-1.695 ) * 400 + 0.5 ) , 100 );
                         // m[i]                = min( int( pow( r[i]/31.65 , 1.0/-1.695 ) * 400 + 0.5 ) , 100 );
                         // m[i]                = ((4.093+3.213*r[i]/1000)/(1-0.009733*r[i]/1000-0.01205*10));  //10 is Assumed Soil Temp
                      //  valueOf[i].moisture = min( int( pow( valueOf[i].resistance/331.55 , 1.0/-1.695 ) * 100 + 0.5 ) , 100 );
                      
                        }
                      
                        // end of multiple read loop
                      
                        // Sort the moisture-resistance vector according to moisture
                        //sortMoistures();
                      
                        // calculate average
                        //avr=average (r, NUM_READS*2);
                        
                        moisture=((4.093+3.213*samples.getAverage(5)/1000)/(1-0.009733*samples.getAverage(5)/1000-0.01205*10));
                        
                        // Print out values
                        //Serial.print(sensorVoltage);
                        //Serial.print("\t");
                        //Serial.print(supplyVoltage);
                        //Serial.print("\t");
                        //Serial.print(moisture);
                        //Serial.print("\t");
                        //Serial.print(avr);
                        //Serial.print("\t");
                        //Serial.print(samples.getAverage());
                        //Serial.print("\t");
                        //Serial.print();
                        //Serial.print("\t");
                        Serial.println(moisture);
                       
                      
                        delay(5000);   
                      
                      }
                      
                      void setupCurrentPath() {
                        if ( activeDigitalPin == 6 ) {
                          activeDigitalPin = 7;
                          knownResistor   = FirstKnown;
                          supplyVoltageAnalogPin = A1;
                          sensorVoltageAnalogPin = A0;
                        }
                        else {
                          activeDigitalPin = 6;
                          knownResistor   = SecondKnown;
                          supplyVoltageAnalogPin = A0;
                          sensorVoltageAnalogPin = A1;
                        }
                      }
                      
                      
                      float average (float * array, int len)  // assuming array is int.
                      {
                        float sum = 0 ;  // sum will be larger than an item, long for safety.
                        //Serial.println("Averaging");
                        for (int i = 0 ; i < len ; i++){
                          //Serial.print(" "); 
                          //Serial.print(array[i]);
                          sum = sum+ array[i] ;
                          //Serial.print(" Sum: ");
                          //Serial.println(sum);
                        }
                        //Serial.print("Average: ");
                        //Serial.println(((float) sum) / len);
                        return  ((float) sum) / len ;  // average will be fractional, so float may be appropriate.
                      }
                      Bitte beachte, dass der Referenzwiderstand in dem von mir verlinkten Blog zu gering ist. 3-5kOhm sollten es sein.

                      Willst du das zeitnah in Konnekting umsetzen? Ich weiß noch nicht, wann ich das schaffe.

                      Gruß,
                      Hendrik

                      Kommentar


                        #71
                        Vielen Dank! Im Beitrag steht im Update 4700 Ohm, da werde ich mich wohl dran halten. Mit Konnekting hab ich bis dato leider noch gar nix gemacht. Da ich sowieso Raspis im Einsatz habe, werd ich mir das vorerst wohl auch sparen.

                        Kommentar


                          #72
                          Hallo,

                          ok.

                          Gruß,
                          Hendrik

                          Kommentar


                            #73
                            Hallo,

                            ich sitze gerade an der Integration des Codes in Konnekting.
                            Ich bekomme diesen Fehler:
                            Code:
                            kdevice_Bodenfeuchte.h:40: error: conflicting declaration 'const byte KonnektingDevice::_numberOfParams'
                            
                             const byte KonnektingDevice::_numberOfParams = sizeof (_paramSizeList); // do not change this code
                            
                                                          ^
                            
                            In file included from H:\HeimNetzwerk\Konnekting\Bodenfeuchte\Neu\Bodenfeuchte\Bodenfeuchte.ino:1:0:
                            
                            C:\Users\henfri\Documents\Arduino\libraries\KONNEKTING_Device_Library\src/KonnektingDevice.h:102:22: note: previous declaration as 'const int KonnektingDevice::_numberOfParams'
                            
                                 static const int _numberOfParams;
                            
                                                  ^
                            
                            H:\HeimNetzwerk\Konnekting\Bodenfeuchte\Neu\Bodenfeuchte\Bodenfeuchte.ino: In function 'void setup()':
                            
                            Bodenfeuchte:60: error: 'KNX_SERIAL' was not declared in this scope
                            
                               Konnekting.init(KNX_SERIAL, PROG_BUTTON_PIN, PROG_LED_PIN, MANUFACTURER_ID, DEVICE_ID, REVISION);
                            
                                               ^
                            
                            Bodenfeuchte:62: error: 'PARAM_initialDelay' was not declared in this scope
                            
                                   int startDelay = (int) Konnekting.getUINT16Param(PARAM_initialDelay);
                            
                                                                                    ^
                            
                            exit status 1
                            conflicting declaration 'const byte KonnektingDevice::_numberOfParams'
                            Ich fühle mich aber unschuldig, denn der Code oben ist ja automatisch generiert vom Code-Generator...

                            Anbei der code:
                            Code:
                            kdevice_Bodenfeuchte.h
                            #define MANUFACTURER_ID 57005
                            #define DEVICE_ID 1
                            #define REVISION 0
                            
                            #define COMOBJ_moisture 0
                            #define COMOBJ_LowerAlarm 1
                            #define COMOBJ_UpperAlarm 2
                            #define COMOBJ_Resistance 3
                            #define PARAM_Geraeteanlaufzeit 0
                            #define PARAM_cyclic 1
                            #define PARAM_cycle 2
                            #define PARAM_DeltaMoisture 3
                            #define PARAM_SendOnChange 4
                            #define PARAM_LowerAlarm 5
                            #define PARAM_SendOnLowerAlarm 6
                            #define PARAM_UpperAlarm 7
                            #define PARAM_SendOnUpperAlarm 8
                            #define PARAM_Samples 9
                                    
                            KnxComObject KnxDevice::_comObjectsList[] = {
                                /* Index 0 - moisture */ KnxComObject(KNX_DPT_9_006, 0x34),
                                /* Index 1 - LowerAlarm */ KnxComObject(KNX_DPT_1_001, 0x34),
                                /* Index 2 - UpperAlarm */ KnxComObject(KNX_DPT_1_001, 0x34),
                                /* Index 3 - Resistance */ KnxComObject(KNX_DPT_7_001, 0x34)
                            };
                            const byte KnxDevice::_numberOfComObjects = sizeof (_comObjectsList) / sizeof (KnxComObject); // do not change this code
                                   
                            byte KonnektingDevice::_paramSizeList[] = {
                                /* Index 0 - Geraeteanlaufzeit */ PARAM_UINT8,
                                /* Index 1 - cyclic */ PARAM_UINT8,
                                /* Index 2 - cycle */ PARAM_UINT32,
                                /* Index 3 - DeltaMoisture */ PARAM_UINT8,
                                /* Index 4 - SendOnChange */ PARAM_UINT8,
                                /* Index 5 - LowerAlarm */ PARAM_INT16,
                                /* Index 6 - SendOnLowerAlarm */ PARAM_UINT8,
                                /* Index 7 - UpperAlarm */ PARAM_INT16,
                                /* Index 8 - SendOnUpperAlarm */ PARAM_UINT8,
                                /* Index 9 - Samples */ PARAM_UINT16
                            };
                            const byte KonnektingDevice::_numberOfParams = sizeof (_paramSizeList); // do not change this code
                            Mein code:
                            Code:
                            #include <KonnektingDevice.h>
                            
                            #include <RunningMedian.h>
                            // Arduino pro Mini 3.3V 8MHZ
                            // "Vinduino" portable soil moisture sensor code V3.00
                            // Date December 31, 2012
                            // Reinier van der Lee and Theodore Kaskalis
                            // www.vanderleevineyard.com
                            
                            // include the library code only for LCD display version
                            #include <math.h>
                            #include "kdevice_Bodenfeuchte.h"
                            
                            
                            #define NUM_READS 20    // Number of sensor reads for filtering
                            
                            
                            const long FirstKnown = 2998;  // Constant value of known resistor in Ohms
                            const long SecondKnown = 3000;  // Constant value of known resistor in Ohms
                            
                            
                            #define PROG_LED_PIN 13
                            #define PROG_BUTTON_PIN 8
                            #define SENSOR_PIN_1 6
                            #define SENSOR_PIN_2 7
                            
                            
                            RunningMedian samples = RunningMedian(NUM_READS*2);
                            
                            
                            long knownResistor;
                            int activeDigitalPin = SENSOR_PIN_1;         // SENSOR_PIN_1 or SENSOR_PIN_2 interchangeably
                            int supplyVoltageAnalogPin;       // SENSOR_PIN_1-ON: A0, SENSOR_PIN_2-ON: A1
                            int sensorVoltageAnalogPin;       // SENSOR_PIN_1-ON: A1, SENSOR_PIN_2-ON: A0
                            
                            float avr;
                            float moisture;
                            
                            int supplyVoltage;                // Measured supply voltage
                            int sensorVoltage;                // Measured sensor voltage
                            
                            float r[NUM_READS*2];
                            
                            int i;                            // Simple index variable
                            
                            void setup() {
                              // initialize serial communications at 9600 bps:
                              Serial.begin(9600); 
                            
                              // initialize the digital pin as an output.
                              // Pin SENSOR_PIN_1 is sense resistor voltage supply 1
                              pinMode(SENSOR_PIN_1, OUTPUT);    
                            
                              // initialize the digital pin as an output.
                              // Pin SENSOR_PIN_2 is sense resistor voltage supply 2
                              pinMode(SENSOR_PIN_2, OUTPUT);   
                            
                            
                              // Initialize KNX enabled Arduino Board
                              Konnekting.init(KNX_SERIAL, PROG_BUTTON_PIN, PROG_LED_PIN, MANUFACTURER_ID, DEVICE_ID, REVISION);
                              if (!Konnekting.isFactorySetting()){
                                  int startDelay = (int) Konnekting.getUINT16Param(PARAM_initialDelay);
                                  if (startDelay > 0) {
                                     delay(startDelay);
                                  }
                                 //diffTempUser = (float) Konnekting.getUINT8Param(PARAM_tempDiff)*0.1; 
                              
                              }
                            
                              }
                            
                            void loop() {
                            
                              // read sensor, filter, and calculate resistance value
                              // Noise filter: median filter
                              samples.clear();
                              for (i=0; i<NUM_READS*2; i++) {
                            
                                setupCurrentPath();      // Prepare the digital and analog pin values
                            
                                // Read 1 pair of voltage values
                                digitalWrite(activeDigitalPin, HIGH);                 // set the voltage supply on
                                delay(10);
                                supplyVoltage = analogRead(supplyVoltageAnalogPin);   // read the supply voltage
                                sensorVoltage = analogRead(sensorVoltageAnalogPin);   // read the sensor voltage
                                digitalWrite(activeDigitalPin, LOW);                  // set the voltage supply off  
                                delay(100); 
                            
                                // Calculate resistance and moisture percentage without overshooting 100
                                // the 0.5 add-term is used to round to the nearest integer
                                // Tip: no need to transform 0-1023 voltage value to 0-5 range, due to following fraction
                                //valueOf[i].resistance = long( float(knownResistor) * ( supplyVoltage - sensorVoltage ) / sensorVoltage + 0.5 );
                                r[i]                  = long( float(knownResistor) * ( supplyVoltage - sensorVoltage ) / sensorVoltage + 0.5 );
                                samples.add(r[i]);
                                //Serial.print("R");
                                //Serial.println(r[i]);
                                //valueOf[i].moisture = min( int( pow( valueOf[i].resistance/31.65 , 1.0/-1.695 ) * 400 + 0.5 ) , 100 );
                               // m[i]                = min( int( pow( r[i]/31.65 , 1.0/-1.695 ) * 400 + 0.5 ) , 100 );
                               // m[i]                = ((4.093+3.213*r[i]/1000)/(1-0.009733*r[i]/1000-0.01205*10));  //10 is Assumed Soil Temp
                            //  valueOf[i].moisture = min( int( pow( valueOf[i].resistance/331.55 , 1.0/-1.695 ) * 100 + 0.5 ) , 100 );
                            
                              }
                            
                              // end of multiple read loop
                            
                              // Sort the moisture-resistance vector according to moisture
                              //sortMoistures();
                            
                              // calculate average
                              //avr=average (r, NUM_READS*2);
                              
                              moisture=((4.093+3.213*samples.getAverage(5)/1000)/(1-0.009733*samples.getAverage(5)/1000-0.01205*10));
                              
                              // Print out values
                              //Serial.print(sensorVoltage);
                              //Serial.print("\t");
                              //Serial.print(supplyVoltage);
                              //Serial.print("\t");
                              //Serial.print(moisture);
                              //Serial.print("\t");
                              //Serial.print(avr);
                              //Serial.print("\t");
                              //Serial.print(samples.getAverage());
                              //Serial.print("\t");
                              //Serial.print();
                              //Serial.print("\t");
                              Serial.println(moisture);
                             
                            
                              delay(5000);   
                            
                            }
                            
                            void setupCurrentPath() {
                              if ( activeDigitalPin == SENSOR_PIN_1 ) {
                                activeDigitalPin = SENSOR_PIN_2;
                                knownResistor   = FirstKnown;
                                supplyVoltageAnalogPin = A1;
                                sensorVoltageAnalogPin = A0;
                              }
                              else {
                                activeDigitalPin = SENSOR_PIN_1;
                                knownResistor   = SecondKnown;
                                supplyVoltageAnalogPin = A0;
                                sensorVoltageAnalogPin = A1;
                              }
                            }
                            
                            void knxEvents(byte index) {
                                // nothing to do in this sketch
                            };
                            
                            
                            float average (float * array, int len)  // assuming array is int.
                            {
                              float sum = 0 ;  // sum will be larger than an item, long for safety.
                              //Serial.println("Averaging");
                              for (int i = 0 ; i < len ; i++){
                                //Serial.print(" "); 
                                //Serial.print(array[i]);
                                sum = sum+ array[i] ;
                                //Serial.print(" Sum: ");
                                //Serial.println(sum);
                              }
                              //Serial.print("Average: ");
                              //Serial.println(((float) sum) / len);
                              return  ((float) sum) / len ;  // average will be fractional, so float may be appropriate.
                            }
                            Was habe ich falsch verstanden?

                            Gruß,
                            Hendrik

                            Kommentar


                              #74
                              Hallo,

                              ein kleiner Tipp vielleicht?

                              Gruß,
                              Hendrik

                              Kommentar


                                #75
                                kannst du mal aus dem ganzen sketch Ordner ein Zip machen? Dann kuck ichs mir mal an.

                                Kommentar

                                Lädt...
                                X