Arduino Uno/SIM900/2 relay/DHT22

Hello everyone!

I have a project with Uno, Sim900, 2 relays and dht 22 sensor.
Code from sketch builder.

#define BLYNK_PRINT Serial


// Default heartbeat interval for GSM is 60
// If you want override this value, uncomment and set this option:
//#define BLYNK_HEARTBEAT 30

#include <TinyGsmClient.h>
#include <BlynkSimpleSIM800.h>
#include <SimpleTimer.h>
#include <DHT.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";

// Your GPRS credentials
// Leave empty, if missing user or pass
char apn[]  = "YourAPN";
char user[] = "";
char pass[] = "";

// or Software Serial on Uno, Nano
#include <SoftwareSerial.h>
SoftwareSerial SerialAT(7, 8); // RX, TX

TinyGsm modem(SerialAT);

#define DHTPIN 5          // What digital pin we're connected to

// Uncomment whatever type you're using!

#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321

SimpleTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);

void setup()
  // Debug console


  // Set GSM module baud rate

  // Restart takes quite some time
  // To skip it, call init() instead of restart()
  Serial.println("Initializing modem...");

  Blynk.begin(auth, modem, apn, user, pass);


  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);

void loop()
{;; // Initiates SimpleTimer

My issue is that after some time working, whole project freezes.
For example i started project, turned on relays, some time passed and arduino have no response for turning on/off relays and no data from dht.

Maybe there is any code to restart project any 15 min/ hour or other period.

You shouldn’t need to restart. Try finding the reason for the crash, possibly your cellular modem is dropping connection? Also, do you need to check the DHT22 every second? perhaps switch that to every 5-10 minutes.

modem was working well, it has external power supply, separated from arduino.

I will try to change data sending period.

I also have graph for dht, i have to change period of data to 1 day, because for 1 and 6 hours period data refreshes every minute, right?

No pinMode? I use 2 DHT22 sensors and have both set to INPUT_PULLUP in pinMode to simplify the circuit.