Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DHT11 doesn't show result on web #370

Closed
r1rider01 opened this issue Jan 4, 2018 · 93 comments
Closed

DHT11 doesn't show result on web #370

r1rider01 opened this issue Jan 4, 2018 · 93 comments

Comments

@r1rider01
Copy link

Mycodo Issue Report:

  • Specific Mycodo Version: 5.5.4

Problem Description

Please list: DHT11 doesn't display anything, deamon log shows error

  • what were you trying to do
  • specific setup details that are involved

Errors

  • List any errors you encountered.
  • Copy and pasting crash logs, or link to any specific
    code lines you've isolated (please use GitHub permalinks for this)

ERROR: 2018-01-04 09:02:06,949 - mycodo.inputs.dht11_4 - ERROR - Could not initialize sensor. Check if gpiod is running. Error: 'NoneType' object has no attribute 'send'

Additional Notes

Is there anything that should be added to make it easier
to address this issue?

Running the manual test
pi@raspberrypi:~/Mycodo/mycodo/tests/manual_tests $ sudo python test_gpio_DHTx.py -g 3 DHT11

works

pi@raspberrypi:~/Mycodo/mycodo/tests/manual_tests $ sudo python test_gpio_DHTx.py -g 3 DHT11
Temperature: 17.0
Humidity: 48.0
Temperature: 17.0
Humidity: 46.0
Temperature: 17.0
Humidity: 53.0
Temperature: 17.0
Humidity: 53.0
Temperature: 17.0
Humidity: 53.0
Temperature: 17.0
Humidity: 53.0
Temperature: 17.0
Humidity: 53.0
Temperature: 17.0
Humidity: 53.0
Temperature: 17.0
Humidity: 53.0
Temperature: 17.0
Humidity: 53.0

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

Can you verify gpiod is running? execute ps aux | grep gpiod

@r1rider01
Copy link
Author

I know its running, because the test works just fine. Here is output:

pi@raspberrypi:~/Mycodo/mycodo/tests/manual_tests $ ps aux | grep gpiod
pi 2462 0.0 0.0 4372 556 pts/0 S+ 09:16 0:00 grep --color=auto gpiod

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

The test script is much older than the current DHT sensor module in Mycodo, and does not use gpiod. Your ps command output indicates gpiod is not running.

What is returned when you execute sudo pigpiod?

This is what you should see if gpiod is running:

pi@delta:~ $ ps aux|grep gpiod
root       477 21.6  0.1  20440  1524 ?        SLsl Jan03 170:17 /usr/local/bin/pigpiod -s 1
pi       26022  0.0  0.0   4380   560 pts/1    S+   10:16   0:00 grep --color=auto gpiod

@r1rider01
Copy link
Author

sudo pigpiod, returned nothing, but then when running
grep gpiod i now get

pi@raspberrypi:~/Mycodo/mycodo/tests/manual_tests $ ps aux | grep gpiod
root 2561 6.5 0.1 9896 1508 ? SLsl 09:28 0:03 pigpiod
pi 2588 0.0 0.0 4372 528 pts/0 S+ 09:28 0:00 grep --color=auto gpiod

@r1rider01
Copy link
Author

Ok now getting this error:

2018-01-04 09:31:46,234 - mycodo.input_4 - ERROR - StopIteration raised. Possibly could not read input. Ensure it's connected properly and detected.

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

can you open your cron file and paste the contents? Open it with sudo crontab -e

@r1rider01
Copy link
Author

r1rider01 commented Jan 4, 2018

# cmID:mycodo #
@reboot /usr/local/bin/pigpiod -s 1 &
# cm~mycodo #
# cmID:restart_daemon #
@reboot /var/mycodo-root/env/bin/python /var/mycodo-root/mycodo/scripts/restart_daemon.py --continuouscheck &
# cm~restart_daemon #

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

Can you download this file: https://github.com/joan2937/pigpio/blob/master/EXAMPLES/Python/DHT11_SENSOR/dht11.py

Then edit line 157 so it is your DHT11 data pin, instead of "4", then run it and let me know if it works?

@r1rider01
Copy link
Author

r1rider01 commented Jan 4, 2018

pi@raspberrypi:~/Mycodo/mycodo/tests/manual_tests $ python dht11.py
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/local/lib/python2.7/dist-packages/pigpio.py", line 1134, in run
    cb.func(cb.gpio, newLevel, tick)
  File "dht11.py", line 69, in either_edge_callback
    handler(tick, diff)
  File "dht11.py", line 91, in _edge_RISE
    raise
TypeError: exceptions must be old-style classes or derived from BaseException, not NoneType

temperature: 17
humidity: 57
temperature: 17
humidity: 57
temperature: 17
humidity: 57
temperature: 17
humidity: 57

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

Is that what happened? It threw an exception, but then output temp/humidity data? That's weird.

@r1rider01
Copy link
Author

correct, that is copy/paste

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

Can you run it with python 3 from the Mycodo virtualenv to test if it works with python 3?

