Thanks for the interest, i am using a Raspberry pi 4 Model B.
I am using it together with an old Rimco rain guage: https://observator.com/products/rim-7499-rain-gauge/ (I work for the Danish Meteorlogical office and got one that was gonna be thrashed)
I just wrote a very simple program in Python using some old code i made while following tutorials by Paul McWorther on youtube. I am by no means good at coding.
Here is my code, i am trying to read the reed switch and when it turns on to switch on a relay:
#import needed libraries and parts from libraries
import RPi.GPIO as GPIO
from time import sleep
#choose the mode of pin numbering BOARD/BCM
GPIO.setmode(GPIO.BOARD)
#variables:
reedIn=40 #reed relay from rimco
medLobOut=38 #for controlling relay for external output
x=0 #counting how many times reed relay has switched
#setup the pins:
GPIO.setup(reedIn,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(medLobOut,GPIO.OUT)
#main
try:
while True:
#read reed relay if it is on or off
reedVal=GPIO.input(reedIn)
#if reedVal = 1 we need to turn on the output of the relay
if reedVal == 1:
GPIO.output(medLobOut, 1)
else:
GPIO.output(medLobOut, 0)
sleep(1)
except KeyboardInterrupt:
#Clean up the pins after use!
GPIO.cleanup()
print('Thas all folks!')
I am using it together with an old Rimco rain guage: https://observator.com/products/rim-7499-rain-gauge/ (I work for the Danish Meteorlogical office and got one that was gonna be thrashed)
I just wrote a very simple program in Python using some old code i made while following tutorials by Paul McWorther on youtube. I am by no means good at coding.
Here is my code, i am trying to read the reed switch and when it turns on to switch on a relay:
#import needed libraries and parts from libraries
import RPi.GPIO as GPIO
from time import sleep
#choose the mode of pin numbering BOARD/BCM
GPIO.setmode(GPIO.BOARD)
#variables:
reedIn=40 #reed relay from rimco
medLobOut=38 #for controlling relay for external output
x=0 #counting how many times reed relay has switched
#setup the pins:
GPIO.setup(reedIn,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(medLobOut,GPIO.OUT)
#main
try:
while True:
#read reed relay if it is on or off
reedVal=GPIO.input(reedIn)
#if reedVal = 1 we need to turn on the output of the relay
if reedVal == 1:
GPIO.output(medLobOut, 1)
else:
GPIO.output(medLobOut, 0)
sleep(1)
except KeyboardInterrupt:
#Clean up the pins after use!
GPIO.cleanup()
print('Thas all folks!')
Statistics: Posted by Thelanie — Sat Jun 22, 2024 7:28 am