sumnerboy12 / mqtt-gpio-monitor

Python script for sending/receiving commands to/from GPIO pins via MQTT messages
46 stars 23 forks source link

Errors at start of script #10

Closed spieter closed 8 years ago

spieter commented 8 years ago

I get an error when i start the script.

Traceback (most recent call last): File "./mqtt-gpio-monitor.py", line 330, in <module> poll() File "./mqtt-gpio-monitor.py", line 310, in poll if newstate != oldstate: UnboundLocalError: local variable 'newstate' referenced before assignment Exception in thread Thread-1 (most likely raised during interpreter shutdown): Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner File "/usr/lib/python2.7/threading.py", line 505, in run File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 2287, in _thread_main File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1261, in loop_forever File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 811, in loop File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1073, in loop_read File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1475, in _packet_read File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1949, in _packet_handle File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 2006, in _handle_connack File "./mqtt-gpio-monitor.py", line 129, in on_connect <type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'subscribe'

in the log file : 2016-02-17 09:23:30,001 INFO Starting mqtt-gpio-monitor 2016-02-17 09:23:30,013 INFO INFO MODE 2016-02-17 09:23:30,021 DEBUG DEBUG MODE 2016-02-17 09:23:30,027 DEBUG INIFILE = mqtt-gpio-monitor.ini 2016-02-17 09:23:30,036 DEBUG LOGFILE = mqtt-gpio-monitor.log 2016-02-17 09:23:30,039 DEBUG Monitoring pins [9, 10] 2016-02-17 09:23:30,065 DEBUG Connecting to 192.168.178.17:1883... 2016-02-17 09:23:30,099 INFO Connected to 192.168.178.17:1883

What could be the problem ?

sumnerboy12 commented 8 years ago

Not a great error message to be fair, but it looks like you haven't specified which module you wish to use in your ini file. Have you read the README?

spieter commented 8 years ago

I changed it to 'MODULE = gpio', now i get a diffrent error. I use the GPIO pins direct.

Traceback (most recent call last): File "./mqtt-gpio-monitor.py", line 326, in init_gpio() File "./mqtt-gpio-monitor.py", line 272, in init_gpio GPIO.setup(pin, GPIO.IN) ValueError: The channel sent is invalid on a Raspberry Pi

spieter commented 8 years ago

I changed from monitorring pin 9 and 10 to 23 and 24. Now it seems to work. i am testing with a breadboard. What volt is high for standard gpio pins ? 3,3V or 5 V ?

Anyway thanks for the fast response and for making this little script available.

bgewehr commented 8 years ago

3,3V