Problem activating GrovePi+ DHT Input

I have a GrovePi+ installed and im trying to connect a DHT22 sensor to the D3 port. From what I can tell that is pin 4

When I active the input I get the following error code in the log. I doesn’t look like something I misconfigured

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.7 from "/var/mycodo-root/env/bin/python"
  * The NumPy version is: "1.20.2"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: libf77blas.so.3: cannot open shared object file: No such file or directory
Traceback (most recent call last):
  File "/var/mycodo-root/env/lib/python3.7/site-packages/numpy/core/__init__.py", line 22, in <module>
    from . import multiarray
  File "/var/mycodo-root/env/lib/python3.7/site-packages/numpy/core/multiarray.py", line 12, in <module>
    from . import overrides
  File "/var/mycodo-root/env/lib/python3.7/site-packages/numpy/core/overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/mycodo-root/mycodo/controllers/base_controller.py", line 74, in run
    self.initialize_variables()
  File "/var/mycodo-root/mycodo/controllers/controller_input.py", line 316, in initialize_variables
    self.measure_input = input_loaded.InputModule(self.input_dev)
  File "/home/pi/Mycodo/mycodo/inputs/grove_temp_humidity.py", line 113, in __init__
    self.initialize_input()
  File "/home/pi/Mycodo/mycodo/inputs/grove_temp_humidity.py", line 118, in initialize_input
    import grovepi
  File "/var/mycodo-root/env/lib/python3.7/site-packages/grovepi.py", line 50, in <module>
    import numpy
  File "/var/mycodo-root/env/lib/python3.7/site-packages/numpy/__init__.py", line 145, in <module>
    from . import core
  File "/var/mycodo-root/env/lib/python3.7/site-packages/numpy/core/__init__.py", line 48, in <module>
    raise ImportError(msg)
ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.7 from "/var/mycodo-root/env/bin/python"
  * The NumPy version is: "1.20.2"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: libf77blas.so.3: cannot open shared object file: No such file or directory

Hmm, I fixed that part by following the instructions in the link provided

sudo apt-get install libatlas-base-dev

Now I get. It might come down to me not understanding the pin numbering and what pin to set in mycodo. Anybody have the GrovePi+ working for them?

2021-04-27 15:03:52,355 - INFO - mycodo.inputs.grove_temp_humidity_96d253e3 - DHT sensor initialization complete, pin=4, type=1.
2021-04-27 15:03:52,356 - INFO - mycodo.controllers.controller_input_96d253e3 - Activated in 160.1 ms
2021-04-27 15:03:52,363 - ERROR - mycodo.inputs.grove_temp_humidity_96d253e3 - Exception raised when taking a reading: not enough values to unpack (expected 3, got 2)
2021-04-27 15:03:54,380 - ERROR - mycodo.inputs.grove_temp_humidity_96d253e3 - Exception raised when taking a reading: not enough values to unpack (expected 3, got 2)
2021-04-27 15:03:56,382 - ERROR - mycodo.inputs.grove_temp_humidity_96d253e3 - Could not acquire a measurement

Im in a bit of a puzzle here. If I run this code I get readings in putty

image

import grovepi
import math
# Connect the Grove Temperature & Humidity Sensor Pro to digital port D3
# This example uses the blue colored sensor.
# SIG,NC,VCC,GND
sensor = 3  # The Sensor goes on digital port 3.

# temp_humidity_sensor_type
# Grove Base Kit comes with the blue sensor.
blue = 0    # The Blue colored sensor.
white = 1   # The White colored sensor.

while True:
    try:
        # This example uses the white colored sensor. 
        # The first parameter is the port, the second parameter is the type of sensor.
        [temp,humidity] = grovepi.dht(sensor,white)  
        if math.isnan(temp) == False and math.isnan(humidity) == False:
            print("temp = %.02f C humidity =%.02f%%"%(temp, humidity))

    except IOError:
        print ("Error")

But with the exact same code in mycodo I get nothing. I even hardcoded the parameters just to be sure

        sensor = 3  # The Sensor goes on digital port 3.
        white = 1   # The White colored sensor.

        self.logger.info("Trying to read")
        [self.temp_temperature,self.temp_humidity] = self.grovepi.dht(sensor,white) 

        if math.isnan(self.temp_temperature) == False and math.isnan(self.temp_humidity) == False:
            self.logger.info("temp = %.02f C humidity =%.02f%%".format(self.temp_temperature, self.temp_humidity))         
        else: 
            self.logger.error(
                "Error reading from DHT sensor: {} {}".format(self.temp_temperature, self.temp_humidity))

This is the log.

2021-04-27 16:19:14,116 - ERROR - mycodo.inputs.grove_temp_and_humidity_0_2c7d04e2 - Error reading from DHT sensor: nan nan

Someone have an idea why the same code wouldnt produce the same result when executed within mycodo?

Apply these changes (either upgrade to master or edit the file and reactivate the Input) and see if it fixes your issues:

Same same, still getting Nan as values.
From the looks of your changes, it looks more or less the same as my version.

No clue whats wrong here. Maybe the grovepi object somehow. Again, running the code directly via putty pulls the values correctly.

I just made some further changes to the GrovePi DHT Input to simplify the code and add more log lines. Give it a try with Log Level: Debug enabled and check the Daemon Log.

Same same

2021-04-28 08:02:41,391 - DEBUG - mycodo.inputs.grove_temp_humidity_96d253e3 - GPIO: 3, Sensor Type: 1
2021-04-28 08:02:41,400 - DEBUG - mycodo.inputs.grove_temp_humidity_96d253e3 - Temp: nan, Hum: nan
2021-04-28 08:02:41,420 - DEBUG - mycodo.controllers.controller_input_96d253e3 - Adding measurements to InfluxDB with ID 96d253e3-6ce8-4bf1-8073-341efbb543e9: {0: {'measurement': 'temperature', 'unit': 'C', 'value': nan, 'timestamp_utc': None}, 1: {'measurement': 'humidity', 'unit': 'percent', 'value': nan, 'timestamp_utc': None}, 2: {'measurement': 'dewpoint', 'unit': 'C', 'value': nan, 'timestamp_utc': None}, 3: {'measurement': 'vapor_pressure_deficit', 'unit': 'Pa', 'value': nan, 'timestamp_utc': None}}

I tried to run it “clean” inside a python output

Same result

2021-04-28 08:26:07,516 - INFO - mycodo.outputs.on_off_python_0c390613 - Initialized in 137.0 ms
2021-04-28 08:26:10,427 - INFO - mycodo.outputs.on_off_python_0c390613 - Temp: nan: Humid: nan: OFF

Running from putty
image

image

Btw. Its not a super critical bug, as I’m not using the DHT22 yet, so you can add to the backlog for later fix:)