Connecting to - SIM900+Mega2560

Why not connect to the server?

SIM900 and Mega2560

#include <DHT.h>
#include <DHT_U.h>
#include <TimeLib.h>
//#include <WidgetRTC.h>
#include <SimpleTimer.h>

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space

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

// Select your modem:
//#define TINY_GSM_MODEM_SIM800
//#define TINY_GSM_MODEM_A6
//#define TINY_GSM_MODEM_M590

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

#define PIN_DOOR            2 // входная дверь в дом
#define PIN_IR              3 // датчик движения в доме
#define DHTPIN              5 // подключен AM2302
#define LED                 4 //
#define DOOR                6 //
#define IR                  7 //

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

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

// Hardware Serial on Mega, Leonardo, Micro
#define SerialAT Serial1

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

TinyGsm modem(SerialAT);

#define DHTTYPE  DHT22


SimpleTimer timer;
//WidgetRTC rtc;

int a;
int ADC_0;

void sendOnOff()  //эта функция выполняеться по таймеру периодически
  digitalWrite(LED, HIGH);

  a = a+1;
  if(a>30) a=0;

  ADC_0 = analogRead(A0);
  Blynk.virtualWrite(V0, ADC_0);

  //-----------------------измеряем влажность и темпиратру AM2302-----------------------------------
  if(a==30)   //прошло 60 секунд - измеряем темпиратуру (a - изменяеться от 0 до 60ти)
    sensors_event_t event;  
    if (!isnan(event.temperature)) 
       Blynk.virtualWrite(V7, event.temperature);
       Serial.print("tempiratura = ");
    if (!isnan(event.relative_humidity)) 
      Blynk.virtualWrite(V8, event.relative_humidity);
      Serial.print("vlashnost   = ");

  digitalWrite(LED, LOW);

void setup()
  // Set console baud rate

  // Set GSM module baud rate

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

  // Unlock your SIM card with a PIN

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

  pinMode(DHTPIN,  INPUT);      //это AM2302
  pinMode(LED,  OUTPUT);        //это LED
  pinMode(DOOR,  INPUT_PULLUP); //дверь
  pinMode(IR,  INPUT_PULLUP);   //ИК датчик


  timer.setInterval(2000L, sendOnOff);        // 

void loop()

Hello. Please use formatting for your code.

Sorry, can not format text, do not get it

Have you looked at? [README] Welcome to Blynk Community!

It is important to format code, as other way it gets unreadable

Thank you

Are you sure you, you don’t need to enter correct credentials for GPRS network? You left the default “YourAPN”, even though there should be usually sth like “internet”…