Large values reading DHT22 sensor with NodeJS

It seems no matter what I do the DHT22 humidity and temperature sensor doesn’t want to work correctly using Nodejs:

const GrovePi = require("node-grovepi").GrovePi
const Board = GrovePi.board
const DHTDigitalSensor = GrovePi.sensors.DHTDigital

var board = new Board({
  debug: true,
  onError: err => console.log(err),
  onInit: res => {
    if (res) {
      console.log(`**Board Version :: ${board.version()}`)
      var dhtSensor = new DHTDigitalSensor(
        4,
        DHTDigitalSensor.VERSION.DHT22,
        DHTDigitalSensor.CELSIUS
      )
      function readHumidityTemp() {
        console.log(dhtSensor.read())
        setTimeout(readHumidityTemp, 1000)
      }
      setTimeout(readHumidityTemp, 1000)
    }
  }
})

board.init()

I ran:

  • firmware update to 1.2.7
  • sudo install.sh (under GrovePi/Script/)
  • sudo setup.py --install (under GrovePi/Software/Python/)

and still readings from the sensor for temp and humidity are 6.805646932770577e+38 (which means the bytes read from the sensor are all 0xff).

Also, the board version is also incorrect - most of the time 255.255.255 (many 0xff again).

I tried to see if python scripts work ok, but got a mixed results:
sudo python grove_firmware_version_check.py -> returns 255.255.255 most of the time
sudo python grove_dht_pro.py -> returns ok results: temp = 24.10 C humidity =35.70%

To make things more interesting we have number of GrovePi shields and sensors and all of them behave the same.

Hi @jakub.kozakiewicz,

Here’s what we need to do before we test anything else:

  1. Update the software on your Raspberry Pi. This means you have to click on DI Software Update and click on Update Dexter Software.

  2. After the above step is done, reboot the your Raspberry Pi and click on DI Software Update again and this time, from the drop-down menu, select the GrovePi and then hit Update Robot. Make sure you have your GrovePi connected to the Raspberry Pi and that nothing is plugged in it.

  3. Tell us what you get by issuing the sudo python grove_firmware_version_check.py command.

  4. If step 3 is a success and you see a version coming up, then try running your NodeJS script again.

If would be nice to also post your log.txt that you get after you follow the 2nd step. If it didn’t work for you, this log.txt file might give us more details on your issue.

Thank you!

Thanks @RobertLucian,

I’m afraid that all that wouldn’t help as we have done it already multiple times. The good news is we managed to figure out the root cause for that issue.

In our particular case, we had number of sensors attached to GrovePi including DHT pro sensor, Digital Light, Pressure, UV, PIR, Piezo and more.

We ran them all as separate nodejs applications, each one of them instantiate GrovePi.board. Most of the sensors would work ok in that setup, but DHT pro sensor would start generating large readings and sudo python grove_firmware_version_check.py command would return 255.255.255. When we ran DHT pro sensor on its own, everything works ok.

Not sure if that is documented anywhere and if that is expected behaviour, but maybe it is something you need to fix.

Right now we are in the process of rewriting the way we read values from sensors.

Hi @jakub.kozakiewicz,

Thank for letting us know of this issue.
I’ve created a ticket on this issue and we will investigate it.

Thank you!

Hi @jakub.kozakiewicz,

Here’s one suggestion you may try: try reading all sensors within the same application, instead of having separate processes for each of it.

Also, it seems like the Grove DHT Pro has a timing issue, which may cause the problem you’ve encountered.
So for now, I encourage you to add some delays before and after reading the Grove DHT Pro sensor.

Let me know how this works for you.

Thank you!

Thanks @RobertLucian - we have already rewrote our application and everything seems to be working ok.
I’m yet to confirm if we are getting any issues with DHT Pro sensor timing.

Hi @jakub.kozakiewicz,

Then I’ll keep this thread open for you in case you get further issues.

By the way, do you think what you wrote could be a benefit for our open-source repository?

Thank you!

Hi @RobertLucian - I’m happy to share what I have so far.
I’ll publish the code on my github and add links here.