Closed fphammerle closed 3 years ago
Confirmed that an upgrade to RPi.GPIO
v0.7.1a4
fixes the issue:
$ sudo docker run -it --device=/dev/gpiomem -e pin=4 hvalev/dht22mqtt-homeassistant:1.1.2 ash
Unable to find image 'hvalev/dht22mqtt-homeassistant:1.1.2' locally
1.1.2: Pulling from hvalev/dht22mqtt-homeassistant
Digest: sha256:d62496030335df0d2c3540689fc4861a4cf566afc8be2594a45fdacb5b9459d2
Status: Downloaded newer image for hvalev/dht22mqtt-homeassistant:1.1.2
/ # python3 -u dht22mqtt.py
Traceback (most recent call last):
File "//dht22mqtt.py", line 7, in <module>
import adafruit_dht
File "/usr/local/lib/python3.9/site-packages/adafruit_dht.py", line 17, in <module>
from digitalio import DigitalInOut, Pull, Direction
File "/usr/local/lib/python3.9/site-packages/digitalio.py", line 15, in <module>
from adafruit_blinka.microcontroller.bcm283x.pin import Pin
File "/usr/local/lib/python3.9/site-packages/adafruit_blinka/microcontroller/bcm283x/pin.py", line 2, in <module>
import RPi.GPIO as GPIO
File "/usr/local/lib/python3.9/site-packages/RPi/GPIO/__init__.py", line 23, in <module>
from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!
/ # apk add --no-cache gcc musl-dev
[...]
/ # pip install RPi.GPIO==0.7.1a4
Collecting RPi.GPIO==0.7.1a4
Using cached RPi.GPIO-0.7.1a4.tar.gz (29 kB)
Building wheels for collected packages: RPi.GPIO
Building wheel for RPi.GPIO (setup.py) ... done
Created wheel for RPi.GPIO: filename=RPi.GPIO-0.7.1a4-cp39-cp39-linux_armv7l.whl size=24929 sha256=92c61194b4da4c2467c62b76a90f6fed4423b9c8f3ca1c9e2537c9f6841c4c41
Stored in directory: /root/.cache/pip/wheels/6f/1c/5c/113894ea5785c8856518ad0d88803c2ec7cbc6cb88e47f2e04
Successfully built RPi.GPIO
Installing collected packages: RPi.GPIO
Attempting uninstall: RPi.GPIO
Found existing installation: RPi.GPIO 0.7.0
Uninstalling RPi.GPIO-0.7.0:
Successfully uninstalled RPi.GPIO-0.7.0
Successfully installed RPi.GPIO-0.7.1a4
WARNING: You are using pip version 21.0.1; however, version 21.1.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
/ # logging=log2stdout python3 -u dht22mqtt.py
2021-05-02T09:13:14Z Starting dht22mqtt...
2021-05-02T09:13:14Z Setup dht22 sensor success...
for reference, why /proc/device-tree
/ /sys/firmware/devicetree/base
is not available in non-privileged docker containers: https://github.com/docker/docker-ce/blob/v19.03.15/components/engine/oci/defaults.go#L127
Looks good to me! Thank you for your contribution. I've accepted your pull request and will update the docker container on docker hub shortly.
great, thanks!
Thanks for sharing this project!
Issue
Background
Allegedly,
RPi.GPIO
supports the raspberry pi 4: https://pypi.org/project/RPi.GPIO/However:
source/cpuinfo.c
fromRPi.GPIO-0.7.0.tar.gz
:/proc/device-tree/system/linux,revision
is not available in non-privileged docker container:due to a shadowing
tmpfs
at/sys/firmware
:and
get_rpi_info
does not compare against RPi4's chip version:This issue will be fixed
RPi.GPIO
v0.7.1
: https://sourceforge.net/p/raspberry-gpio-python/tickets/190/Question
Could you install
v0.7.1a4
instead ofv0.7.0
to support rRPi4 (without--privileged
)?https://github.com/hvalev/dht22mqtt-homeassistant-docker/blob/main/requirements.txt#L3