• Happy Holidays Guest!

    We want to announce that we will be working at reduced staffing for the holidays. Specifically Monday the 23rd until Jan 2nd.

    This will affect approval queue times and responses to support tickets. Please adjust your plans accordingly and enjoy yourselves this holiday season!

  • Hi Guest!

    Please be aware that we have released a critical security patch for VaM. We strongly recommend updating to version 1.22.0.7 using the VaM_Updater found in your installation folder.

    Details about the security patch can be found here.
Switching things with Raspberry PI + Relay Board

Guides Switching things with Raspberry PI + Relay Board

This is a quick DIY guide how you could switch devices on/off or switch between E-Stim channels using a Raspberry PI, a Relay board and the Connect plugin directly from your VaM scene using triggers. No soldering needed. As this is just the equivalent of "reconnecting cables", this should work with any E-Stim devices.

We are using mechanical relays, which means the current that runs the Raspberry and relay board is completely isolated from the E-Stim devices. Also the relays are rated for 5A 250V AC or 5A 30V DC, so instead of E-Stim you could also switch pretty much anything with it. Like a "magic wand" vibrator, etc. Downside of using relays is that they are "slow" and make a "click" sound when switching. You probably shouldn't switch them more than once per second or so, especially when switching high currents/voltage.
1681057367568.png



Parts List
  • Raspberry PI 3B+
    Other (cheaper) Raspberry PI units with 40 pin GPIO header should do as well. You probably want to make sure it at least has Wifi, though.
    1681056210856.png
  • Micro-USB power supply, 5V, 2.5A
    Note that newer Raspberry PI may need USB-C now.
    1681058147149.png

  • Passive cooler set for your Raspberry PI
    Technically not needed, but you may get some better performance.
    1681108956138.png
  • MicroSDHC card
    If you are lazy, they sell them with Raspberry Pi OS pre-installed these days.
    1681109455284.png
  • Waveshare RPi Relay Board (B)
    There are plenty of alternatives available. I chose this one because, the Raspberry PI can be mounted, it does not necessarily need a case as it already has a backpanel and also the GPIO pin assignments can be customized.
    1681056149950.png
  • 4x 20mm spacers, screws, nuts and shims (e.g. M2.5 standard)
    1681056648773.png

  • Dupont cable male-female, 20cm, separable
    1681057003724.png
  • Several TENS/EMS electrode cables, matching whatever E-Stim devices and electrodes you have.
    1681057817740.png
Tools and consumables
  • screwdriver
  • wire stripper
  • scissors
  • multimeter
    • optional, but very helpful
  • insulating tape (various colors)
    • It helps keeping track of all the cables if you can color them ;)
  • generic copper wire, isolated
    • You just need a number of some short pieces to connect the relays


Optional additional parts
This is preparing for future expansions, you don't really need these at this point. See "The future..." section at the bottom.
  • Adafruit Perma-Proto HAT (the one without EEPROM)
    1681057461944.png
  • Stacking Header 2x20
    The pins header included with the Proto HAT are too short to connect cables to it. So you need a header with longer pins.
    1681056076059.png

  • 4x additional spacers to match the stacking header


