Instructables code for raspberrypi 4b Dht22 not updating

My DHT22 values for temp and humidity are static. not updating. I am using the code as seen on the Instructibles code sample for DHT22.

I am using a Raspberrypi 4b. I do not receive any errors. My Temp and Humidity values are fixed and never change. I have checked the DHT22 and it seems to be fine. I replaced it and it still does not update values for temp and humidity.

I have notieced in the project hardware section there is not a value for Raspberrypi 4b. I am using the 3b hardware designation…

Link?

Pete.

Thank you.

I am using a Raspberrypi 3b on this same project. And I have duplicated the code for the Raspberrypi 4b. The Raspberrypi 3b works fine.

code:

var blynkLib = require('blynk-library');
var sensorLib = require('node-dht-sensor');

var AUTH = 'k0zNzezAytitrdAUAsXLkE5n38rTnz05';

// Setup Blynk
var blynk = new blynkLib.Blynk(AUTH);

// Setup sensor, exit if failed
var sensorType = 22; // 11 for DHT11, 22 for DHT22 and AM2302
var sensorPin  = 4;  // The GPIO pin number for sensor signal
if (!sensorLib.initialize(sensorType, sensorPin)) {
    console.warn('Failed to initialize sensor');
    process.exit(1);
}

// Automatically update sensor value every 5 seconds
setInterval(function() {
    var readout = sensorLib.read();
    readout.temperature = readout.temperature * 9/5.0 + 32
    blynk.virtualWrite(13, readout.temperature.toFixed(1));
    blynk.virtualWrite(14, readout.humidity.toFixed(1));
 //   console.log('Temperature:', readout.temperature.toFixed(1) + 'F');
 //   console.log('Humidity:   ', readout.humidity.toFixed(1)    + '%');
}, 5000);

@chip please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Pete.

Done.

You’ve done something, but not what I asked you to do.
I have you triple backticks to copy/paste, I suggest you use them.

Pete.

Done again. Sorry, never used them before.

I noticed when I run my script the “onoff” mode is turned on. Is that a problem?

I have four pieces of hardware on this project;
2 ESP-01 in New Hampshire (all working)
1 Raspberrypi 3b in New Hampshire (working)
1 Raspberrypi 4b in Florida (the problem child)

if you uncomment these lines, can you post on what you see on the Pi4 console ?

 //   console.log('Temperature:', readout.temperature.toFixed(1) + 'F');
 //   console.log('Humidity:   ', readout.humidity.toFixed(1)    + '%');

It looks like things could be working. I have gotten a delay on the Blynk cloud of about two hours which makes it looks like no update on the dht22 values. Thanks for your reply.

Maybe you should change to a differnet time range in SuperChart.
Live will show the data immediately, 15 minutes to 3 days will show updates every minute, 1 week and higher will show updates every hour.

If you don’t have the time ranges you want the this can be changed in the SuperChart widget (at the bottom, in edit mode).

Pete.