How to get 5 volts from a 3 volts pin on ESP32

Hi Team

I need some hits on how to continue.

My goal is to enable my outdoor mailbox with:

Right next to the mail box, will I have a box, with a ESP32 to control the reed and the lock. The box will have a button, that when pressed (or from HA) will unlock the lock for 5 seconds so the door can be opened.

The plan is to use ESPHome. The reed switch I have done before.

But the solenoid lock is new, and I would like some hits. Guess the way to go is with a configuration like this: https://esphome.io/components/switch/gpio.html and the Momentary switch (Activated from the push of the button or from HA GUI).

But the really tricky part, is how to connect the solenoid lock to the ESP32. As I can see, the lock needs 5 volts. So ground to one side of the lock, and then the pin in the ESPHome config to the other side of the lock - guess that is the one with power.
But as I understand, the ESP32 only delivers 3 volts, and the lock needs 5 volts.
So, what do I put between the ‘pin’ and the lock to raise it from 3 to 5 volts.
And is that the way to do it ?

Thanks :wink:

Joern Borup

Hi,

  • The clean and correct way of doing this is to power the lock separately and use the esp32 with a relay to complete and break the lock circuit.

  • Not so clean which is dependent on the esp32 board that you have (I’m assuming it’s some form of devkit powered by usb). If so it ‘is’ (with caution) possible to do but depends on variables like the amount of current draw and being careful with your circuit. The 5v line in this example is essentially taken from the usb input

https://www.esp32.com/viewtopic.php?t=11904

  • Please ensure you have the correct pinout for the board you’re using

Hope this helps and the best of luck

Thanks for responding.
And I can see that I’m missing some info.

Yes - I’m planning on using af ESP32 dev board.
Power - since I also need 5 v for a HC-SR04, I have taken a USB cable and using the 5 v and gnd to power the units. The ESP32 with the VIN/5v pin.
And back to the lock. It needs to be controlled by one of the GPIO pins - and I guess those are only delivering somewhere between 2.8-3.3 v.

So, as you say, the way to go is to use a relay - that gets 5v from the usb cable, and has the GPIO pin as signal - like this one: https://www.tinytronics.nl/shop/en/others/relay/5v-relay-1-channel-high-active

Thanks for the hint…

/Joern

Or one of these: https://www.amazon.de/-/en/Electrely-Channel-Optocoupler-Support-Trigger/dp/B07GRW83FR/ref=sr_1_4?crid=ES6MYVSJDMLP&dchild=1&keywords=relais+5v+arduino&qid=1617228184&sprefix=relay+5v%2Caps%2C406&sr=8-4

Trigger - from the GPIO,
Direct positive - from the USB 5v
com - also the usb 5v (can this one go as low as 5 volts ?)
NC - to the lock (only power when relay is active).

guess the question is - can this relay also pass 5v on the ‘interface’ side, eventhough it says 250v ?

/Joern

Yes. The relay is rated to a maximum of 250V, and therefore can easily handle anything below that.

Thank you all… and thanks to the HA community for fast answers :wink:

/Joern

Just remember to include a non powered way to open the mailbox in case the solenoid stops working.

What ??? - Are you saying that electronics and DIY projects not always works 100% :wink:

Thanks for the reminder…
/Joern

Personally I would try a L shaped metal piece and see if that can be wedged in through the mail slot to open the lock.