# How to hardwire different voltages to a rasberrypi

**URL:** <https://discourse.nodered.org/t/how-to-hardwire-different-voltages-to-a-rasberrypi/100272>\
**Category:** Hardware\
**Created:** [29 January 2026 16:07 UTC](https://discourse.nodered.org/t/how-to-hardwire-different-voltages-to-a-rasberrypi/100272 "2026-01-29T16:07:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elindo586](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/elindo586/32/105439_2.png) [@Elindo586](https://discourse.nodered.org/u/Elindo586)\
**Post date:** [29 January 2026 16:07 UTC](https://discourse.nodered.org/t/how-to-hardwire-different-voltages-to-a-rasberrypi/100272/1 "2026-01-29T16:07:24Z")

</div>

Common voltages could be:  
120vac, 220vac, 24vdc, 12vdc

^^ so how could I connect this voltage safely to a rasberrypi to use the I/Os to run Node-RED?

Apparently there are some devices with names like:  
Solid State Relay  
Optoisolator  
Converter module  
and who knows what else..

But what would be better to use? and where can I get those items?

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [29 January 2026 16:36 UTC](https://discourse.nodered.org/t/how-to-hardwire-different-voltages-to-a-rasberrypi/100272/2 "2026-01-29T16:36:57Z")

</div>

What are you trying to do?  
Are you trying to detect/monitor the mains voltage value?  
Are you trying to detect a current load?

**First of all - mains voltages are extremely dangerous and can KILL you.**

**I would NOT attempt to connect any mains wiring anywhere near a Raspberry Pi as you immediately expose the mains connections unless you adequately shield them. You might know where those connections are located but someone else (another adult or a child) may not and could touch them with terrible consequences.**

There are devices that will detect mains voltage, current load, phase angle, etc.. and report these values to Node-RED via MQTT. If you answer the above questions I may be able to advise.

---

<div class="post-metadata">

**Author:** ![Elindo586](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/elindo586/32/105439_2.png) [@Elindo586](https://discourse.nodered.org/u/Elindo586)\
**Post date:** [29 January 2026 16:45 UTC](https://discourse.nodered.org/t/how-to-hardwire-different-voltages-to-a-rasberrypi/100272/3 "2026-01-29T16:45:08Z")

</div>

I am trying to monitor on/off state of a solenoid.

Solenoids may work with different types of voltages.

I did watch a youtube video of a LED light connected using a resistor, but that was a rough example of how it works.... I assume there are better ways to do it.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [29 January 2026 16:57 UTC](https://discourse.nodered.org/t/how-to-hardwire-different-voltages-to-a-rasberrypi/100272/4 "2026-01-29T16:57:01Z")

</div>

You really should take note of Dave's warnings. Mains electricity can and does kill. Both directly and indirectly (e.g. fires).

A solenoid may have a low and a high voltage side. Typically, the low-voltage side would do the switching of the high voltage.

But there are a vast number of different solenoid types and voltages and you really need to know what you are doing.

A solenoid switchable by a 3.3v or 5v circuit _could_ feasibly have a Pi connected into that circuit to detect its state. But even then, it is very easy to kill the Pi as its GPIO pins have no protection on them.

There are also non-contact current monitors that can detect when current is flowing through a mains circuit. That would be a lot safer if you are not used to dealing with mains voltages.

---

<div class="post-metadata">

**Author:** ![Elindo586](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/elindo586/32/105439_2.png) [@Elindo586](https://discourse.nodered.org/u/Elindo586)\
**Post date:** [29 January 2026 17:11 UTC](https://discourse.nodered.org/t/how-to-hardwire-different-voltages-to-a-rasberrypi/100272/5 "2026-01-29T17:11:08Z")

</div>

You won't run the solenoid at 3.3v... you would use something in parallel to step it down to 3.3v to feed it to the I/O.

There seem to be many options to explore, but not sure what would be most common / reliable / less expensive.

^^^ This is the hardwire option... I assume there would be something to convert the regular voltage signal into MQTT as well, but likely more expensive.

What would be cleaner? cost effective? safer? ... lots of variables yet to explore.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [29 January 2026 17:22 UTC](https://discourse.nodered.org/t/how-to-hardwire-different-voltages-to-a-rasberrypi/100272/6 "2026-01-29T17:22:30Z")

</div>

> [@Elindo586](#):
>
> You won't run the solenoid at 3.3v... you would use something in parallel to step it down to 3.3v to feed it to the I/O.

Like I was saying, there are LOTS of variables:

> **[Mains solenoid with 3.3v input switching](https://search.brave.com/search?q=mains+solenoid+with+3.3v+input+switching&summary=1&conversation=08ac72a2ed9bbdc283cc677e22c11476f1fd)**
>
> To switch a mains-powered solenoid using a 3.3V logic input, you must use an isolated switching method for safety and reliability. Direct connection is unsafe due to high voltage risks.
> 
> \### Recommended Approach: Optocoupler + MOSFET or Relay
> \- Use a...

> [@Elindo586](#):
>
> ^^^ This is the hardwire option... I assume there would be something to convert the regular voltage signal into MQTT as well, but likely more expensive.

There are MANY options for mains switching using Wi-Fi and/or MQTT (or Zigbee or Z-Wave and MQTT). Look at the Shelly or SONOFF for examples.

These would be far safer and easier. Shelly in particular, I have multiple devices from them including an RGBW LED strip controller and some UK mains plugs. Each of them is controllable via MQTT over Wi-Fi with no hardware or software hacking.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [30 March 2026 17:22 UTC](https://discourse.nodered.org/t/how-to-hardwire-different-voltages-to-a-rasberrypi/100272/7 "2026-03-30T17:22:41Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
