A solenoid is a coil of wire wrapped around a cylindrical form that generates a magnetic field when electric current flows through it. Building one yourself requires just a few materials: magnet wire, a tube or rod to wrap it around, a DC power supply, and optionally a ferromagnetic core to boost the magnetic force. The basic construction is straightforward, but the details of wire gauge, number of turns, core material, and power supply all determine whether your solenoid actually works well or overheats in seconds.
How a Solenoid Works
When current flows through a coil of wire, each loop generates a small magnetic field. Stack enough loops together in a cylinder and those individual fields combine into a strong, uniform field running through the center. This is the principle behind every solenoid, from the starter motor in your car to the locking mechanism on a door.
The strength of that internal magnetic field follows a simple relationship: it increases with more current and more turns of wire per unit length. Doubling the current doubles the field. Doubling the number of turns per centimeter also doubles it. In physics notation, the field strength B equals the permeability of the core material multiplied by the current multiplied by the number of turns divided by the coil length (B = μ₀ × I × N / L). You don’t need to memorize the formula, but understanding the relationship helps you make smart design choices: if you want a stronger solenoid, you either add more turns, push more current through it, or insert a core that concentrates the magnetic field.
Materials You’ll Need
For a small DIY solenoid, you need:
- Magnet wire: Copper wire with a thin enamel insulation coating. For most hobby projects, 18 to 24 AWG works well. Thicker wire (lower AWG number) handles more current but takes up more space, giving you fewer turns. Thinner wire fits more turns but overheats at lower currents.
- A winding form: A non-magnetic tube (plastic, cardboard, or PVC) that gives the coil its shape. The inner diameter should be slightly larger than whatever plunger or core you plan to insert.
- A core (optional but recommended): A soft iron bolt, nail, or steel rod placed inside the coil. This dramatically increases the magnetic field.
- A DC power supply: Batteries or a bench power supply. Common choices are 5V, 9V, or 12V DC.
- A return spring: If you’re building a solenoid actuator with a plunger that needs to retract when power is removed.
Choosing the Right Wire Gauge
Wire gauge determines how much current your solenoid can safely carry. Push too much current through thin wire and the enamel insulation melts, causing shorted turns and a dead coil. Here are the maximum current ratings for common magnet wire sizes based on a conservative 700 circular mils per amp rating:
- 18 AWG: 2.3 amps
- 20 AWG: 1.5 amps
- 22 AWG: 920 milliamps
- 24 AWG: 577 milliamps
- 26 AWG: 361 milliamps
- 28 AWG: 226 milliamps
For a first solenoid project, 20 or 22 AWG is a good middle ground. You get enough turns to create a useful field without needing a high-current power supply. If you need serious pulling force, step up to 16 or 18 AWG and pair it with a supply that can deliver 2 to 4 amps.
Why Core Material Matters
An air-core solenoid (just the coil with nothing inside) works, but its magnetic field is relatively weak. Inserting a ferromagnetic core multiplies the field strength enormously because the core material concentrates and channels magnetic flux lines.
Different materials vary wildly in how effectively they do this, measured by a property called permeability. A plain iron bolt has a permeability roughly 4 to 100 times that of air, depending on the type. Silicon steel jumps to around 1,500 times air. Ferrite cores range from 750 to 15,000 times air, depending on the composition. For a simple DIY solenoid, a soft iron nail or bolt from the hardware store is the easiest and cheapest option. It provides a solid boost without any specialty sourcing.
The key word here is “soft” iron. You want a material that magnetizes easily when current flows and demagnetizes quickly when current stops. Hardened steel or permanent magnet materials will retain magnetism after you turn the power off, which can cause the plunger to stick in place.
Winding the Coil
Start by securing one end of the magnet wire to your winding form with a small piece of tape, leaving about 6 inches of wire free as a lead. Then wind the wire tightly around the form in a single layer, keeping each turn snug against the previous one with no gaps or overlaps. Neat, even winding produces a more uniform magnetic field and prevents turns from crossing over each other and creating hot spots.
When you reach the end of the form, you can either stop (single-layer solenoid) or reverse direction and wind a second layer directly on top of the first. Multi-layer coils are stronger because you’re packing more turns into the same length. Before adding a second layer, wrap a thin strip of electrical tape or Kapton tape over the first layer. This extra insulation prevents turns in adjacent layers from pressing against each other and wearing through the enamel, which would cause an internal short circuit. The enamel coating on magnet wire is what ensures current flows through each turn sequentially rather than jumping between loops.
For a typical hobby solenoid, 100 to 300 turns produces a useful field. More turns means a stronger magnet but also higher electrical resistance, which limits how much current flows at a given voltage. When you finish winding, secure the outer end with tape and leave another 6-inch lead. Gently scrape the enamel off the last half-inch of both leads with sandpaper or a hobby knife so you can make electrical connections.
Matching Your Power Supply
Your solenoid’s coil is essentially a resistor (plus some inductance). The total resistance depends on the wire gauge and how many turns you wound. You can measure it with a multimeter across the two leads. Once you know the resistance, Ohm’s law tells you the current: divide your supply voltage by the resistance. That current needs to fall below the safe limit for your wire gauge.
For example, if you wound 200 turns of 22 AWG wire and measure 3 ohms of resistance, a 12V supply would push 4 amps through the coil. That’s well above the 920 milliamp safe rating for 22 AWG, so the wire would overheat quickly. You’d need to either use a lower voltage (say, 3V for about 1 amp), add more turns to increase resistance, or switch to thicker wire. A 5V supply on that same coil gives roughly 1.7 amps, still too high. This is why checking the math before connecting power is important.
Most DIY solenoids run on standard DC voltages: 5V, 9V, or 12V. Staying within about 10% of your target voltage keeps operation predictable. Significant overvoltage can permanently damage the coil by generating excessive heat in the wire.
Managing Heat
Every solenoid generates heat while energized. The wire has resistance, current flows through it, and that produces waste heat (the same principle as a toaster element, just at a lower level). How you manage this heat determines whether your solenoid lasts minutes or years.
The concept to understand is duty cycle: the percentage of time the solenoid is powered on versus the total cycle time. A solenoid rated for continuous duty (100% duty cycle) can stay energized indefinitely because it’s designed to dissipate its own heat. Most DIY solenoids are not designed this way. If you’re building a solenoid to actuate something briefly, like pulling a latch, keep the on-time short and allow cool-down time between activations. A duty cycle of 25% (on for one second, off for three) gives the coil plenty of time to shed heat.
If you need continuous operation, use thicker wire than the minimum required for your current, which reduces resistance and heat generation. You can also add a heat sink, use a lower voltage with correspondingly lower current, or increase the coil’s surface area to improve cooling.
Adding a Plunger and Return Spring
If you’re building an actuator rather than just an electromagnet, you’ll insert a movable iron plunger inside the coil. When current flows, the magnetic field pulls the plunger toward the center of the coil. When current stops, a return spring pushes it back out.
The spring needs to be weak enough that the solenoid can overcome it when energized, but strong enough to reliably retract the plunger when power is removed. For small solenoids, a light compression spring with a spring constant around 100 to 300 N/m (roughly 0.6 to 1.7 pounds per inch of compression) is a reasonable starting point. If the spring is too stiff, the plunger won’t fully engage. Too weak, and the plunger won’t retract crisply.
One practical issue with plunger solenoids is residual magnetism. After you cut power, the iron core and plunger can retain a small magnetic field that makes the plunger stick in the engaged position. The most reliable fix is a mechanical spacer, about 0.050 inches (roughly 1.2 mm) thick, that prevents the plunger from making full metal-to-metal contact with the solenoid body. This small air gap weakens any residual field enough that the return spring can do its job. A thin rubber bumper or plastic washer at the end of the stroke works well for this.
Testing and Adjusting
Before connecting full power, check the coil resistance with a multimeter. An unexpectedly low reading suggests shorted turns. Then connect your power supply at a low voltage first and verify that the coil draws the current you expect. Hold a small iron object near the end of the coil to feel the pull. If you have a plunger, insert it and check that it moves smoothly without binding against the tube walls.
If the pulling force is too weak, you have several options. Adding a ferromagnetic core is the single biggest improvement if you haven’t already. Increasing current (with appropriately rated wire) is next. Winding more turns helps, but at some point the added resistance offsets the benefit. Moving the plunger’s starting position closer to the center of the coil also increases force, since the magnetic field is strongest at the coil’s midpoint.
If the coil gets noticeably warm within a few seconds of operation, you’re either pushing too much current or the duty cycle is too high. Reduce the supply voltage, increase the off-time between activations, or rewind with thicker wire.

