Not running on a RPi! on Pi4B running AWS Greengrass
A Python module to control the GPIO on a Raspberry Pi
Brought to you by:
croston
Having issues getting GPIO input on RPi4B using AWS Greengrass. I get the error:
RuntimeError: Not running on a RPi!.
My code looks like this:
import time
import datetime
import json
import awsiot.greengrasscoreipc
from awsiot.greengrasscoreipc.model import (
PublishToTopicRequest,
PublishMessage,
JsonMessage
)
import RPi.GPIO as GPIO
channel = 20
GPIO.setmode(GPIO.BCM)
GPIO.setup(channel, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
while True:
if GPIO.input(channel) == GPIO.LOW:
print("Hello")
time.sleep(5)
The error happens on the first line that actually uses the library:
GPIO.setmode(GPIO.BCM)
I do see this two year old issue that is similar but I believe that because this is running in the greengrass framework my issue would be a bit different.
https://sourceforge.net/p/raspberry-gpio-python/tickets/171/
I originally started out with gpiozero and had the same issue. They sent me here. Here is a link to that issue.
I have learned a bit more. When I run commands in the cli as the greengrass user I get the errors. It definitely seems to be a hardware detection error that is happening but only when run a certain users.
Solved. Adding the user that greengrass runs as to the group gpio fixed the issue.