MicroBlocks Relay

Issue #482 resolved
Hans Braakmann created an issue

When you hook up a 5V relay to a 5V solenoid on a Raspberry Pi Pico, MicroBlocks instantly disrupts the connection. I’m on a Mac (Sonoma 14.2.1.)

Comments (7)

  1. John Maloney repo owner

    Both relay's and solenoids require a LOT of current, much more than the Pico's on-board power regulator can supply. You are basically overloading the power circuit so the board resets itself as if the power were cut.

    Relays, solenoids, and motors can create voltage spikes that can damage the microcontroller so you should avoid connecting such devices directly to the I/O pins of any microcontroller. Instead, you should use a transistor or motor controller to switch the power.

    That said, many relay boards have a built-in transistor for exactly that purpose; those boards are designed to be controlled by an I/O pin. If you are using such a board the issue is probably just the limited current capacity of the board. Powering the board with a battery pack may help -- even AAA batteries can supply more current than the on-board power supply, at least for a short while.

  2. Hans Braakmann reporter

    Thank you, with the relay motors works just fine with it was the cheap solenoid that gave me the headache.

  3. John Maloney repo owner

    Ahh! I guess the voltage spike was the problem, not the current draw. Glag you figured that out.

    Are you using some sort of external power (e.g. a battery pack)? Even small solenoids can draw a few hundred milliamps. Of course, a 5v solenoid won't draw as much current on 3.3v as it would on 5v but 3.3v might not be enough to operate it. I'm looking for some good solenoids that work on 3.3v. If your solenoid is working well could you post a link in a comment here? Much appreciated!

  4. Log in to comment