Hi, I had the following script for Raspberry:
import RPi.GPIO as GPIO
import subprocess
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)GPIO.setup(36,GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
while True:
status=GPIO.input(36)
if status==False:
print(“La raspberry Pi se apagará”)
subprocess.call([‘sudo’,‘shutdown’,‘now’])
But of course, Rpi.GPIO is not useful for my rock, so reading we have seen that the normal thing would be to use the mraa library, however we are having certain difficulties, currently the code is like this:
import mraa
import subprocess
mraa.setLogLevel(mraa.LOG_LEVEL_ERROR)GPIO= mraa.Gpio(36)
GPIO.dir(mraa.DIR_IN)
GPIO.mode(mraa.MODE_PULLDOWN)while True:
status=GPIO.read()
if status==False:
print(“La raspberry Pi se apagará”)
subprocess.call([‘sudo’,‘shutdown’,‘now’])
but regardless of the resistance mode you use, if you declare the pin as an input it reads a 1 without applying the 3V to it, and if u declare the pin as an output it reads a 0. This pin is connected to a power supply wich which provides 3V all the time and 0 when the rock is going to turn off.
Working on Debian 11.