NEWS
mcp3008 in IoBroker einbinden
-
Hallo, ich möchte 8 analoge Kanäle (Feuchtesensor u.s.w) einbinden. Habe hierzu den MCP3008 über getrennte + 3,3V an Pin 23, 21, 19 und 24 am Raspi angeschlossen. Masse ist gleich.
Dann habe ich im Raspi-Tools den SPI eingeschaltet und im IOBroker über die Katze den Adapter https://github.com/raspilc/ioBroker.mcp3xxx-analog installiert und eingespielt. Dieser legt mir dann die Instanz und 8 Objekte an. Soweit so gut. Leider startet der Adapter nur kurz und geht dann von grün auf gelb im Wechsel. Im Log wird folgendes angezeigt.host.raspberrypi 2020-05-04 16:51:04.266 info Restart adapter system.adapter.mcp3xxx-analog.0 because enabled host.raspberrypi 2020-05-04 16:51:04.265 info instance system.adapter.mcp3xxx-analog.0 terminated with code 0 (NO_ERROR) host.raspberrypi 2020-05-04 16:51:04.265 error Caught by controller[7]: { [Error: EACCES, Permission denied] errno: 13, code: 'EACCES', syscall: 'open' } host.raspberrypi 2020-05-04 16:51:04.264 error Caught by controller[6]: { [Error: EACCES, Permission denied] errno: 13, code: 'EACCES', syscall: 'open' } host.raspberrypi 2020-05-04 16:51:04.264 error Caught by controller[5]: { [Error: EACCES, Permission denied] errno: 13, code: 'EACCES', syscall: 'open' } host.raspberrypi 2020-05-04 16:51:04.264 error Caught by controller[4]: { [Error: EACCES, Permission denied] errno: 13, code: 'EACCES', syscall: 'open' } host.raspberrypi 2020-05-04 16:51:04.263 error Caught by controller[3]: { [Error: EACCES, Permission denied] errno: 13, code: 'EACCES', syscall: 'open' } host.raspberrypi 2020-05-04 16:51:04.263 error Caught by controller[2]: { [Error: EACCES, Permission denied] errno: 13, code: 'EACCES', syscall: 'open' } host.raspberrypi 2020-05-04 16:51:04.262 error Caught by controller[1]: { [Error: EACCES, Permission denied] errno: 13, code: 'EACCES', syscall: 'open' } host.raspberrypi 2020-05-04 16:51:04.261 error Caught by controller[0]: { [Error: EACCES, Permission denied] errno: 13, code: 'EACCES', syscall: 'open' } mcp3xxx-analog.0 2020-05-04 16:51:03.737 info (2758) Terminated (NO_ERROR): Without reason mcp3xxx-analog.0 2020-05-04 16:51:03.734 info (2758) terminating mcp3xxx-analog.0 2020-05-04 16:51:03.712 error (2758) Error: EACCES, Permission denied mcp3xxx-analog.0 2020-05-04 16:51:03.710 error (2758) uncaught exception: EACCES, Permission denied mcp3xxx-analog.0 2020-05-04 16:51:03.708 error (2758) Error: EACCES, Permission denied mcp3xxx-analog.0 2020-05-04 16:51:03.706 error (2758) uncaught exception: EACCES, Permission denied mcp3xxx-analog.0 2020-05-04 16:51:03.704 error (2758) Error: EACCES, Permission denied mcp3xxx-analog.0 2020-05-04 16:51:03.703 error (2758) uncaught exception: EACCES, Permission denied mcp3xxx-analog.0 2020-05-04 16:51:03.700 error (2758) Error: EACCES, Permission denied mcp3xxx-analog.0 2020-05-04 16:51:03.699 error (2758) uncaught exception: EACCES, Permission denied mcp3xxx-analog.0 2020-05-04 16:51:03.696 error (2758) Error: EACCES, Permission denied mcp3xxx-analog.0 2020-05-04 16:51:03.695 error (2758) uncaught exception: EACCES, Permission denied mcp3xxx-analog.0 2020-05-04 16:51:03.692 error (2758) Error: EACCES, Permission denied mcp3xxx-analog.0 2020-05-04 16:51:03.691 error (2758) uncaught exception: EACCES, Permission denied mcp3xxx-analog.0 2020-05-04 16:51:03.688 error (2758) Error: EACCES, Permission denied mcp3xxx-analog.0 2020-05-04 16:51:03.687 error (2758) uncaught exception: EACCES, Permission denied mcp3xxx-analog.0 2020-05-04 16:51:03.681 info (2758) cleaned everything up... mcp3xxx-analog.0 2020-05-04 16:51:03.677 error (2758) Error: EACCES, Permission denied mcp3xxx-analog.0 2020-05-04 16:51:03.676 error (2758) uncaught exception: EACCES, Permission denied mcp3xxx-analog.0 2020-05-04 16:51:03.129 info (2758) Start reading analog values at bus 0 device 0 on 8 channels @ 500 ms interval mcp3xxx-analog.0 2020-05-04 16:51:03.127 info (2758) Channel 7 initialized mcp3xxx-analog.0 2020-05-04 16:51:03.125 info (2758) Channel 6 initialized mcp3xxx-analog.0 2020-05-04 16:51:03.124 info (2758) Channel 5 initialized mcp3xxx-analog.0 2020-05-04 16:51:03.123 info (2758) Channel 4 initialized mcp3xxx-analog.0 2020-05-04 16:51:03.121 info (2758) Channel 3 initialized mcp3xxx-analog.0 2020-05-04 16:51:03.120 info (2758) Channel 2 initialized mcp3xxx-analog.0 2020-05-04 16:51:03.118 info (2758) Channel 1 initialized mcp3xxx-analog.0 2020-05-04 16:51:03.116 info (2758) Channel 0 initialized mcp3xxx-analog.0 2020-05-04 16:51:03.072 info (2758) starting. Version 0.0.1 in /opt/iobroker/node_modules/iobroker.mcp3xxx-analog, node: v10.19.0 host.raspberrypi 2020-05-04 16:51:00.720 info instance system.adapter.mcp3xxx-analog.0 started with pid 2758
Was mache ich falsch oder müsste ich noch tun damit der Adapter funktioniert.
Auf dem Raspberry läuft Node.js V10.19.0 und NMP 6.13.4
NodeRed würde ich ungern installieren da schon ein eBus, SonOffs, Fritzbox, Telegram und text2Command läuft.Bin noch Anfänger hab aber schon komplette Garten und Heizungssteuerung implementiert. Zu SPI im IOBroker finde ich aber kaum was.
Danke schon mal für eure Hilfe.
-
Hat keiner eine Idee?
mit py-spidev und über nano angelegtes Script (mcp3008.py) kann ich alle 8 Channels einwandfrei auslesen.
Mit dem IO-Broker aus "https://github.com/raspilc/ioBroker.mcp3xxx-analog" bin ich aber noch nicht weiter gekommen. -
So jetzt hab ich es geschafft.
Nach freischalten von SPI mit Raspi-Config muss auch der IOBroker mit "sudo adduser iobroker spi" berechtigt werden.
Zum Auslesen habe ich folgenden Link genommen.
https://www.raspilc.de/Tutorials/4-Kanal-Analog-Modul-in-ioBroker-nutzen
Für den MPC3008 habe ich das Script entsprechend abgeändert.
Bus und Device stehen bei meinem Raspi-3 auf 0</variables> <block type="procedures_defcustomnoreturn" id="+Mw]Y2?.93oBf(ge{jt~" x="113" y="63"> <mutation statements="false"> <arg name="busNumber" varid="K~~eKvUm{de`qR1Y:FLv"></arg> <arg name="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GF0ZSgiQW5hbG9nbW9kdWwuQ2hhbm5lbDUiLChyZWFkaW5nLnJhd1ZhbHVlKSksdHJ1ZTsKICAgIH0pOwogIH0sIEludGVydmFsKTsKfSk7Cn0KCmZ1bmN0aW9uIHJlYWQ3KCl7CmNvbnN0IGlucHV0NyA9IG1jcGFkYy5vcGVuTWNwMzAwOCg2LCB7YnVzTnVtYmVyOiBidXNOdW1iZXIsIGRldmljZU51bWJlcjpkZXZpY2VOdW1iZXIsICBzcGVlZEh6OiAyMDAwMH0sIChlcnIpID0+IHsKICBpZiAoZXJyKSB0aHJvdyBlcnI7CgogIHNldEludGVydmFsKCgpID0+IHsKICAgIGlucHV0Ny5yZWFkKChlcnIsIHJlYWRpbmcpID0+IHsKICAgICAgaWYgKGVycikgdGhyb3cgZXJyOwoKICAgICAgc2V0U3RhdGUoIkFuYWxvZ21vZHVsLkNoYW5uZWw2IiwocmVhZGluZy5yYXdWYWx1ZSkpLHRydWU7CiAgICB9KTsKICB9LCBJbnRlcnZhbCk7Cn0pOwp9CgpmdW5jdGlvbiByZWFkOCgpewpjb25zdCBpbnB1dDggPSBtY3BhZGMub3Blbk1jcDMwMDgoNywge2J1c051bWJlcjogYnVzTnVtYmVyLCBkZXZpY2VOdW1iZXI6ZGV2aWNlTnVtYmVyLCAgc3BlZWRIejogMjAwMDB9LCAoZXJyKSA9PiB7CiAgaWYgKGVycikgdGhyb3cgZXJyOwoKICBzZXRJbnRlcnZhbCgoKSA9PiB7CiAgICBpbnB1dDgucmVhZCgoZXJyLCByZWFkaW5nKSA9PiB7CiAgICAgIGlmIChlcnIpIHRocm93IGVycjsKCiAgICAgIHNldFN0YXRlKCJBbmFsb2dtb2R1bC5DaGFubmVsNyIsKHJlYWRpbmcucmF3VmFsdWUpKSx0cnVlOwogICAgfSk7CiAgfSwgSW50ZXJ2YWwpOwp9KTsKfQo=</field> <comment pinned="false" h="80" w="160">Liest die Werte des 4-Kanal-Analogmoduls.busNumber > Nr. des SPI-Busses (RasPi 1= 0, RasPi2/3=1, Tinker Board=2deviceNumber > genutzte CS-Leitung (0 oder1) </comment> </block> <block type="procedures_callcustomnoreturn" id="-vA)=,47jm|xOTu0RiVL" x="113" y="113"> <mutation name="Read_8AI_Modul"> <arg name="busNumber"></arg> <arg name="deviceNumber"></arg> <arg name="Interval"></arg> </mutation> <value name="ARG0"> <block type="math_number" id="WyP!BzAW=l|c9CGnp16C"> <field name="NUM">0</field> </block> </value> <value name="ARG1"> <block type="math_number" id="5T0mmPWZx62Y}FGh,:b]"> <field name="NUM">0</field> </block> </value> <value name="ARG2"> <block type="math_number" id="`aS~(w8[IA,QtW-P+0V7"> <field name="NUM">10000</field> </block> </value> </block> </xml>_text
-
@hasont
Hast du mit dem iobroker-Adapter sinnvolle Werte erhalten?Ich hatte massive Probleme, z.B. Ain 1 war ok, aber sobald Ain2 eine Eingangsspannung bekam, waren die Werte von Ain 1 nicht mehr sinnvoll.
Ich habe mich da ein wenig reingearbeitet und den Adapter etwas modifiziert.
Wenn du das System so noch am laufen hast, kannst du evtl. mal meinen Adapter installieren und testen:
https://github.com/AndreasL384/ioBroker.mcp3xxx-analog_v2
Danke.Dir auf jeden Fall schon mal vielen Dank für den Hinweis mit Hinzufügen des Users iobroker in die spi Gruppe.
-
@andreas-liphardt
Hallo, ja ich Messe mit dem 3008 seit 2 Jahren an 3 Gartenfeuchtegeber die analogwerte aus. Die Kanäle die ich nicht brauche lege ich fest auf Masse und bin eigentlich bisher sehr zufrieden.
Kann es ev. sein, dass deine Spannung nicht stabil ist?
Ich hab auch keinen Adapter im IOBroker benutzt sondern SPI direkt am Raspi eingerichtet und soviel ich noch weiß erstmal dort abgefragt und getestet. Dann ein JavaSkript dafür gebaut.<xml xmlns="https://developers.google.com/blockly/xml"> <variables> <variable id="K~~eKvUm{de`qR1Y:FLv">busNumber</variable> <variable id="H)HJx=.Wftan,x_J6wUF">deviceNumber</variable> <variable id="T74|NyJod4GvB(.3RDC-">Interval</variable> <variable id="*4^SNr%8|n?q(YIA2]2+">dreisatz_zwischenwert</variable> <variable id="%C[7WA{At?3JbHG%3$@!">Einheit</variable> <variable id="cLZO1%Ru+:4m,FR,Kr7s">dreisatz_endwert</variable> <variable id="{3gP%PvJ4`Xk,EDj0!yW">Bodenfeuche_Prozent</variable> </variables> <block type="procedures_defcustomnoreturn" id="+Mw]Y2?.93oBf(ge{jt~" x="88" y="-162"> <mutation statements="false"> <arg name="busNumber" varid="K~~eKvUm{de`qR1Y:FLv"></arg> <arg name="deviceNumber" varid="H)HJx=.Wftan,x_J6wUF"></arg> <arg name="Interval" varid="T74|NyJod4GvB(.3RDC-"></arg> </mutation> <field name="NAME">Read_8AI_Modul</field> <field name="SCRIPT">Y3JlYXRlU3RhdGUoJ0FuYWxvZ21vZHVsLkNoYW5uZWwwJywwLHJlYWQxKTsKY3JlYXRlU3RhdGUoJ0FuYWxvZ21vZHVsLkNoYW5uZWwwX2luXyUnLHtuYW1lOiAiQ2hhbm5lbDBfaW5fJSJ9KTsKY3JlYXRlU3RhdGUoJ0FuYWxvZ21vZHVsLkNoYW5uZWwxJywwLHJlYWQyKTsKY3JlYXRlU3RhdGUoJ0FuYWxvZ21vZHVsLkNoYW5uZWwxX2luXyUnLHtuYW1lOiAiQ2hhbm5lbDFfaW5fJSJ9KTsKY3JlYXRlU3RhdGUoJ0FuYWxvZ21vZHVsLkNoYW5uZWwyJywwLHJlYWQzKTsKY3JlYXRlU3RhdGUoJ0FuYWxvZ21vZHVsLkNoYW5uZWwzJywwLHJlYWQ0KTsKY3JlYXRlU3RhdGUoJ0FuYWxvZ21vZHVsLkNoYW5uZWw0JywwLHJlYWQ1KTsKY3JlYXRlU3RhdGUoJ0FuYWxvZ21vZHVsLkNoYW5uZWw1JywwLHJlYWQ2KTsKY3JlYXRlU3RhdGUoJ0FuYWxvZ21vZHVsLkNoYW5uZWw2JywwLHJlYWQ3KTsKY3JlYXRlU3RhdGUoJ0FuYWxvZ21vZHVsLkNoYW5uZWw3JywwLHJlYWQ4KT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1jcDMwMDgoNywge2J1c051bWJlcjogYnVzTnVtYmVyLCBkZXZpY2VOdW1iZXI6ZGV2aWNlTnVtYmVyLCAgc3BlZWRIejogMjAwMDB9LCAoZXJyKSA9PiB7CiAgaWYgKGVycikgdGhyb3cgZXJyOwoKICBzZXRJbnRlcnZhbCgoKSA9PiB7CiAgICBpbnB1dDgucmVhZCgoZXJyLCByZWFkaW5nKSA9PiB7CiAgICAgIGlmIChlcnIpIHRocm93IGVycjsKCiAgICAgIHNldFN0YXRlKCJBbmFsb2dtb2R1bC5DaGFubmVsNyIsKHJlYWRpbmcucmF3VmFsdWUpKSx0cnVlOwogICAgfSk7CiAgfSwgSW50ZXJ2YWwpOwp9KTsKfQo=</field> <comment pinned="false" h="80" w="160">Liest die Werte des 4-Kanal-Analogmoduls.busNumber > Nr. des SPI-Busses (RasPi 1= 0, RasPi2/3=1, Tinker Board=2deviceNumber > genutzte CS-Leitung (0 oder1) </comment> </block> <block type="comment" id="[HaYZ%[*JeY`xP:!XEHR" x="88" y="-112"> <field name="COMMENT">10000 = 10 sec 300000 = 5 min</field> <next> <block type="procedures_callcustomnoreturn" id="YaoWGRLyM,uDF^3+,L=l"> <mutation name="Read_8AI_Modul"> <arg name="busNumber"></arg> <arg name="deviceNumber"></arg> <arg name="Interval"></arg> </mutation> <value name="ARG0"> <block type="math_number" id="XQw|8tcq(V6Gr]Y8m*$v"> <field name="NUM">0</field> </block> </value> <value name="ARG1"> <block type="math_number" id="yd@krYrGZi~^:q==P@CG"> <field name="NUM">0</field> </block> </value> <value name="ARG2"> <block type="math_number" id="6hAcI#6Xm^$NsYCmL*@("> <field name="NUM">300000</field> </block> </value> </block> </next> </block> <block type="on" id="~S-)Y@XQKveg-bJm0~?o" x="88" y="63"> <field name="OID">javascript.0.Analogmodul.Channel0</field> <field name="CONDITION">any</field> <field name="ACK_CONDITION"></field> <statement name="STATEMENT"> <block type="controls_if" id=";jjVodu}N{KH#!F2v3ic"> <value name="IF0"> <block type="logic_operation" id="[^:be;:R~X`E+7F_Vi0!"> <field name="OP">AND</field> <value name="A"> <block type="logic_compare" id="=qulWE#S:bJJ-!Xobdv8"> <field name="OP">GT</field> <value name="A"> <block type="get_value" id="tX4t!f7ZRe?,CUa(11UG"> <field name="ATTR">val</field> <field name="OID">javascript.0.Analogmodul.Channel0</field> </block> </value> <value name="B"> <block type="math_number" id="_cnI9!pSQH20Vt3F8A``"> <field name="NUM">523</field> </block> </value> </block> </value> <value name="B"> <block type="logic_compare" id="(FWu!~q]^P~f_v}+Wj]%"> <field name="OP">LT</field> <value name="A"> <block type="get_value" id="ufi.-[EB}vss+Zu%b*N!"> <field name="ATTR">val</field> <field name="OID">javascript.0.Analogmodul.Channel0</field> </block> </value> <value name="B"> <block type="math_number" id="s$H)}Rxf%`rkLqc[FU;G"> <field name="NUM">1024</field> </block> </value> </block> </value> </block> </value> <statement name="DO0"> <block type="variables_set" id="e`UH1T]OH+rlTor_($1T"> <field name="VAR" id="*4^SNr%8|n?q(YIA2]2+">dreisatz_zwischenwert</field> <value name="VALUE"> <block type="math_arithmetic" id="InfUb7oXCNZXF-_|I5FH"> <field name="OP">DIVIDE</field> <value name="A"> <shadow type="math_number" id="ib#N)=+d[F9s+d[g^,Gv"> <field name="NUM">100</field> </shadow> </value> <value name="B"> <shadow type="math_number" id=".QoH,7N%N}@ZMw-+3Ebw"> <field name="NUM">500</field> </shadow> </value> </block> </value> <next> <block type="variables_set" id="N39#TxCe1fk4Ho:y{W32"> <field name="VAR" id="%C[7WA{At?3JbHG%3$@!">Einheit</field> <value name="VALUE"> <block type="math_arithmetic" id="HS?oh`)OY~oq9vA$dq[E"> <field name="OP">MINUS</field> <value name="A"> <shadow type="math_number" id=")6d%v$dNeNVHY;QNYW/o"> <field name="NUM">1</field> </shadow> <block type="get_value" id="t+@G=rSv)Q-HI#N-g:Go"> <field name="ATTR">val</field> <field name="OID">javascript.0.Analogmodul.Channel0</field> </block> </value> <value name="B"> <shadow type="math_number" id="!O**w[QaM/Vk=G)`Jc0["> <field name="NUM">523</field> </shadow> </value> </block> </value> <next> <block type="variables_set" id="GN/oKRo1%@vh:{S-4Lpj"> <field name="VAR" id="cLZO1%Ru+:4m,FR,Kr7s">dreisatz_endwert</field> <value name="VALUE"> <block type="math_arithmetic" id="Y)c2gc[oa$cUi)1{3bf%"> <field name="OP">MULTIPLY</field> <value name="A"> <shadow type="math_number" id="s`URD4Y#v9~b4kQ=*CD)"> <field name="NUM">0</field> </shadow> <block type="variables_get" id="t77PZOX!@Jb{`eLughPb"> <field name="VAR" id="*4^SNr%8|n?q(YIA2]2+">dreisatz_zwischenwert</field> </block> </value> <value name="B"> <shadow type="math_number" id="ZNI]B]?kX~lvHP91CXtw"> <field name="NUM">0</field> </shadow> <block type="variables_get" id="D`U4cKBCz,gwovbB!InP"> <field name="VAR" id="%C[7WA{At?3JbHG%3$@!">Einheit</field> </block> </value> </block> </value> <next> <block type="variables_set" id="2B?6Bk9kEEu5$9mWoNtR"> <field name="VAR" id="{3gP%PvJ4`Xk,EDj0!yW">Bodenfeuche_Prozent</field> <value name="VALUE"> <block type="math_round" id="9D=t@jggwO3h]L;SP1mr"> <field name="OP">ROUND</field> <value name="NUM"> <shadow type="math_number" id=";:oDyZVVJ,_IqZCsdr?6"> <field name="NUM">3.1</field> </shadow> <block type="variables_get" id="%`QipW;F@h7=MB+#Z#)y"> <field name="VAR" id="cLZO1%Ru+:4m,FR,Kr7s">dreisatz_endwert</field> </block> </value> </block> </value> <next> <block type="control" id="HXMf0KAupmYO^%V(C1r("> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">javascript.0.Analogmodul.Channel0_in_%</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="math_arithmetic" id=":6,Aco-!4YSAG^0sn.]~"> <field name="OP">MINUS</field> <value name="A"> <shadow type="math_number" id="(nk6EA$E4VJ7y@q*vuAc"> <field name="NUM">100</field> </shadow> </value> <value name="B"> <shadow type="math_number" id="%[.:4$I}{]^bp.FGdMcU"> <field name="NUM">1</field> </shadow> <block type="variables_get" id="aJ()XMg=dcBu9}/mj_[("> <field name="VAR" id="{3gP%PvJ4`Xk,EDj0!yW">Bodenfeuche_Prozent</field> </block> </value> </block> </value> </block> </next> </block> </next> </block> </next> </block> </next> </block> </statement> </block> </statement> <next> <block type="on" id="w[5`g]1ML$wuLL*ynue$"> <field name="OID">javascript.0.Analogmodul.Channel1</field> <field name="CONDITION">any</field> <field name="ACK_CONDITION"></field> <statement name="STATEMENT"> <block type="controls_if" id="Hd:~%U)vb0#/#4}vU1|h"> <value name="IF0"> <block type="logic_operation" id="$TA!}${QoXF}Y$n@TpRN"> <field name="OP">AND</field> <value name="A"> <block type="logic_compare" id="crF6`Wm0cO#iO!1?.CG@"> <field name="OP">GT</field> <value name="A"> <block type="get_value" id="#dsJkB]F(8Iio6lW,G+2"> <field name="ATTR">val</field> <field name="OID">javascript.0.Analogmodul.Channel1</field> </block> </value> <value name="B"> <block type="math_number" id="}I?ui,}%i(674z1C1eA}"> <field name="NUM">523</field> </block> </value> </block> </value> <value name="B"> <block type="logic_compare" id="`CI+S*DPTSt(JyCW@Egj"> <field name="OP">LT</field> <value name="A"> <block type="get_value" id="u2~M[v+0L;1GC99,h##L"> <field name="ATTR">val</field> <field name="OID">javascript.0.Analogmodul.Channel1</field> </block> </value> <value name="B"> <block type="math_number" id="T-xz:lg*9z);:533jcBR"> <field name="NUM">1024</field> </block> </value> </block> </value> </block> </value> <statement name="DO0"> <block type="variables_set" id="uLiw=1F_cB}sO~SKUmGj"> <field name="VAR" id="*4^SNr%8|n?q(YIA2]2+">dreisatz_zwischenwert</field> <value name="VALUE"> <block type="math_arithmetic" id="@oMJ;}W@p_DM^3NKvOLw"> <field name="OP">DIVIDE</field> <value name="A"> <shadow type="math_number" id="Fl3GEs{+hSj$)+,T9oAa"> <field name="NUM">100</field> </shadow> </value> <value name="B"> <shadow type="math_number" id="BaK,Y,uxxGFJsb+X^;|*"> <field name="NUM">500</field> </shadow> </value> </block> </value> <next> <block type="variables_set" id="u(MItPmy`#@U!?Bi-Ax["> <field name="VAR" id="%C[7WA{At?3JbHG%3$@!">Einheit</field> <value name="VALUE"> <block type="math_arithmetic" id="NhGGq[sQ9(=?/6Q+Mkl#"> <field name="OP">MINUS</field> <value name="A"> <shadow type="math_number"> <field name="NUM">1</field> </shadow> <block type="get_value" id="bxBtg;)^ei@5$*EtSe-o"> <field name="ATTR">val</field> <field name="OID">javascript.0.Analogmodul.Channel1</field> </block> </value> <value name="B"> <shadow type="math_number" id="vv)2#D8bO=ocYJBdPqkV"> <field name="NUM">523</field> </shadow> </value> </block> </value> <next> <block type="variables_set" id="FG_b=[kzzWll(O3niBTq"> <field name="VAR" id="cLZO1%Ru+:4m,FR,Kr7s">dreisatz_endwert</field> <value name="VALUE"> <block type="math_arithmetic" id="3is/PQ=~vQ5(hH!/7c#."> <field name="OP">MULTIPLY</field> <value name="A"> <shadow type="math_number"> <field name="NUM">0</field> </shadow> <block type="variables_get" id="a0AZ[3~]UtPVEuK#*X:q"> <field name="VAR" id="*4^SNr%8|n?q(YIA2]2+">dreisatz_zwischenwert</field> </block> </value> <value name="B"> <shadow type="math_number" id="]oB*}ePV`PBaOE3(n)P("> <field name="NUM">0</field> </shadow> <block type="variables_get" id="u4vK$^kpi15B%~=)Nqfr"> <field name="VAR" id="%C[7WA{At?3JbHG%3$@!">Einheit</field> </block> </value> </block> </value> <next> <block type="variables_set" id="oaw.LZf*k5/!w]3~gK!6"> <field name="VAR" id="{3gP%PvJ4`Xk,EDj0!yW">Bodenfeuche_Prozent</field> <value name="VALUE"> <block type="math_round" id=":=]I7e+{x#xoRcDXg![V"> <field name="OP">ROUND</field> <value name="NUM"> <shadow type="math_number"> <field name="NUM">3.1</field> </shadow> <block type="variables_get" id="kTy%;le4,jCYNxtrqz8V"> <field name="VAR" id="cLZO1%Ru+:4m,FR,Kr7s">dreisatz_endwert</field> </block> </value> </block> </value> <next> <block type="control" id="F1vXk+L{Hb#pMZ5Z~wXY"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">javascript.0.Analogmodul.Channel1_in_%</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="math_arithmetic" id=":AbSbBo#[lLy5gVY|-ht"> <field name="OP">MINUS</field> <value name="A"> <shadow type="math_number" id=")*qR%FZU)5C_Riv12jg8"> <field name="NUM">100</field> </shadow> </value> <value name="B"> <shadow type="math_number" id="6[?Qu7,N2hjT4Qgn%1x2"> <field name="NUM">1</field> </shadow> <block type="variables_get" id="#eMH;648tF%#VZp`N8ci"> <field name="VAR" id="{3gP%PvJ4`Xk,EDj0!yW">Bodenfeuche_Prozent</field> </block> </value> </block> </value> </block> </next> </block> </next> </block> </next> </block> </next> </block> </statement> </block> </statement> </block> </next> </block> </xml>
-
@andreas-liphardt
Hallo Andreas,vielen Dank für Deine Arbeit: Ich konnte zwar den Adapter nicht installieren (Fehlercode 25), allerdings waren Deine Korrekturen in main.js absolut korrekt und führten zu einem perfekt laufenden MCP3008.
Die Änderungen habe ich manuell durchführen müssen.
Ursprünglich hatte ich exakt das gleiche Problem der unklaren Werte und beim 3008 wurde Kanal 4-7 gleich ausgelesen wie 0-3.
Das ist nun behoben.