Learn

Powering a Circuit with a 12V 7Ah SLA Battery on a Raspberry Pi 4B

Wire a real, adjustable 12V 7Ah sealed lead-acid battery as a standalone power source, watch its own on-canvas charge level and voltage readout update live, and see its voltage sag along a real SLA discharge curve as connected loads draw current from it over time.

Note: the Battery (12V 7Ah, SLA) is a Premium-tier component in the simulator — you’ll need a Premium or VIP plan to use it there.

Try this directly in the free Raspberry Pi 4B simulator — no hardware or signup required. New to the GPIO header? Start with the interactive pinout guide.

What you’ll need

  • Raspberry Pi 4B
  • Battery (12V 7Ah, SLA)
  • Resistor (~220Ω)
  • LED

Step by step

  1. Drag Raspberry Pi 4B, Battery (12V 7Ah, SLA), a Resistor, and an LED onto the Canvas.
  2. Hover over the battery's 2 pins to confirm the labels: + and −.
  3. Wire the battery's + → a Resistor → the LED's anode. LED's cathode → the battery's −. Wire the battery's − → a Pi GND pin too, so the whole circuit shares one common ground.

Before clicking Start, look at the battery's own on-canvas readout — it already reads about 12.7V, and its charge-level fill bar is completely full. A real battery has power without needing any code to run, unlike a Pi's own power pins, which only turn on once the simulation is running.

  1. Click Start — no Python code is needed for this circuit, the same zero-code behavior any other power source (a Pi power pin, a DC Power Supply, a Buck Converter) already has in this simulator.

The LED lights at full brightness, powered entirely by the battery. Click the battery to select it and open its settings panel — you'll see Nominal Voltage (12), Capacity (7 Ah), a live Charge percentage, and a "Recharge to 100%" button.

A real 7Ah battery under a small LED's few-milliamp draw would realistically last for days — far too long to watch happen in this tutorial. To see the charge level actually move in a few minutes, we'll temporarily exaggerate the load.

  1. Click Stop. Click the Resistor and lower its value to about 15Ω in its own settings panel — much lower than you'd ever really use with an LED, but it draws far more current, speeding up the demo.
  2. Click the battery and lower its Capacity setting to 1 Ah (the minimum) in its own settings panel, keeping Nominal Voltage at 12.
  3. Click Start again, and keep the battery's settings panel open so you can watch its Charge percentage.

Within roughly a minute, the Charge percentage begins visibly ticking down, and the on-canvas fill bar noticeably shrinks. The voltage readout drops too, but only slightly at first — a real SLA battery's voltage stays relatively flat for most of its charge range, only falling off steeply once it gets low.

Leave it running for several more minutes. Once the Charge percentage drops below 15%, check the Console — you'll see a low-charge warning naming the current percentage and voltage, and the on-canvas fill bar turns red.

  1. Click Stop.

The Charge percentage stays exactly where it was — clicking Stop doesn't recharge the battery, the same as unplugging real hardware doesn't magically refill it.

  1. With the simulation still stopped, click the battery's "Recharge to 100%" button in its settings panel.

The Charge percentage and the on-canvas fill bar both jump straight back to 100% — instantly, even while the simulation is stopped.

  1. Restore the Resistor to a more realistic value (220Ω) and the battery's Capacity back to 7 Ah, ready for a normal, long-lasting circuit going forward.

What “working correctly” looks like

  • The battery's own on-canvas voltage readout is real even before clicking Start — a fresh, fully charged battery reads about 12.7V at rest, since a real battery holds power without needing any code to run.
  • LED brightness scales with the resistor value exactly the same way it would from any other power source (a Pi pin, a DC Power Supply, a Buck Converter) — the battery participates in the same Ohm's-law brightness model, nothing special-cased.
  • Charge level only decreases while the simulation is running AND a real load is drawing current all the way back to the battery's own − pin — it never decreases on its own while idle, and clicking Stop freezes it exactly where it was.
  • Voltage sags gradually as charge depletes, following a real SLA discharge curve — relatively flat through most of the charge range, then falling off more steeply once the charge gets low, never a flat line that drops instantly to 0V.
  • Console logs a low-charge warning once state of charge crosses below 15%, and the on-canvas fill bar turns red at the same point.
  • "Recharge to 100%" instantly restores full charge, whether the simulation is running or stopped.

If something’s wrong

  • Charge level never seems to change → confirm the simulation is genuinely running (Start was clicked, not just the settings panel open) and that a real load is wired all the way back to the battery's own − pin — an open circuit draws zero current, so there's nothing to deplete.
  • Depletion is far too slow to observe → lower the Capacity setting and wire a lower-value resistor as the load, exactly like this tutorial's own demo step — a full-size 7Ah battery under a small LED's few-milliamp draw is realistically meant to last days, not minutes.
  • LED never lights even though the battery's readout shows a real voltage → check the LED's anode/cathode orientation, and confirm both the battery's + and − pins are genuinely wired into the loop — a dangling − pin means there's no return path even if + is correctly wired.
  • Charge level reset unexpectedly → only "Recharge to 100%" resets it; a normal Stop/Start cycle, or reloading a saved circuit, should always leave the charge exactly where it was.