Device offline after 1 day

Hello com

I have a Raspberry pi 3 with a dht22 sensor and use the blynk server. It works good but i have the problem that after 1 day or 2 it shows me you raspberry is offline then i reboot the pi and it work again 1 or 2 days and it goes again offline. Can say me anyone what is the problem??

We need to know more .
Please post your code.

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

var AUTH = 'YOUR_AUTH_TOKEN';

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

// Setup sensor, exit if failed
var sensorType = 11; // 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(4, readout.humidity.toFixed(1));
    
    console.log('Temperature:', readout.temperature.toFixed(1) + 'C');
    console.log('Humidity:   ', readout.humidity.toFixed(1)    + '%');
}, 2000);

Use ``` to format your code
Your code isn’t complete, we can’t help you

1 Like

Thank you for the formated code
I think you are using Node.js
I use C++, so maybe @PeteKnight could help :thinking:

1 Like

Yes i use node.js . I hope he can help🥺

1 Like

Nope, Raspberry Pi’s are best used as servers for Blynk, MQTT and Node-Red in my opinion, I’ve never felt the need to run the Blynk client on one.

Pete.

2 Likes

Is it maybe the 2 seconds intervall?

Maybe, try to increase to 30 secs

1 Like

Ok i test it

1 Like

I have test it and after 2 days it shows me again „device is offline“ :sob: can you show me maybe your code in c++ because maybe i use this methode when its run better. Or is it not possible?

You can’t run C++ on a Pi without some sort of emulator software.
The only one that I’m aware of was WiringPi, and that is now deprecated.

Are you 100% tied to using the Pi as your board?
As I said earlier, I think Pis are great as servers, but they are far too expensive, cumbersome to set-up and slow to boot for use as a board to use as an interface for a DHT sensor.

Pete.

Yes i must use my pi as my board because all the other devices run over this pi :pleading_face::see_no_evil: then i must life with this reboots :pensive:

How you do this with c++ @Blynk_Coeur ?

Or can write me maybe someone a script that reboot my pi when blynk shows me „device is offline“ ?

I use ESP 8266 and ESP32, so I have no idea for PI :slight_smile:

And it always works for you without problems? Then i buy me a esp8266 :sweat_smile: