I am using PIGPIO library to read temperature and humidity from a DHT22 sensor. This is the script I am using.
import os
import sys
import time
import pigpio
pi = pigpio.pi()
import DHT22
s = DHT22.sensor(pi,4,17)
s.trigger()
time.sleep(0.2)
print("{} {} {:3.2f} {} {} {} {}".format(
s.humidity(), s.temperature(), s.staleness(),
s.bad_checksum(), s.short_message(), s.missing_message(),
s.sensor_resets()))
s.cancel()
pi.stop()
the script runs well and return the temperature and humidity as expected. However, in my terminal I got the following error:
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/home/pi/share/dht_py/pigpio_dht22/DHT22.py", line 238, in cancel
self.pi.set_watchdog(self.gpio, 0)
File "/usr/local/lib/python2.7/dist-packages/pigpio.py", line 1764, in set_watchdog
self.sl, _PI_CMD_WDOG, user_gpio, int(wdog_timeout)))
File "/usr/local/lib/python2.7/dist-packages/pigpio.py", line 983, in _pigpio_command
sl.s.send(struct.pack('IIII', cmd, p1, p2, 0))
AttributeError: 'NoneType' object has no attribute 'send'
Error in sys.exitfunc:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/home/pi/share/dht_py/pigpio_dht22/DHT22.py", line 238, in cancel
self.pi.set_watchdog(self.gpio, 0)
File "/usr/local/lib/python2.7/dist-packages/pigpio.py", line 1764, in set_watchdog
self.sl, _PI_CMD_WDOG, user_gpio, int(wdog_timeout)))
File "/usr/local/lib/python2.7/dist-packages/pigpio.py", line 983, in _pigpio_command
sl.s.send(struct.pack('IIII', cmd, p1, p2, 0))
AttributeError: 'NoneType' object has no attribute 'send'
What is the cause of this error and how to avoid that? Thank you in advance.