-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime error: not running on a Rpi #49
Comments
failed to initialize hardware SPI, You have to enable spi (0 or 1) or spidev0 or spidev1 for your need. It is "disabled" by default in DTB. Steps:
4 . Edit the file (use jed or any other text editor) , change the spi you need (and the one that can work on M2Z)
|
thank you, but during step 2 i get the following: these are what is in the boot dir: for step 3, which file needs to be specified? |
It should be: ls -la bpi-m2-zero-v4.dtb But, but, but wait a minute, i realized you are running raspi on m2z, is that correct? Sorry, i can't help you with raspi. |
DTB was taken from https://github.com/avafinger/bananapi-zero-ubuntu-base-minimal/releases/download/v3.10/boot_focal.tar.gz and decompiled, then SPI interface was enabled according to avafinger/bananapi-zero-ubuntu-base-minimal#49 .
DTB was taken from https://github.com/avafinger/bananapi-zero-ubuntu-base-minimal/releases/download/v3.10/boot_focal.tar.gz and decompiled, then SPI interface was enabled according to avafinger/bananapi-zero-ubuntu-base-minimal#49 .
I am continuing to get the Runtime error: Not running on a RPi. I am using a Raspberry pi 4B with Ubuntu Mate 20.04. I was using the same simple code on my old 3B+ and it worked fine. I have tried adding the username to the gpio group and it did not fix the issue. I have tried gpiozero and get the same error. Not sure what to do now as I read a lot of other people with the same issue but have not yet found a solution that works for me. Thanks.
code is below:
import RPi.GPIO as GPIO
from hx711 import HX711
#set the pin numbers for the weight sensor on raspberry pi
hx = HX711(5, 6)
hx.set_reading_format("MSB", "MSB")
#set calibration factor aka reference unit
hx.set_reference_unit(105)
hx.reset()
hx.tare()
abc=input("scale is tared, press enter to start ->")
#print("Tare done! Add weight now...")
#begin weight count and export to google sheet
#cellcounter = 2
endloop = 10 #number of times to run the code
for k in range(endloop):
total = 0
endrange = 10 #number of readings to average
for i in range(endrange):
val = hx.get_weight(5)
total = val + total
#set time delay between readings
hx.power_down()
hx.power_up()
time.sleep(0.1)
here is the error:
runfile('/home/4di/.config/spyder-py3/weightgpio.py', wdir='/home/4di/.config/spyder-py3')
/usr/lib/python3/dist-packages/gpiozero/pins/pi.py:129: SPISoftwareFallback: failed to initialize hardware SPI, falling back to software (error was: failed to import spidev)
warnings.warn(
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 69, in call
self = cls._instances[key]
KeyError: (8,)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/gpiozero/pins/pi.py", line 71, in pin
pin = self.pins[n]
KeyError: 8
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 1, in
runfile('/home/4di/.config/spyder-py3/weightgpio.py', wdir='/home/4di/.config/spyder-py3')
File "/usr/lib/python3/dist-packages/spyder_kernels/customize/spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "/usr/lib/python3/dist-packages/spyder_kernels/customize/spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/home/4di/.config/spyder-py3/weightgpio.py", line 4, in
spi = HX711()
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 95, in call
self = super(GPIOMeta, cls).call(*args, **kwargs)
File "/home/4di/.local/lib/python3.8/site-packages/hx711_gpiozero/init.py", line 19, in init
super().init(bits, max_voltage, **spi_args)
File "/usr/lib/python3/dist-packages/gpiozero/spi_devices.py", line 128, in init
super(AnalogInputDevice, self).init(shared=True, **spi_args)
File "/usr/lib/python3/dist-packages/gpiozero/spi_devices.py", line 34, in init
self._spi = self.pin_factory.spi(**spi_args)
File "/usr/lib/python3/dist-packages/gpiozero/pins/pi.py", line 142, in spi
return self.spi_classes[('software', shared)](self, **spi_args)
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 72, in call
self = super(GPIOMeta, cls).call(*args, **kwargs)
File "/usr/lib/python3/dist-packages/gpiozero/pins/local.py", line 152, in init
super(LocalPiSoftwareSPI, self).init(select_pin, active_high=False)
File "/usr/lib/python3/dist-packages/gpiozero/output_devices.py", line 47, in init
super(OutputDevice, self).init(pin, pin_factory=pin_factory)
File "/usr/lib/python3/dist-packages/gpiozero/mixins.py", line 69, in init
super(SourceMixin, self).init(*args, **kwargs)
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 375, in init
pin = self.pin_factory.pin(pin)
File "/usr/lib/python3/dist-packages/gpiozero/pins/pi.py", line 73, in pin
pin = self.pin_class(self, n)
File "/usr/lib/python3/dist-packages/gpiozero/pins/rpigpio.py", line 101, in init
GPIO.setup(self.number, GPIO.IN, self.GPIO_PULL_UPS[self._pull])
The text was updated successfully, but these errors were encountered: