Post by cdenney on Apr 3, 2022 9:31:06 GMT -8
The dust sensor seemed to go down today (got a serious of identical readings), so I tried rebooting the pi, but that just resulted in it not recording any data for a while. When I tried running the script manually, I got some errors related to the dust sensor. Here's the output when I tried running the testDustHM3301.py script
>>python3 testDustHM3301.py
./SkyWeather2.JSON File exists
/home/pi/SDL_Pi_SkyWeather2/testDustHM3301.py:19: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(config.DustSensorPowerPin, GPIO.OUT)
b"2022-04-03 10:24:02 initCheckPermitted: \n+---------------------------------------------------------+\n|Sorry, you don't have permission to run this program. |\n|Try running as root, e.g. precede the command with sudo. |\n+---------------------------------------------------------+\n\n\nCan't initialise pigpio library\n"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Can't connect to pigpio at localhost(8888)
Did you start the pigpio daemon? E.g. sudo pigpiod
Did you specify the correct Pi host/port in the environment
variables PIGPIO_ADDR/PIGPIO_PORT?
E.g. export PIGPIO_ADDR=soft, export PIGPIO_PORT=8888
Did you specify the correct Pi host/port in the
pigpio.pi() function? E.g. pigpio.pi('soft', 8888)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Traceback (most recent call last):
File "/home/pi/SDL_Pi_SkyWeather2/DustSensor.py", line 43, in <module>
hm3301 = SDL_Pi_HM3301.SDL_Pi_HM3301(SDA= config.DustSensorSDA, SCL = config.DustSensorSCL, pi=myPi)
File "./SDL_Pi_HM3301/SDL_Pi_HM3301.py", line 41, in __init__
h = self.pi.bb_i2c_open(self.SDA, self.SCL, 20000)
File "/usr/lib/python3/dist-packages/pigpio.py", line 3464, in bb_i2c_open
return _u2i(_pigpio_command_ext(
File "/usr/lib/python3/dist-packages/pigpio.py", line 1062, in _pigpio_command_ext
sl.s.sendall(ext)
AttributeError: 'NoneType' object has no attribute 'sendall'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/SDL_Pi_SkyWeather2/testDustHM3301.py", line 39, in <module>
import DustSensor
File "/home/pi/SDL_Pi_SkyWeather2/DustSensor.py", line 45, in <module>
myPi.bb_i2c_close(config.DustSensorSDA)
File "/usr/lib/python3/dist-packages/pigpio.py", line 3481, in bb_i2c_close
return _u2i(_pigpio_command(self.sl, _PI_CMD_BI2CC, SDA, 0))
File "/usr/lib/python3/dist-packages/pigpio.py", line 1025, in _pigpio_command
sl.s.send(struct.pack('IIII', cmd, p1, p2, 0))
AttributeError: 'NoneType' object has no attribute 'send'
This seems like it's probably an issue with trying to reach the dust sensor board over the GPIO pins, but I'm not sure what the next troubleshooting steps would be.
-edit- ok on further troubleshooting, this seems to be a problem with initializing the pigpio connection. For some reason "localhost" and port 8888 isn't working.
this thread suggested starting pigpiod from the terminal and running netstat -vatn to see what it was listening on, but unlike that OP, none of the connections were labelled as pigpiod and the port 8888 was attached to a tcp6 address:
this thread suggested starting pigpiod from the terminal and running netstat -vatn to see what it was listening on, but unlike that OP, none of the connections were labelled as pigpiod and the port 8888 was attached to a tcp6 address:
pi@raspberrypi:~ $ sudo pigpiod
pi@raspberrypi:~ $ netstat -vatn
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:5900 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 64 192.168.0.127:22 192.168.0.122:55139 ESTABLISHED
tcp 0 0 192.168.0.127:22 192.168.0.122:53327 ESTABLISHED
tcp 0 0 127.0.0.1:45943 127.0.0.1:39950 ESTABLISHED
tcp 0 0 127.0.0.1:39950 127.0.0.1:45943 ESTABLISHED
tcp 0 0 192.168.0.127:22 192.168.0.122:54436 ESTABLISHED
tcp 0 0 192.168.0.127:22 192.168.0.122:54535 ESTABLISHED
tcp6 0 0 :::5900 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN
tcp6 0 0 :::8888 :::* LISTEN
I tried replacing the port argument with those two ports that were listening at localhost and I also tried to replace the host argument with the tcp6 adress that was listenting to 8888, but none of it worked. If I had to guess, it seems like the raspberry pi is tying up the port to some other ipv6 address for some reason, which is preventing pigpio.pi() from connecting on the defaults, but I can't fiure out more than that.
-edit2- Ok, so once I killed all pigpiod processes (sudo killall pigpiod), and then using the -n 127.0.0.1 argument from the earlier thread, I was able to get it to listen to an ipv4 address as expected, and testDustHM3301.py script is returning dust/AQI values, but it's starting out with the following warning:
The main SkyWeather2 script is also running (although with the same error). However, when I reboot the pi, the fix I did by manually starting pigpiod with the forced ipv4 seems to reset and I get the original problem. I'm not sure how to do the "sudo pigpiod -n 127.0.0.1" by default.
-edit2- Ok, so once I killed all pigpiod processes (sudo killall pigpiod), and then using the -n 127.0.0.1 argument from the earlier thread, I was able to get it to listen to an ipv4 address as expected, and testDustHM3301.py script is returning dust/AQI values, but it's starting out with the following warning:
python3 testDustHM3301.py
./SkyWeather2.JSON File exists
/home/pi/SDL_Pi_SkyWeather2/testDustHM3301.py:21: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(config.DustSensorPowerPin, GPIO.OUT)
b"2022-04-03 11:15:41 initCheckPermitted: \n+---------------------------------------------------------+\n|Sorry, you don't have permission to run this program. |\n|Try running as root, e.g. precede the command with sudo. |\n+---------------------------------------------------------+\n\n\nCan't initialise pigpio library\n"
The main SkyWeather2 script is also running (although with the same error). However, when I reboot the pi, the fix I did by manually starting pigpiod with the forced ipv4 seems to reset and I get the original problem. I'm not sure how to do the "sudo pigpiod -n 127.0.0.1" by default.