{"id":1151,"date":"2026-10-25T18:52:56","date_gmt":"2026-10-25T17:52:56","guid":{"rendered":"https:\/\/www.jtdigital.de\/?p=1151"},"modified":"2026-10-25T22:42:57","modified_gmt":"2026-10-25T21:42:57","slug":"belegtmeldung-arduino-stromfuehler","status":"publish","type":"post","link":"https:\/\/www.jtdigital.de\/en\/belegtmeldung-arduino-stromfuehler\/","title":{"rendered":"Occupancy detection with the Arduino: reading our current sensors correctly"},"content":{"rendered":"<p class=\"wp-block-paragraph\">Our current sensors normally report occupied track sections to an s88-N feedback module. But they can just as well be read directly with an <strong>Arduino<\/strong> \u2013 for example, to show in the fiddle yard which track is occupied, or to switch the polarity of a frog depending on it. This guide shows step by step how to connect the current sensor, which resistor is needed and which pitfalls are often overlooked.<\/p>\n\n\n\n<div class=\"wp-block-group jt-tldr is-layout-flow wp-block-group-is-layout-flow\">\n<p class=\"jt-box-title wp-block-paragraph\"><strong>Key points at a glance<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The current sensor\u2019s DATA output switches to GND when occupied \u2013 the Arduino then reads <strong>LOW<\/strong>.<\/li>\n\n<li>Without a <strong>pull-up resistor<\/strong>, the input is undefined: the reading jumps back and forth randomly.<\/li>\n\n<li>The Arduino\u2019s internal pull-up is often not enough. A proven solution is an <strong>external 100 k\u03a9 pull-up<\/strong> from 5 V to the input.<\/li>\n\n<li>In the sketch: <code>LOW<\/code> = occupied, <code>HIGH<\/code> = free.<\/li>\n<\/ul>\n<\/div>\n\n\n\n<div class=\"wp-block-group jt-toc is-layout-flow wp-block-group-is-layout-flow\">\n<p class=\"jt-box-title wp-block-paragraph\"><strong>Contents<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a href=\"#material\">What you need<\/a><\/li>\n\n<li><a href=\"#prinzip\">How the signal output works<\/a><\/li>\n\n<li><a href=\"#anschluss\">Step 1: Connect the current sensor<\/a><\/li>\n\n<li><a href=\"#pullup\">Why a large pull-up?<\/a><\/li>\n\n<li><a href=\"#sketch\">Step 2: Upload the sketch<\/a><\/li>\n\n<li><a href=\"#fehlersuche\">Step 3: Test and find faults<\/a><\/li>\n\n<li><a href=\"#faq\">Frequently asked questions<\/a><\/li>\n<\/ol>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"material\">What you need<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>an <a href=\"\/en\/product\/stromfuehler-1x3a-gleisbelegtmelder\/\">Current Sensor 1\u00d73A<\/a> per track section \u2013 or one <a href=\"\/en\/product\/stromfuehler-8x3a-gleisbelegtmelder\/\">Current Sensor 8\u00d73A<\/a> for up to eight sections<\/li>\n\n<li>an Arduino with 5 V, for example Uno or Nano<\/li>\n\n<li>a 100 k\u03a9 resistor per monitored section<\/li>\n\n<li>a track section insulated on both sides<\/li>\n\n<li>some stranded wire or jumper wires<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"prinzip\">How the signal output works<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The current sensor sits between the command station\u2019s track output and the insulated track section. If current flows in the section \u2013 because a loco or a lit carriage is standing there \u2013 the current sensor connects its output <strong>DATA<\/strong> with <strong>GND<\/strong>. If the section is free, DATA stays open.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So the output itself supplies no voltage; it only \u201cpulls\u201d to ground. That is exactly why the Arduino needs a resistor that holds the input at 5 V in the idle state \u2013 the so-called <strong>pull-up<\/strong>.<\/p>\n\n\n\n<div class=\"wp-block-columns jt-cards is-layout-flex wp-container-core-columns-is-layout-3a88641f wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"jt-card-top jt-card-dark wp-block-paragraph\">Track occupied<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Current flows in the section<\/li>\n\n<li>DATA is connected to GND<\/li>\n\n<li>Arduino reads <strong>LOW (0)<\/strong><\/li>\n<\/ul>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"jt-card-top wp-block-paragraph\">Track free<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>no current in the section<\/li>\n\n<li>DATA is open<\/li>\n\n<li>Pull-up pulls to 5 V: Arduino reads <strong>HIGH (1)<\/strong><\/li>\n<\/ul>\n<\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"anschluss\">Step 1: Connect the current sensor<\/h2>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"642\" height=\"744\" src=\"https:\/\/www.jtdigital.de\/wp-content\/uploads\/2026\/10\/schaltplan-arduino-stromfuehler-03001.png\" alt=\"Schaltplan: Stromf\u00fchler 03001 am Arduino \u2013 GND an GND, DATA an A0, Pull-up-Widerstand 100 k\u03a9 zwischen VCC und A0\" class=\"wp-image-1152\" style=\"width:420px\" srcset=\"https:\/\/www.jtdigital.de\/wp-content\/uploads\/2026\/10\/schaltplan-arduino-stromfuehler-03001.png 642w, https:\/\/www.jtdigital.de\/wp-content\/uploads\/2026\/10\/schaltplan-arduino-stromfuehler-03001-259x300.png 259w, https:\/\/www.jtdigital.de\/wp-content\/uploads\/2026\/10\/schaltplan-arduino-stromfuehler-03001-10x12.png 10w, https:\/\/www.jtdigital.de\/wp-content\/uploads\/2026\/10\/schaltplan-arduino-stromfuehler-03001-600x695.png 600w\" sizes=\"auto, (max-width: 642px) 100vw, 642px\" \/><figcaption class=\"wp-element-caption\">Circuit diagram: current sensor 03001 on the Arduino with a 100 k\u03a9 pull-up between VCC (5 V) and A0<\/figcaption><\/figure>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>GND<\/strong> of the current sensor to <strong>GND<\/strong> of the Arduino.<\/li>\n\n<li><strong>DATA<\/strong> of the current sensor to an input of the Arduino, for example <strong>A0<\/strong>. The analogue pins can also be used as digital inputs.<\/li>\n\n<li>A resistor of <strong>100 k\u03a9<\/strong> between <strong>5 V<\/strong> and the same input.<\/li>\n\n<li>Track side as usual: track output of the command station or booster to \u201cInput\u201d, the insulated section to \u201cTrack\u201d \u2013 details are in the installation instructions.<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-group jt-tip is-layout-flow wp-block-group-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Several tracks:<\/strong> Each current sensor gets its own input (A0, A1, A2 \u2026) and its own pull-up. GND is shared by all. On the 8x3A current sensor each of the eight outputs works in exactly the same way.<\/p>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"pullup\">Why a large pull-up?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This is the most common sticking point. When the detector is triggered, its output has a certain internal resistance. Together with the pull-up it forms a <strong>voltage divider<\/strong>. Only if the pull-up is significantly larger than this internal resistance does the voltage at the input reliably drop below the Arduino\u2019s switching threshold \u2013 and it reliably detects LOW.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Arduino\u2019s internal pull-up and also an external 10 k\u03a9 resistor are usually too small for this. The typical symptom: when a loco enters the section, the value read seems to jump randomly between 0 and 1. With a pull-up of <strong>100 k\u03a9<\/strong> the circuit works reliably.<\/p>\n\n\n\n<div class=\"wp-block-group jt-tip jt-warn is-layout-flow wp-block-group-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Often overlooked:<\/strong> If you use an external pull-up, the internal pull-up must be off \u2013 that is, <code>pinMode(A0, INPUT)<\/code> instead of <code>INPUT_PULLUP<\/code>. Otherwise both resistors are connected in parallel and the effective value becomes too small again. And: no pull-down! With a resistor to GND, the Arduino always reads LOW.<\/p>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"sketch\">Step 2: Upload the sketch<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A minimal sketch for one track: the onboard LED lights up while the section is occupied, and the serial monitor shows the state.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Occupancy detection with current sensor 03001 on the Arduino\nconst int GLEIS1 = A0;          \/\/ DATA output of the current sensor\nconst int LED    = LED_BUILTIN; \/\/ Onboard LED shows \"occupied\"\n\nvoid setup() {\n  pinMode(GLEIS1, INPUT);       \/\/ external 100 k\u03a9 pull-up, internal pull-up OFF\n  pinMode(LED, OUTPUT);\n  Serial.begin(9600);\n}\n\nvoid loop() {\n  \/\/ active-low: LOW means \"track occupied\"\n  bool belegt = (digitalRead(GLEIS1) == LOW);\n\n  digitalWrite(LED, belegt ? HIGH : LOW);\n  Serial.println(belegt ? \"Track 1: occupied\" : \"Track 1: free\");\n  delay(200);\n}<\/code><\/pre>\n\n\n\n<div class=\"wp-block-group jt-tip is-layout-flow wp-block-group-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Classic pitfall:<\/strong> In C\/C++, <code>==<\/code> checks for equality, <code>=<\/code> assigns a value. <code>if (gleis1 = false)<\/code> is therefore always false \u2013 the correct form is <code>if (gleis1 == false)<\/code>. The mistake is easy to miss because the sketch compiles anyway \u2013 the evaluation simply does not work.<\/p>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"fehlersuche\">Step 3: Test and find faults<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let a loco run into the section: the onboard LED must light up, and \u201cTrack 1: occupied\u201d appears in the serial monitor. If that does not work straight away, check the most common causes in this order:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Check the logic:<\/strong> Is LOW evaluated as \u201coccupied\u201d? The return value of <code>digitalRead()<\/code> may need to be negated.<\/li>\n\n<li><strong>Increase the pull-up:<\/strong> Use 100 k\u03a9 and switch off the internal pull-up.<\/li>\n\n<li><strong>Measure the voltage:<\/strong> With a multimeter between input and GND \u2013 once with and once without a loco in the section. Without a loco there should be about 5 V, with a loco well below 1.5 V (switching threshold on the 5 V Arduino).<\/li>\n\n<li><strong>Measure the detector:<\/strong> Measure the resistance between DATA and GND on the current sensor, again with and without a loco.<\/li>\n\n<li><strong>Adjust the sensitivity:<\/strong> Use the potentiometer to shift the switching threshold. Towards \u201c+\u201d the detector becomes less sensitive, towards \u201c\u2212\u201d more sensitive.<\/li>\n\n<li><strong>Test another input:<\/strong> To rule out a faulty pin, use a different input.<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-columns jt-prodcards is-layout-flex wp-container-core-columns-is-layout-3a88641f wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-vertically-aligned-stretch is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-group is-vertical is-content-justification-stretch is-layout-flex wp-container-core-group-is-layout-d8dce8eb wp-block-group-is-layout-flex\" style=\"min-height:100%\">\n<figure class=\"wp-block-image size-medium is-resized jt-prod-img\"><a href=\"\/en\/product\/stromfuehler-1x3a-gleisbelegtmelder\/\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"225\" src=\"https:\/\/www.jtdigital.de\/wp-content\/uploads\/2025\/01\/P1060198-300x225.jpg\" alt=\"Stromf\u00fchler 1x3A, Gleisbelegtmelder mit Federklemmen, Ober- und Unterseite\" class=\"wp-image-153\" style=\"aspect-ratio:3\/2;object-fit:contain;width:100%;height:180px\" srcset=\"https:\/\/www.jtdigital.de\/wp-content\/uploads\/2025\/01\/P1060198-300x225.jpg 300w, https:\/\/www.jtdigital.de\/wp-content\/uploads\/2025\/01\/P1060198-scaled-600x450.jpg 600w, https:\/\/www.jtdigital.de\/wp-content\/uploads\/2025\/01\/P1060198-scaled-800x600.jpg 800w, https:\/\/www.jtdigital.de\/wp-content\/uploads\/2025\/01\/P1060198-1024x768.jpg 1024w, https:\/\/www.jtdigital.de\/wp-content\/uploads\/2025\/01\/P1060198-768x576.jpg 768w, https:\/\/www.jtdigital.de\/wp-content\/uploads\/2025\/01\/P1060198-1536x1152.jpg 1536w, https:\/\/www.jtdigital.de\/wp-content\/uploads\/2025\/01\/P1060198-2048x1536.jpg 2048w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"\/en\/product\/stromfuehler-1x3a-gleisbelegtmelder\/\">Current Sensor 1\u00d73A<\/a><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">One track section up to 3 A, adjustable sensitivity, spring terminals.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\" style=\"margin-top:auto\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"\/en\/product\/stromfuehler-1x3a-gleisbelegtmelder\/\">View product<\/a><\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-vertically-aligned-stretch is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-group is-vertical is-content-justification-stretch is-layout-flex wp-container-core-group-is-layout-d8dce8eb wp-block-group-is-layout-flex\" style=\"min-height:100%\">\n<figure class=\"wp-block-image size-medium is-resized jt-prod-img\"><a href=\"\/en\/product\/stromfuehler-8x3a-gleisbelegtmelder\/\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"200\" src=\"https:\/\/www.jtdigital.de\/wp-content\/uploads\/2026\/03\/P1000108-300x200.jpg\" alt=\"Stromf\u00fchler 8x3A mit acht Potentiometern und Federklemmen\" class=\"wp-image-245\" style=\"aspect-ratio:3\/2;object-fit:contain;width:100%;height:180px\" srcset=\"https:\/\/www.jtdigital.de\/wp-content\/uploads\/2026\/03\/P1000108-300x200.jpg 300w, https:\/\/www.jtdigital.de\/wp-content\/uploads\/2026\/03\/P1000108-1024x683.jpg 1024w, https:\/\/www.jtdigital.de\/wp-content\/uploads\/2026\/03\/P1000108-768x512.jpg 768w, https:\/\/www.jtdigital.de\/wp-content\/uploads\/2026\/03\/P1000108-1536x1024.jpg 1536w, https:\/\/www.jtdigital.de\/wp-content\/uploads\/2026\/03\/P1000108-2048x1365.jpg 2048w, https:\/\/www.jtdigital.de\/wp-content\/uploads\/2026\/03\/P1000108-600x400.jpg 600w, https:\/\/www.jtdigital.de\/wp-content\/uploads\/2026\/03\/P1000108-800x533.jpg 800w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"\/en\/product\/stromfuehler-8x3a-gleisbelegtmelder\/\">Current Sensor 8\u00d73A<\/a><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Eight track sections, adjustable per output \u2013 ideal for fiddle yards.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\" style=\"margin-top:auto\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"\/en\/product\/stromfuehler-8x3a-gleisbelegtmelder\/\">View product<\/a><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"faq\">Frequently asked questions<\/h2>\n\n\n\n<details class=\"wp-block-details jt-faq is-layout-flow wp-block-details-is-layout-flow\"><summary>Can I connect the current sensor to an Arduino and an s88-N feedback module at the same time?<\/summary>\n<p class=\"wp-block-paragraph\">No, it is an either-or: a signal output is connected either to an s88-N feedback module or to an Arduino \u2013 not to both at once.<\/p>\n<\/details>\n\n\n\n<details class=\"wp-block-details jt-faq is-layout-flow wp-block-details-is-layout-flow\"><summary>Does this also work with a 3.3 V board such as ESP32 or Raspberry Pi Pico?<\/summary>\n<p class=\"wp-block-paragraph\">Yes, the principle is the same: the output only switches to GND, and the pull-up then goes to 3.3 V instead of 5 V.<\/p>\n<\/details>\n\n\n\n<details class=\"wp-block-details jt-faq is-layout-flow wp-block-details-is-layout-flow\"><summary>Why does the reading flicker when a train enters?<\/summary>\n<p class=\"wp-block-paragraph\">Usually the pull-up is too small or the internal pull-up is also active. If that does not help, you can briefly debounce the state in the sketch \u2013 for example, only accept it after several identical readings \u2013 or readjust the sensitivity with the potentiometer.<\/p>\n<\/details>\n\n\n\n<details class=\"wp-block-details jt-faq is-layout-flow wp-block-details-is-layout-flow\"><summary>How much may I connect to the output?<\/summary>\n<p class=\"wp-block-paragraph\">The signal output tolerates up to 35 V DC and 50 mA. That is more than enough for an Arduino input with a pull-up; loads such as relays or lamps do not belong directly on the output.<\/p>\n<\/details>","protected":false},"excerpt":{"rendered":"<p>Here is how to read our current sensors directly with an Arduino: wiring, the right pull-up resistor, a ready-made sketch and a troubleshooting checklist.<\/p>","protected":false},"author":29,"featured_media":410,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"jt_en_seo_title":"Arduino Occupancy Detection with Current Sensors | JT Digital","jt_en_seo_desc":"Occupancy detection with the Arduino: connecting the current sensor, why a 100 k\u03a9 pull-up is needed, a ready-made sketch and troubleshooting \u2013 step by step.","footnotes":""},"categories":[151,147],"tags":[],"class_list":["post-1151","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-steuerung-software","category-wissen-praxis"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.jtdigital.de\/en\/wp-json\/wp\/v2\/posts\/1151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jtdigital.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jtdigital.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jtdigital.de\/en\/wp-json\/wp\/v2\/users\/29"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jtdigital.de\/en\/wp-json\/wp\/v2\/comments?post=1151"}],"version-history":[{"count":3,"href":"https:\/\/www.jtdigital.de\/en\/wp-json\/wp\/v2\/posts\/1151\/revisions"}],"predecessor-version":[{"id":1167,"href":"https:\/\/www.jtdigital.de\/en\/wp-json\/wp\/v2\/posts\/1151\/revisions\/1167"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.jtdigital.de\/en\/wp-json\/wp\/v2\/media\/410"}],"wp:attachment":[{"href":"https:\/\/www.jtdigital.de\/en\/wp-json\/wp\/v2\/media?parent=1151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jtdigital.de\/en\/wp-json\/wp\/v2\/categories?post=1151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jtdigital.de\/en\/wp-json\/wp\/v2\/tags?post=1151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}