I am currently using a Raspberry Pi to control the speed of a 12V DC motor and it works perfectly fine right now like this:
This works: I can start, stop and ramp up the DC motor speed. But obviously, it only goes in 1 direction and it cannot spin in the other direction unless I physically reverse the red/black wires at the output of the PWM module. I tried it and it works, the motor can spin in the other direction with -12V instead of +12V.
Then, I ordered a DPDT 8 pins relay (LY2NJ) because I saw the following YT video and that is exactly what I want to do: https://www.youtube.com/watch?v=xTGzcN8JrUk
This is how I connected everything, but I think something is off in the connections I made, because there was smoke when I connected the battery, so I immediately unhooked everything and I'm now asking for your expertise to help me find what's wrong. Note that the bottom relay enables the RPi 3.3V GPIO pin to trigger the 12V DPDT relay.
What's wrong with the connections I made? (DO NOT REPRODUCE THE ABOVE)
EDIT: WELP, after frying my older Raspberry Pi (It's now RIP instead of RPI, get it? Yeah it's not funny) I have followed @brhans advice to power the DPDT relay AFTER the PWM and also I'm freaking out about grounding to the RPi ever again, so I grounded all the relays to the -12V instead of to the RPi:
Do you think this will fry my second RPi or should it be good like that??