Hi, so today my DHT22 arrived and i switched it out with the old DHT11 and its much better.I also switched my code from DHT22 to DHT11. Now here is the problem, maybe better to illustrate it with a graph !
So on the second graph you see i get data,zero,data,zero. I did not have this with the DHT11.
Il add the code here, maybe i missed something ?
Thanks in advance guys.
var blynkLib = require('/usr/lib/node_modules/blynk-library');
var sensorLib = require('/usr/lib/node_modules/node-dht-sensor');
var AUTH = 'xxx';
// 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 2 seconds
setInterval(function() {
var readout = sensorLib.read();
blynk.virtualWrite(3, readout.temperature.toFixed(1));
blynk.virtualWrite(5, readout.temperature.toFixed(1));
blynk.virtualWrite(4, readout.humidity.toFixed(1));
blynk.virtualWrite(6, readout.humidity.toFixed(1));
console.log('Temperature:', readout.temperature.toFixed(1) + '°C');
console.log('Humidity: ', readout.humidity.toFixed(1) + '%');
}, 3000);
I tried to put it on PUSH and 1sec and result is the same. Its almost like its getting data saying its 0 but in the console you can see thats not true.
Everythibg is working as it used to.But its not that i don’t get any data from the dht22 its just in stead of just showing like 22 degrees is goes 22,0,22,22,22,0,22,22,0,22 like this. Zero just jumps in from time to time and that does not happen in the console. The graph shows this better
As you have the virtualWrite’s in your script you MUST set the frequency as PUSH.
You can only use 1, 2 , 3 seconds etc if you are not using virtualWrite’s in the script and even if you didn’t have them 1 second would be a bad choice.
Your script comment states 2 second intervals but the actual script shows 3000ms, try at 10000ms.
So i switched it to 10s and the console shows data every 10 seconds, but in Blynk it switches from (in this case) 18.7 to 0 and 18.6 etc while console is not transmitting any data. I’m gonna try that other solution now.
That suggests you still have some widget set with a timed frequency in the app and that the reading frequency is too short for the DHT. Check all widgets and set them all as PUSH frequency.
https://www.youtube.com/watch?v=7-Q0VMRAD-8
This will be better then any explanation i could give. And yes i added 4 because at some point i needed 4. Btw removed those aswel to see if that would help but it didn’t.