pleas help me

90 views
Skip to first unread message

Pavel Juříček

unread,
Jan 15, 2021, 7:53:59 PM1/15/21
to WebIOPi
2021-01-15 21:48:37 - WebIOPi - INFO - Starting WebIOPi/0.7.1/Python3.7
2021-01-15 21:48:37 - WebIOPi - INFO - GPIO - Native mapped to REST API /GPIO
2021-01-15 21:48:37 - WebIOPi - INFO - Loading configuration from /etc/webiopi/config
2021-01-15 21:48:37 - WebIOPi - ERROR - name 'GPIO' is not defined
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/WebIOPi-0.7.1-py3.7-linux-armv7l.egg/webiopi/__main__.py", line 75, in <module>
    main(sys.argv)
  File "/usr/local/lib/python3.7/dist-packages/WebIOPi-0.7.1-py3.7-linux-armv7l.egg/webiopi/__main__.py", line 69, in main
    server = Server(port=port, configfile=configfile, scriptfile=scriptfile)
  File "/usr/local/lib/python3.7/dist-packages/WebIOPi-0.7.1-py3.7-linux-armv7l.egg/webiopi/server/__init__.py", line 52, in __init__
    self.gpio.addSetups(config.items("GPIO"))
  File "/usr/local/lib/python3.7/dist-packages/WebIOPi-0.7.1-py3.7-linux-armv7l.egg/webiopi/devices/digital/gpio.py", line 62, in addSetups
    self.addGPIOSetup(gpio, params)
  File "/usr/local/lib/python3.7/dist-packages/WebIOPi-0.7.1-py3.7-linux-armv7l.egg/webiopi/devices/digital/gpio.py", line 55, in addGPIOSetup
    self.addGPIO(self.gpio_setup, gpio, params)
  File "/usr/local/lib/python3.7/dist-packages/WebIOPi-0.7.1-py3.7-linux-armv7l.egg/webiopi/devices/digital/gpio.py", line 45, in addGPIO
    func = GPIO.OUT
NameError: name 'GPIO' is not defined

Pavel Juříček

unread,
Jan 16, 2021, 1:37:36 PM1/16/21
to WebIOPi
2021-01-16 19:32:42 - WebIOPi - INFO - Starting WebIOPi/0.7.1/Python2.7
2021-01-16 19:32:42 - WebIOPi - INFO - GPIO - Native mapped to REST API /GPIO
2021-01-16 19:32:42 - WebIOPi - WARNING - Access unprotected
2021-01-16 19:32:42 - WebIOPi - INFO - HTTP Server binded on http://192.168.99.116:8000/
2021-01-16 19:32:42 - WebIOPi - INFO - CoAP Server binded on coap://192.168.99.116:5683/
2021-01-16 19:32:42 - WebIOPi - INFO - CoAP Server binded on coap://224.0.1.123:5683/ (MULTICAST)
^[[A^[[A----------------------------------------
Exception happened during processing of request from ('::ffff:192.168.99.130', 7785, 0, 0)

Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 293, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 655, in __init__
    self.handle()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
    method()
  File "build/bdist.linux-armv7l/egg/webiopi/protocols/http.py", line 277, in do_GET
    self.processRequest()
  File "build/bdist.linux-armv7l/egg/webiopi/protocols/http.py", line 268, in processRequest
    except (GPIO.InvalidDirectionException, GPIO.InvalidChannelException, GPIO.SetupException) as e:
NameError: global name 'GPIO' is not defined
----------------------------------------
gpio version: 2.52
Copyright (c) 2012-2018 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty

Raspberry Pi Details:
  Type: Pi 4B, Revision: 02, Memory: 4096MB, Maker: Sony
  * Device tree is enabled.
  *--> Raspberry Pi 4 Model B Rev 1.2
  * This Raspberry Pi supports user-level GPIO access.

----------------------------------------
 +-----+-----+---------+------+---+---Pi 4B--+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |   2 |   8 |   SDA.1 | ALT0 | 1 |  3 || 4  |   |      | 5v      |     |     |
 |   3 |   9 |   SCL.1 | ALT0 | 1 |  5 || 6  |   |      | 0v      |     |     |
 |   4 |   7 | GPIO. 7 |   IN | 1 |  7 || 8  | 1 | ALT5 | TxD     | 15  | 14  |
 |     |     |      0v |      |   |  9 || 10 | 1 | ALT5 | RxD     | 16  | 15  |
 |  17 |   0 | GPIO. 0 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |
 |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |
 |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |
 |  10 |  12 |    MOSI | ALT0 | 0 | 19 || 20 |   |      | 0v      |     |     |
 |   9 |  13 |    MISO | ALT0 | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |
 |  11 |  14 |    SCLK | ALT0 | 0 | 23 || 24 | 1 | OUT  | CE0     | 10  | 8   |
 |     |     |      0v |      |   | 25 || 26 | 1 | OUT  | CE1     | 11  | 7   |
 |   0 |  30 |   SDA.0 |   IN | 1 | 27 || 28 | 1 | IN   | SCL.0   | 31  | 1   |
 |   5 |  21 | GPIO.21 |   IN | 1 | 29 || 30 |   |      | 0v      |     |     |
 |   6 |  22 | GPIO.22 |   IN | 1 | 31 || 32 | 0 | OUT  | GPIO.26 | 26  | 12  |
 |  13 |  23 | GPIO.23 |   IN | 1 | 33 || 34 |   |      | 0v      |     |     |
 |  19 |  24 | GPIO.24 |   IN | 1 | 35 || 36 | 1 | IN   | GPIO.27 | 27  | 16  |
 |  26 |  25 | GPIO.25 |   IN | 1 | 37 || 38 | 1 | IN   | GPIO.28 | 28  | 20  |
 |     |     |      0v |      |   | 39 || 40 | 1 | IN   | GPIO.29 | 29  | 21  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+---Pi 4B--+---+------+---------+-----+-----+


Dne sobota 16. ledna 2021 v 1:53:59 UTC+1 uživatel Pavel Juříček napsal:

hal8000b

unread,
Jan 18, 2021, 1:23:36 PM1/18/21
to WebIOPi
Hi,
First Im not sure if its ever going to work on a Pi Model 4 as it was wrote for Pi ModelA,B and a patch for Pi Model
2.   If the pinout is the same as Pi Model 2 then you may be in luck

This is your error:
NameError: global name 'GPIO' is not defined

So  for some reason you are working with Python branch 2 and not 3 and chances are that the GPIO library has not been
installed or not compatible with Pi 4B.

You need to post two files.
Your script.py and your index.html

Without these its not possible to answer.
The Pi Model 4 is not the best choice for IoT. Its far too power hungry and  you dont need all that CPU power.
As realys and switches operate in milliseconds not microseconds then the earlier Pi's are excellent and much
more power efficient.

However I'll check back in a few days to see if you have posted these files.

Meantime I'm trying to get  webiopi running on an Orange Pi Zero, more powerful that the Rasberry Pi's  even when underclocked
and used 500mW of power, perfect for IoT
Reply all
Reply to author
Forward
0 new messages