Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. Heizöltank Füllstand

    NEWS

    • Wir empfehlen: Node.js 22.x

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker goes Matter ... Matter Adapter in Stable

    Heizöltank Füllstand

    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Semmy last edited by

      Hallo
      Ich habe einen HC-SR04 und messe damit den Füllstand im Heizöltank. Wie kann ich die folgende Liste in Iobroker mit den Sensor HC-SR04 integrieren?
      Roth-Roth-Batterie-Tank-1000-L-mit-1-Tank.pdf

      Viele Grüße
      Semmy

      K 1 Reply Last reply Reply Quote 0
      • K
        klassisch Most Active @Semmy last edited by klassisch

        @semmy Ich habe einen liegenden zylindrischen Erdtank und habe mir einfach die Formel abgeleitet.
        Diese Roth Batterietanks scheinen recht quaderförmig zu sein.
        Da würde ich einfach mit den Innenmaßen rechnen.
        Die Rundung unten würde ich in einen Offset stecken. Da kommt man eh nie hin. Und ab vielleich 20 oder 30 cm geht der Inhalt wohl linear mit der Höhe
        Das wäre also die eine Variante: Einfach aus Quader rechnen.

        Ansonsten die Ochsentour
        Erstmal in der Variante abrunden auf den letzten ganzzahligen cm könnte das einfach mit einem Arry gemacht werden. Dazu muß die 0 eingefügt werden. 0cm -> 0Liter
        Für jeden cm gibt es einen Tabellenwert. Also nehmen wir die cm als Index des Arrays und den Wert als Volumen. Also Tabelle reinhacken.

        Eingang beim Funktionsaufruf ist die Füllhöhe von unten wie in der Tabelle

        Wenn man von oben mißt, braucht es halt noch die Umrechnung

        level = positionOffset - distanceValue;

        Und ruft dann die function auf

        tankinhalt = getVolume(level);

        
        function getVolume(myLevel){
            const tankVolume = [0,7,13,20,27,33,40,47  ja alle Daten eingeben in cm Schritten; nichts auslassen sonst gehts schief, 1000, 1009, 1017, 1026];
            const minLevel = 0;
            const maxLevel = 119
        	if(myLevel >= MinLevel && myLevel <= Maxlevel){
        		let truncLevel = Mat.trunc(myLevel);
        		let volume = tankVolume[truncLevel];
        		return volume;
        	}
        	else{
        		console.log('Messfehler');
        		return null; 
        	};
        }; 
        
        S 1 Reply Last reply Reply Quote 0
        • S
          Semmy @klassisch last edited by

          @klassisch Habe es mal eingegeben, kommt immer folgende Meldung:

          14:46:36.018	info	javascript.0 (824) Start javascript script.js.Haus.Heizöl
          14:46:36.021	error	javascript.0 (824) script.js.Haus.Heizöl compile failed: at script.js.Haus.Heizöl:1
          
          K 1 Reply Last reply Reply Quote 0
          • K
            klassisch Most Active @Semmy last edited by

            @semmy Poste mal, was Du hast.
            Hast Du die Tabelle komplett eingegeben?

            Und dann ist noch ein ' verloren gegeangen am Ende von
            'Messfehler'

            S 1 Reply Last reply Reply Quote 0
            • K
              klassisch Most Active last edited by klassisch

              Hier eine Version mit Interpolation.
              Es ist ein kleines Testprogramm vorangestellt, welches die Funktion aufruft und das Ergebnis ins log schreibt. Die Tanktabelle ist von meinem Tank im Auslieferungszustand. 10 000 Liter zylindrisch liegend). Musst halt Deine Tabelle reinhacken. Für jeden vollen cm einen Volumenwert.

              
              
              
              // Testprogramm 
              // Interpolation Tanktabelle
              // Tabelle Hans Tank 10 000 Liter
              
              var res = null; 
              {
              for (let x=-1; x<182; x=x+17.3){
                  res = getVolume(x);
                  console.log('x: ' + x + ' Volume: ' + res);
              };
              console.log('Test program executed');
              }; 
              
              
              
              function getVolume(myLevel){
                  const tankVolume = [0, 8.409859784, 23, 43.5318943, 65, 93.30470164, 119, 153.9586423, 184, 223.5705811, 257, 300.8977322, 337, 385.04257, 424, 475.3122288, 510, 571.1472806, 615, 672.0811422, 718, 777.7149676, 827, 887.7011452, 939, 1001.731933, 1056, 1119.531332, 1177, 1240.849092, 1301, 1365, 1429, 1494, 1559, 1624, 1691, 1760, 1829, 1898, 1968, 2039, 2110, 2182, 2255, 2328, 2402, 2477, 2552, 2627, 2702, 2778, 2855, 2932, 3010, 3088, 3166, 3244, 3323, 3402, 3482, 3562, 3642, 3722, 3803, 3884, 3965, 4046, 4127, 4209, 4291, 4373, 4455, 4537, 4619, 4701, 4783, 4865, 4947, 5029, 5111, 5193, 5275, 5357, 5439, 5521, 5603, 5685, 5767, 5849, 5931, 6013, 6094, 6175, 6256, 6337, 6418, 6498, 6578, 6658, 6738, 6817, 6896, 6974, 7052, 7130, 7208, 7300, 7362, 7438, 7513, 7588, 7663, 7738, 7812, 7885, 7958, 8030, 8101, 8172, 8242, 8311, 8380, 8449, 8516, 8581, 8646, 8711, 8775, 8839, 8902, 8963, 9024, 9084, 9143, 9201, 9258, 9313, 9368, 9422, 9474, 9525, 9575, 9624, 9671, 9716, 9760, 9803, 9844, 9883, 9921, 9956, 9990, 10021, 10049, 10075, 10098, 10117, 10132, 10140, ];
                  const minLevel = 0; // min index
                  const maxLevel = tankVolume.length -1; // max index
                  let volume = 0;
              	if(myLevel >= minLevel && myLevel <= (maxLevel +0.5)){
              		let truncLevel = Math.trunc(myLevel);
              	    if(truncLevel == maxLevel) {
              			volume = tankVolume[truncLevel]; // top of table. Interpolation neither necessary nor possible
              		}
              		else { // inertpolation according https://en.wikipedia.org/wiki/Line_(geometry) ; https://de.wikipedia.org/wiki/Zweipunkteform
              			/* y  = (x-x1) * (y2-y1)/(x2-x1) +y1
              			   y  : volume
              			*/
                          let x  = myLevel;
              			let x1 = truncLevel;
              			let x2 = truncLevel + 1;
              			let y1 = tankVolume[x1];
              			let y2 = tankVolume[x2];
              			volume = (x-x1) * (y2-y1)/(x2-x1) +y1; 
              		}; 
              		return volume;
              	}
              	else{ // level out of range
              		console.log('Error,  level out of range: ' + myLevel);
              		return null; 
              	};
              }; 
              
              
              
              1 Reply Last reply Reply Quote 0
              • S
                Semmy @klassisch last edited by

                @klassisch Ok, ich habs geändert. Jetzt kommt keine Fehlermeldung, aber wie bekomme ich jetzt den aktuellen Füllstand meines Tanks in das Script? Ich kenne mich mit js nicht so aus.

                Mit freundlichen Grüßen
                Semmy

                K 1 Reply Last reply Reply Quote 0
                • K
                  klassisch Most Active @Semmy last edited by klassisch

                  @semmy wo kommen denn die Sensordaten an?
                  Der Sensor misst von oben auf die Öloberfläche?
                  Der Sensor gibt den Abstand in cm aus?

                  Dann braucht es noch den Sensorwert in cm bei vollem Tank.
                  Man trigget auf den Datenpunkt des Sensorwerts

                  https://github.com/ioBroker/ioBroker.javascript/blob/master/docs/en/javascript.md#on---subscribe-on-changes-or-updates-of-some-state

                  Man rechnet dann von Abstand Sensor zur Öloberfläche auf Füllstandshöhe (Level) um und füttert damit die function getVolume

                  Das könnte funktionieren, konnte es aber nicht testen. Habe ja andere Datenpunkte. Und es ist meine Tanktabelle drin, mußt durch Deine ersetzen

                  
                  
                  // Interpolation Tanktabelle
                  // Tabelle Hans Tank 10 000 Liter
                  
                  /*  Testscript currently not needed
                  var res = null; 
                  {
                  for (let x=-1; x<182; x=x+17.3){
                      res = getVolume(x);
                      console.log('x: ' + x + ' Volume: ' + res);
                  };
                  console.log('Test program executed');
                  }; 
                    Testscript currently not needed */
                  
                  
                  const sensorValueInCmId = 'hierMussDieAdresseDesDatenpunktsRein'; // richtige Adresse eintragen
                  const tankVolumeLiterId = '0_userdata.0.power.tank.tankinhalt';
                  
                  const abstandSensorZuOeloberflaecheWennVollInCm = 30;  // richtigen Wert eintragen
                  const maximaleTankfuellHoehe = 119; // aus Peiltabelle
                  
                  
                  // Datenpunkt für Tankinhalt erzeugen
                  createState(tankVolumeLiterId, undefined , false, {
                     name: tankVolumeLiter,
                     desc: 'total quantity in liter',
                     type: 'number',
                     unit: 'Liter',
                     role: 'value'
                  });
                  
                  
                  
                  on(sensorValueInCmId, function (dp) {
                  	let sensorDistanceValue = dp.state.val;
                      let distanceSensorToSurface = sensorDistanceValue - abstandSensorZuOeloberflaecheWennVollInCm; 
                  	let fuellHoehe = maximaleTankfuellHoehe - distanceSensorToSurface; 
                  	let tankInhalt = getVolume(fuellHoehe);
                      setState(tankVolumeLiterId, tankInhalt);
                  });
                  
                  
                  function getVolume(myLevel){
                      const tankVolume = [0, 8.409859784, 23, 43.5318943, 65, 93.30470164, 119, 153.9586423, 184, 223.5705811, 257, 300.8977322, 337, 385.04257, 424, 475.3122288, 510, 571.1472806, 615, 672.0811422, 718, 777.7149676, 827, 887.7011452, 939, 1001.731933, 1056, 1119.531332, 1177, 1240.849092, 1301, 1365, 1429, 1494, 1559, 1624, 1691, 1760, 1829, 1898, 1968, 2039, 2110, 2182, 2255, 2328, 2402, 2477, 2552, 2627, 2702, 2778, 2855, 2932, 3010, 3088, 3166, 3244, 3323, 3402, 3482, 3562, 3642, 3722, 3803, 3884, 3965, 4046, 4127, 4209, 4291, 4373, 4455, 4537, 4619, 4701, 4783, 4865, 4947, 5029, 5111, 5193, 5275, 5357, 5439, 5521, 5603, 5685, 5767, 5849, 5931, 6013, 6094, 6175, 6256, 6337, 6418, 6498, 6578, 6658, 6738, 6817, 6896, 6974, 7052, 7130, 7208, 7300, 7362, 7438, 7513, 7588, 7663, 7738, 7812, 7885, 7958, 8030, 8101, 8172, 8242, 8311, 8380, 8449, 8516, 8581, 8646, 8711, 8775, 8839, 8902, 8963, 9024, 9084, 9143, 9201, 9258, 9313, 9368, 9422, 9474, 9525, 9575, 9624, 9671, 9716, 9760, 9803, 9844, 9883, 9921, 9956, 9990, 10021, 10049, 10075, 10098, 10117, 10132, 10140, ];
                      const minLevel = 0; // min index
                      const maxLevel = tankVolume.length -1; // max index
                      let volume = 0;
                  	if(myLevel >= minLevel && myLevel <= (maxLevel +0.5)){
                  		let truncLevel = Math.trunc(myLevel);
                  	    if(truncLevel == maxLevel) {
                  			volume = tankVolume[truncLevel]; // top of table. Interpolation neither necessary nor possible
                  		}
                  		else { // inertpolation according https://en.wikipedia.org/wiki/Line_(geometry) ; https://de.wikipedia.org/wiki/Zweipunkteform
                  			/* y  = (x-x1) * (y2-y1)/(x2-x1) +y1
                  			   y  : volume
                  			*/
                              let x  = myLevel;
                  			let x1 = truncLevel;
                  			let x2 = truncLevel + 1;
                  			let y1 = tankVolume[x1];
                  			let y2 = tankVolume[x2];
                  			volume = (x-x1) * (y2-y1)/(x2-x1) +y1; 
                  		}; 
                  		return volume;
                  	}
                  	else{ // level out of range
                  		console.log('Error,  level out of range: ' + myLevel);
                  		return null; 
                  	};
                  }; 
                  
                  
                  
                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post

                  Support us

                  ioBroker
                  Community Adapters
                  Donate

                  586
                  Online

                  32.0k
                  Users

                  80.5k
                  Topics

                  1.3m
                  Posts

                  2
                  7
                  393
                  Loading More Posts
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes
                  Reply
                  • Reply as topic
                  Log in to reply
                  Community
                  Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                  The ioBroker Community 2014-2023
                  logo