Assembly
This is straightforward, there is not much to it:
  1. Mount the Raspberry PI on the Relay Board
  2. Use two Dupont cables to supply the relay board with 5V power. As you are using a 10W power supply, you can just draw directly from the Raspberry PI, e.g. pins 4 and 6. The Dupont cables fit just fine into the screw terminal block.
    1681059941086.png
  3. In my setup I have 4 E-Stim channels I want to connect to a single set of electrodes. For that I'm using 3 pairs of 2 relays each. I'm using the yellow jumpers of the relay board to pair channels 1-2, 3-4 and 5-6. That way each of them switch as one and we only need a single GPIO port for each pair.
    1681061265753.png
  4. Use more Dupont cables to connect the relay inputs to GPIO ports used by the ConnectGPIO plugin. Here is an overview what is connected to what, yeah, it's bit confusing. (You can also change the GPIO's used in the source code of the ConnectGPIO app, if you prefer. I actually did that, which is why you see different pins being used in the overview photo above.)
    Connect plugin0123456789
    GPIO name17181920212223242526
    Actual Pin number11123538401516182237
    Relay board13578-----
  5. Use some copper wire to chain the relays. Each relay has 3 pins, the center pin C can be connected to either A or B, based on how the corresponding GPIO port is set. Basically we use relay pair 1-2 to decide whether we want input from pair 3-4 or 5-6:
    • Relay 1 pin A ⇔ Relay 3 pin C
    • Relay 1 pin B ⇔ Relay 5 pin C
    • Relay 2 pin A ⇔ Relay 4 pin C
    • Relay 2 pin B ⇔ Relay 6 pin C
  6. Cut the ends of the TENS/EMS electrode cables and remove some 4-5mm insulation. For obvious reasons, THINK before you cut ;)Make sure you cut the correct ends. Put the cable ends into the various screw terminal blocks of the relays.
    • I recommend to actually measure using a multimeter which is the positive pole and what's ground for each cable and then use some colored insulating tape to mark it. Although relay pairs should switch "as one", so this shouldn't happen, we still want to avoid to connect positive pole and ground from different E-Stim devices, even if it's just for a microsecond.
    • Note that some cables may include some kind "rope" besides just copper wire to make them stronger. Since that rope likely isn't conductive, you need to cut a bit of it away so it doesn't get into the screw terminal blocks and give you a bad connection.
    • I'm using relays 1, 3 and 5 for the positive pole. Relays 2, 4 and 6 for ground.
  7. Use a multimeter to check all the connections. Go through all different relay states to make sure everything works as expected. It's just way easier to find issues this way.

Usage in VaM
  1. Compile/Run the ConnectGPIO application on your Raspberry PI. Follow the instructions in the PDF that comes with the application, find it with the Connect plugin download. Don't forget it needs admin rights to control GPIO ports, so run it with "sudo". Also make sure your device is connected to your local network, e.g. your Wifi.
  2. Add an Empty atom to your VaM scene. Name doesn't matter, but I renamed it to "ConnectGPIO".
  3. Add a Connect plugin to your atom. Setup the IP address or hostname of the Raspberry PI in your local network. Then hit the "Connect" button. You should get a log message in VaM telling you it was able to connect.
    1681064635068.png
  4. Use the "Send" trigger of the plugin to send commands to your Raspberry PI.
    • For example: GPIO;m=111;v=001
    • This would set relay pairs 1-2 and 3-4 to their A side, while the 5-6 pair would switch to their B side. If you hooked it up as described above would have chosen the E-Stim channel connected to the 3-4 pair A side.
    • The Waveshare Relay Board has helpful LEDs that indicate the status of each relay. LEDs are ON if the matching GPIO if OFF.
    • Check the PDF documentation that comes with ConnectGPIO for more command examples.
      1681065195230.png
  5. It can be useful to use a StateMachine LogicBrick and setup a "State" for each E-Stim channel. That way you can refer each channel by some name, which makes it easier than having to think in 0's and 1's. Also helps with testing to confirm everything is working.
    1681065720006.png

So, what's it all for?
Obviously you can use all the things described there in a scene similar to my "The New Remote" scene. But it's pretty much up to you, anything is possible. Doesn't have to be BDSM either ;)


The future...and the holy grail
A potential future plan is to look into into an edging/orgasm-sensor. Apparently just about before someone (male or female) is about to cum, there are a series of involuntary muscle contractions. These can be measured via an inflatable buttplug and a simple air pressure sensor, connected by some hose. You can detect when someone is a few seconds before cumming. There is a small company by the name of MausTec.io who build/sell an open-source edging-device based on that principle, which is supposedly able to keep you edged for an hour or so. So, if I can build something similar and get the signal via Raspberry PI into VaM...which your favorite dominatrix in VaM could then react to...like triggering voice lines or animation, turning off the vibrator just at the "right" moment...or ramping up the punishment....all the things you can do with VaM....then we have the perfect VR edging system...."inescapable" until the timer runs out, thanks to VirtualLock.

Sadly, I have very little time to actually work on this....so it may be a long while, probably months, if ever :ROFLMAO:
Also expect that, even with build plans, you will need a LOT of tinkering and trial&error until you get it working well and calibrated to your body. There is of course also the possibility I'm falling for some internet legend here, but at least I will have fun building this ;)
1681066681883.png
1681066578941.png



Support me here:
1681069430644.png
Author
MacGruber
Views
3,764
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from MacGruber

Back
Top Bottom