sudo ~/Mycodo/env/bin/python dht11.py

@r1rider01
Copy link
Author

r1rider01 commented Jan 4, 2018

pi@raspberrypi:~/Mycodo/mycodo/tests/manual_tests $ sudo ~/Mycodo/env/bin/python dht11.py
Traceback (most recent call last):
  File "dht11.py", line 158, in <module>
    for d in sensor:
TypeError: iter() returned non-iterator of type 'DHT11'
pi@raspberrypi:~/Mycodo/mycodo/tests/manual_tests $

edit: I changed for formatting. Encase in tripple-backtics (```) to display as monospace and preserve whitespaces

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

Let me see if I can get it working with python 3 (what Mycodo now runs with as of v5.5.0).

@r1rider01
Copy link
Author

Can i downgrade mycodo? or just wait?

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

To what version?

@r1rider01
Copy link
Author

i can wait, not a rush really. eta on update?

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

I'll try to get something for you to test in the next hour.

@r1rider01
Copy link
Author

Kyle i appreciate your dedication and quick responses!

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

Are you able and willing to give me SSH access to your Pi to perform tests? It will be much quicker for me to just upload a test script and perform tweaks until I can get it working, than to go back-and-forth here with test scripts. Though, I understand if it's a difficulty or a security risk to let a stranger have access to your Pi.

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

I think I got rid of that exception. Change line 143 from:

    def next(self):

to

    def __next__(self):

This is the same code I used in Mycodo, so I'm looking for what can be causing the issue.

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

Before we get deep into changing code, try deactivating your sensor, then activate it again, in Mycodo.

@r1rider01
Copy link
Author

I would allow SSH but my firewall doesn't allow me to open ports. sorry.

Ive deactivated and re activated non stop even rebooted, changed GPIO ports, etc..

@r1rider01
Copy link
Author

your line 143 change is the same thing.... next(self) what am i changing?

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

The line 143 change is for the test script I mentioned, at https://github.com/joan2937/pigpio/blob/master/EXAMPLES/Python/DHT11_SENSOR/dht11.py

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

Just to confirm, since we started pigpiod and confirmed it was running, you have deactivated the DHT11 sensor and activated it again, in Mycodo?

@r1rider01
Copy link
Author

correct

@r1rider01
Copy link
Author

i see line 143 but it already says next(self) what does it need to change to?

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

Change the next() in the test script to include the underscores, as it is here

@r1rider01
Copy link
Author

Kyle i must be missing something this is what i see in your comment:

I think I got rid of that exception. Change "next(self)" on line 143 to "next(self)"

I don't see any _ underscores

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

Great! Can you paste the output from the daemon log, please?

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

I'd also like to get it to return a float value instead of an integer, so would you mind testing one more test module?

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

Also, the graph tooltips (mouse hover) should show F in addition to all C measurements.

@r1rider01
Copy link
Author

2018-01-04 12:14:01,499 - mycodo.daemon - INFO - Mycodo daemon v5.5.4 starting
2018-01-04 12:14:01,723 - mycodo.daemon - INFO - Anonymous statistics enabled
2018-01-04 12:14:01,746 - mycodo.daemon - INFO - Starting rpyc server
2018-01-04 12:14:01,971 - mycodo.output - INFO - Output controller activated in 57.7 ms
2018-01-04 12:14:02,472 - mycodo.daemon - INFO - All activated Timer controllers started
2018-01-04 12:14:02,604 - mycodo.input_2 - INFO - Activated in 94.5 ms
2018-01-04 12:14:02,804 - mycodo.input_4 - INFO - Activated in 105.2 ms
2018-01-04 12:14:02,805 - mycodo.daemon - INFO - All activated Input controllers started
2018-01-04 12:14:02,806 - mycodo.daemon - INFO - All activated Math controllers started
2018-01-04 12:14:02,807 - mycodo.daemon - INFO - All activated PID controllers started
2018-01-04 12:14:02,807 - mycodo.daemon - INFO - All activated LCD controllers started
2018-01-04 12:14:03,362 - mycodo.conditional - INFO - Conditional settings refreshed
2018-01-04 12:14:03,363 - mycodo.conditional - INFO - Conditional controller activated in 54.9 ms
2018-01-04 12:14:03,364 - mycodo.daemon - INFO - Mycodo daemon v5.5.4 started in 1.864 seconds
2018-01-04 12:14:03,366 - mycodo.daemon - INFO - 35.78 MB RAM in use
2018-01-04 12:14:23,087 - mycodo.input_4 - INFO - Deactivated in 85.7 ms
2018-01-04 12:14:25,428 - mycodo.input_4 - INFO - Activated in 96.4 ms

@r1rider01
Copy link
Author

of course ill help just let me know.

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

There should have been more log lines after the sensor activated. No big deal, though. Try this module: dht11.txt

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

Pay attention to the timestamp to make sure it's actually updating after you replace the module with the new code and restart the mycodo daemon.

@r1rider01
Copy link
Author

that was the full log since restart.

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

Ah, that makes sense. If there were no log lines displayed, that meant there were no errors.

@r1rider01
Copy link
Author

New file, got 1 reading then:

2018-01-04 12:27:26,143 - mycodo.daemon - INFO - Mycodo daemon v5.5.4 starting
2018-01-04 12:27:26,382 - mycodo.daemon - INFO - Anonymous statistics enabled
2018-01-04 12:27:26,406 - mycodo.daemon - INFO - Starting rpyc server
2018-01-04 12:27:26,634 - mycodo.output - INFO - Output controller activated in 58.1 ms
2018-01-04 12:27:27,135 - mycodo.daemon - INFO - All activated Timer controllers started
2018-01-04 12:27:27,316 - mycodo.input_2 - INFO - Activated in 130.6 ms
2018-01-04 12:27:27,469 - mycodo.input_4 - INFO - Activated in 92.1 ms
2018-01-04 12:27:27,469 - mycodo.daemon - INFO - All activated Input controllers started
2018-01-04 12:27:27,470 - mycodo.daemon - INFO - All activated Math controllers started
2018-01-04 12:27:27,470 - mycodo.daemon - INFO - All activated PID controllers started
2018-01-04 12:27:27,471 - mycodo.daemon - INFO - All activated LCD controllers started
2018-01-04 12:27:28,073 - mycodo.conditional - INFO - Conditional settings refreshed
2018-01-04 12:27:28,074 - mycodo.conditional - INFO - Conditional controller activated in 101.6 ms
2018-01-04 12:27:28,074 - mycodo.daemon - INFO - Mycodo daemon v5.5.4 started in 1.931 seconds
2018-01-04 12:27:28,077 - mycodo.daemon - INFO - 36.80 MB RAM in use
2018-01-04 12:28:02,031 - mycodo.input_4 - ERROR - StopIteration raised. Possibly could not read input. Ensure it's connected properly and detected.
2018-01-04 12:28:47,211 - mycodo.input_4 - ERROR - StopIteration raised. Possibly could not read input. Ensure it's connected properly and detected.

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

Try this one, please: dht11.txt

@r1rider01
Copy link
Author

same error as above, this time it didn't even give me an initial reading thou.

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

And just to be sure, you're restarting the daemon, then deactivating, and reactivating the sensor, correct?

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

Okay. I'm going back to the original code that worked, because the DHT11 accuracy is +-5% and +-2C, so we don't need float values. Please try this: dht11.txt

@r1rider01
Copy link
Author

back to working just fine :-)

@r1rider01
Copy link
Author

can you add this to the request list:

Make F (Celceuis) default as a setting for us dumb Americans LOL

@r1rider01
Copy link
Author

Are you into Crypto Currency? send me your ETH or LTC address,

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

What do you mean by make it default? As in change the x-axis of the graphs? Unfortunately, that would be very difficult with how the graph code is designed, as all units are hard coded to be SI. If you hover over the graph, it will show you the converted F temperature. This is the compromise I came up with a long time ago that users who requested F were okay with. It also helps to get comfortable with the metric system ;)

Sure, and thanks! I have both:
LTC: LefW35ALg8ZdWQguoDS114QrY3AKC5GPCW
ETH: 0x16097be33831088346e9224eE38Fc23fA3b1d335

@r1rider01
Copy link
Author

very good.

kizniche added a commit that referenced this issue Jan 4, 2018
@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

I just pushed the fix that will be incorporated in the next release. I'll make that release soon. You'll be able to upgrade from the Config -> Upgrade menu once it's live.

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

Okay, v5.5.5 is live. Thanks for the bug report. There are a lot of sensors Mycodo supports that may not work after moving from python 2 to python 3 (Mycodo v5.5.0+), so I appreciate people who come forward and are willing to help test fixes for them.

@r1rider01
Copy link
Author

not sure if this is related...but just noticed that my GPIOD wasn't running after the upgrade?

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

Hmm. It's definitely an issue that it's not starting at boot.

Try starting it with sudo /usr/local/bin/pigpiod -s 1 & and let me know if it starts running by checking ps aux | grep pigpiod

If it's already running, kill it first with sudo killall pigpiod and confirm it has stopped before trying to start it.

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

actually, that may cause an error. Try rebooting, then starting pigpiod

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

can you verify pigpiod is in /usr/local/bin by executing whereis pigpiod

@r1rider01
Copy link
Author

pigpiod: /usr/bin/pigpiod /usr/local/bin/pigpiod /usr/man/man1/pigpiod.1

@r1rider01
Copy link
Author

ok well after reboot it started up, not sure what caused it to fail earlier. will keep an eye out.

FYI sent some ETH

@kizniche
Copy link
Owner

kizniche commented Jan 4, 2018

Okay, I was going to suggest rebooting and seeing if the cron entry starts it. That's good news.

Thanks! I haven't seen the transaction show up yet, but they can take a while. I'll look out for it.

Let me know if you have any other issues.

@kizniche kizniche closed this as completed Jan 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants