Hello
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_SIM900
//#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
DHT_Unified dht(DHTPIN, DHTTYPE);
SimpleTimer timer;
//WidgetRTC rtc;
int a;
int ADC_0;
void sendOnOff() //эта функция выполняеться по таймеру периодически
{
//clockDisplay();
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;
dht.temperature().getEvent(&event);
if (!isnan(event.temperature))
{
Blynk.virtualWrite(V7, event.temperature);
Serial.print("tempiratura = ");
Serial.println(event.temperature);
}
dht.humidity().getEvent(&event);
if (!isnan(event.relative_humidity))
{
Blynk.virtualWrite(V8, event.relative_humidity);
Serial.print("vlashnost = ");
Serial.println(event.relative_humidity);
}
}
digitalWrite(LED, LOW);
}
void setup()
{
// Set console baud rate
Serial.begin(9600);
delay(10);
// Set GSM module baud rate
SerialAT.begin(9600);
delay(3000);
// Restart takes quite some time
// To skip it, call init() instead of restart()
Serial.println("Initializing modem...");
//modem.restart();
//delay(30000);
// Unlock your SIM card with a PIN
//modem.simUnlock("1234");
Blynk.begin(auth, modem, apn, user, pass);
//rtc.begin();
//Blynk.syncAll();
pinMode(DHTPIN, INPUT); //это AM2302
pinMode(LED, OUTPUT); //это LED
pinMode(DOOR, INPUT_PULLUP); //дверь
pinMode(IR, INPUT_PULLUP); //ИК датчик
//clockDisplay();
timer.setInterval(2000L, sendOnOff); //
Serial.println("START");
}
void loop()
{
Blynk.run();
timer.run();
}