How to wire a Rpi, a relay, a DPDT and a PWM module to a DC motor, allowing to control its direction and speed?
OK I was drunk yesterday.  Thank god my 25Ah (yes, you read that correctly) lithium battery did not explode.  I wired the relay wrong! That is why the RPi fried.

Today, I unsoldered the mess I did yesterday and rewired the relay as it should have been to make it a reverse polarity switch. For any future noob (hopefully not as much as I am) coming here to look up the way to wire a LY2N-J DPDT relay for reversing polarity, THIS is the correct way AND NO SMOKE THIS TIME :)



I also tuned some other things as well, while I was at it, such as replace the relay for a true 3.3v one, which is less prone to sticking.  I also connected every single 12V relay, PWM and DC motor to the battery's -12V "ground" instead of the RPi's ground, because I'm freaking out due to what happened yesterday.  I still would feel better protecting the PWM signal pin with a diode, which I don't have right now.

BONUS: Anybody knows what extremely fast inverse polarity recovery diode I could order to protect the GPIO port "just in case" the PWM decides to short to the signal pin?

Thanks!