RPI-200 Edge Node GPIO Help


I have a RPI-200 Edge node with N3uron installed that is polling RS485 perfectly fine, i am now trying to access the GPIO Pins with no success via a Python script has anyone had any luck? Ive tried DI0 and DI1 uaing a momentary switch to send a mqtt message, ive evens shorted these pins manually and changed my script accordingly to no avail, Tried the usual running it as sudo, and ive tried a few variations of libraries to access the pins and im not seeing the change of the pins in the CLI from previous debugging in my scripts anyhelp is appreciated below is my Python script

from periphery import GPIO
import paho.mqtt.client as mqtt
import time

MQTT Settings

MQTT_BROKER = “Broker Address”
MQTT_PORT = 1883
MQTT_TOPIC = “Report”
MQTT_MESSAGE = “Switch Activated!”
MQTT_USERNAME = “Token” # Replace with your actual MQTT broker username
MQTT_PASSWORD = “Random” # Replace with your actual MQTT broker password

MQTT Callbacks for debugging

def on_connect(client, userdata, flags, rc):
if rc == 0:
print(“Connected to MQTT Broker!”)
print(“Failed to connect to MQTT Broker. Return code:”, rc)

def on_publish(client, userdata, mid):
print(“MQTT message published.”)

Setup MQTT Client

client = mqtt.Client()
client.on_connect = on_connect
client.on_publish = on_publish
client.username_pw_set(MQTT_USERNAME, MQTT_PASSWORD)
client.connect(MQTT_BROKER, MQTT_PORT, 60)

Correct the line number for GPIO27 as per your setup

NOTE: Adjust the ‘27’ if the line number for GPIO27 is different in your setup

gpio_in = GPIO("/dev/gpiochip0", 27, “in”)

def check_switch():
value = gpio_in.read()
# Debugging: Print GPIO read value
print(f"Checking GPIO27: {value}")
if value:
print(“Switch Press Detected!”)
result, mid = client.publish(MQTT_TOPIC, MQTT_MESSAGE)
if result == mqtt.MQTT_ERR_SUCCESS:
print(“MQTT message sent successfully.”)
print(“Failed to send MQTT message.”)

while True:
time.sleep(0.1) # Polling interval
except KeyboardInterrupt:
print(“Script terminated.”)

Hi there,
Another user had similar issue, it turned out to be the pin numbers that worked, instead of the Logical names.
Try that. (his was an LED on a GPIO )
GL :slight_smile: PJ