I am trying to utilize my RPi 3+ to trip a SPDT Bosch Automotive 12VDC relay in order to activate chicken water heaters when temp below 34 degrees. The program code works well on other, non relay associated functions. The relay is from eBay, here is the description: 5 Pack 12V DC Car 30A 40A Relay 5 Pin Socket Harness SPDT Bosch Style 5 If I connect relays coil neg(-) directly to PS neg, then all works well. I have also tried using a 3.3VDC power source from a PC PS, connecting (+)3.3 to trans base and neg to emitter, that did not work either. Here is the schematic: Schematic

and here the python code:

#!/usr/bin/env python3

import RPi.GPIO as GPIO
import time, datetime
#import subprocess
import pigpio
import MultiTempsP3

GPIO.setup(18, GPIO.OUT)  # Relay #7

cooptemp = float(MultiTempsP3.temps("72f9386") )

now = datetime.datetime.now()

if cooptemp < 34:
    print("less than 34")
    GPIO.output(18, GPIO.LOW)  # on relay, low = on
    print("greater than 34")
    GPIO.output(18, GPIO.HIGH)

1 Answer 1


That was a very silly mistake: I kept inverting the 2N2222 transistor the wrong way around: I had collected from PS ground and Emitted to Relay; should be the other way around!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.