BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

My project offline

#1

Hi

in my new project i have arduino mega + ethernet + sim800c keyestudio…
i have insert my token in project, but when play my project is offline and in serial monitor arduino

[12030] Using static IP
[13592] IP:192.168.188.98
[13592] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on Arduino Mega

[13715] Connecting to blynk-cloud.com:8080
[28788] Connecting to blynk-cloud.com:8080
[31951] Login timeout
[33951] Connecting to blynk-cloud.com:8080
[37266] Login timeout

internet is ok , i have generated a new token but always the same problem…

0 Likes

#2

Hello,

you also need to add your wifi informations :slight_smile:

// yourwifi
//char ssid[] = “login”;
//char pass[] = “pass”;

And this line in setup :slight_smile:

Blynk.begin(auth, ssid, pass);

Where auth is your token.

0 Likes

#3

Why do you have both?
Which are you using for the connection?

You probably need to post your code (correctly formatted with backticks of course).

Pete.

0 Likes

#4

this is my initial part code

//Librerie e definizione hardware
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <BlynkSimpleEthernet.h>
#include <SoftwareSerial.h>
#define SIM800_TX_PIN 8                                //SIM800 TX al pin D8 di to Arduino
#define SIM800_RX_PIN 7                                //SIM800 TX al pin D7 di to Arduino
SoftwareSerial mySerial(SIM800_TX_PIN, SIM800_RX_PIN); //Creazione software serial per SIM800L
#define reed 2
#define tamper 3
#define led_1 9
#define led_2 6
#define W5100_CS  10
#define SDCARD_CS 4
SimpleTimer timer;
WidgetTerminal terminal (V30);
//per app blynk con terminal input
BLYNK_CONNECTED() {
      Blynk.syncVirtual(V30);
  }
BLYNK_WRITE(V30)
{
  if (String("1111") == param.asStr()) {
terminal.println("Password Accettata!") ;
Blynk.notify("Attenzione, password impianto accettata, stato impianto OFF");
digitalWrite (2, LOW);
  } else {
terminal.print("Password Errata!!!!!");
Blynk.notify("Attenzione, tentativo di violazione impianto allarme !!!");
Blynk.email("xxxx@gmail.com", "Accesso errato , forzatura impianto allarme!!!");
terminal.write(param.getBuffer(), param.getLength());
terminal.println();
digitalWrite (2,HIGH);
  }
  terminal.flush();
}
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "+++++++++++++++++++++++++++++";
//sync time ntp
EthernetUDP Udp;
IPAddress server_ip (139, 59, 206, 133); //cloud blynk
// Mac address should be different for each device in your LAN
byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress arduino_ip ( 192, 168, 188, 98);
IPAddress dns_ip     (  8,   8,   8,   8);
IPAddress gateway_ip ( 192, 168, 188, 001);
IPAddress subnet_mask(255, 255, 255, 000);
EthernetServer server = EthernetServer(80);

sim for sms and lan is down
lan for blynk app and sim is down

0 Likes

#5

I’ve fixed your code formatting, it’s triple backticks at the beginning and end.
Triple backticks look like this:
```

The initial part of your code is interesting, but doesn’t handle any of the connection process, which is where I suspect the issue is.

Pete.

0 Likes

#6

the part blynk_write(V30), is a terminal input for on/off my allarm , and the code continued

my problem is the part blynk_write ecc…??

0 Likes

#7

From the title of your thread and the serial monitor output in your initial post, the problem is that you aren’t managing to connect to the Blynk cloud server.
The part of the code that handles that connection, and switches from Ethernet to GPRS if the LAN is down is missing from the code that you’ve posted, so it’s impossible for people to advise you on how to rectify the issue unless you post your full code.

Pete.

2 Likes

#8

this is my code in beta version

//Librerie e definizione hardware
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <BlynkSimpleEthernet.h>
#include <SoftwareSerial.h>
#define SIM800_TX_PIN 8                                //SIM800 TX al pin D8 di to Arduino
#define SIM800_RX_PIN 7                                //SIM800 TX al pin D7 di to Arduino
SoftwareSerial mySerial(SIM800_TX_PIN, SIM800_RX_PIN); //Creazione software serial per SIM800L
#define reed 2
#define tamper 3
#define led_1 9
#define led_2 6
#define W5100_CS  10
#define SDCARD_CS 4
SimpleTimer timer;
WidgetTerminal terminal (V30);
//per app blynk con terminal input
BLYNK_CONNECTED() {
      Blynk.syncVirtual(V30);
  }
BLYNK_WRITE(V30)
{
  if (String("1111") == param.asStr()) {
terminal.println("Password Accettata!") ;
Blynk.notify("Attenzione, password impianto accettata, stato impianto OFF");
digitalWrite (2, LOW);
  } else {
terminal.print("Password Errata!!!!!");
Blynk.notify("Attenzione, tentativo di violazione impianto allarme !!!");
Blynk.email("xxxx@gmail.com", "Accesso errato , forzatura impianto allarme!!!");
terminal.write(param.getBuffer(), param.getLength());
terminal.println();
digitalWrite (2,HIGH);
  }
  terminal.flush();
}
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
//sync time ntp
EthernetUDP Udp;
IPAddress server_ip (139, 59, 206, 133); //cloud blynk
// Mac address should be different for each device in your LAN
byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress arduino_ip ( 192, 168, 188, 98);
IPAddress dns_ip     (  8,   8,   8,   8);
IPAddress gateway_ip ( 192, 168, 188, 001);
IPAddress subnet_mask(255, 255, 255, 000);
EthernetServer server = EthernetServer(80);
//variabili lettura sms in entrata
char stringa[100];
char comando[31] = {0};
// variabili antifurto
bool stato_imp = false;
volatile int stato_reed  = LOW;
volatile int stato_tamper = LOW;
String number = "xxxxxxxxxxx";
void setup()
{
  Serial.begin(9600);
  mySerial.begin(9600);
  delay(10000);                             // attendo che il GSM abbia agganciato la linea
  mySerial.print("AT+CMGF=1\r\n");          // imposta il formato del messaggio SMS come testo
  delay(1000);
  mySerial.print("AT+CNMI=1,2,0,0,0\r\n");  // specifica come devono essere gestiti i messaggi SMS appena arrivati
  delay(1000);
  pinMode(reed, INPUT);
  attachInterrupt(digitalPinToInterrupt(reed), line_reed, FALLING );    // FALLING = da alto a basso.
  pinMode(tamper, INPUT);
  attachInterrupt(digitalPinToInterrupt(tamper), line_tamper, FALLING );  // FALLING = da alto a basso.
  pinMode(led_1, OUTPUT);
  digitalWrite(led_1, LOW);
  pinMode(led_2, OUTPUT);
  digitalWrite(led_2, LOW);
    Blynk.begin(auth, "blynk-cloud.com", 8080, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
}
void loop()
{
  lettura_sms();
  antifurto();
  Blynk.run();
  timer.run();
}
void line_reed()
{
  stato_reed = HIGH;
}
void line_tamper()
{
  stato_tamper = HIGH;
}
void antifurto() {
  if (stato_imp = true) { // flag impianto inserito
    number1inserito();
    number2inserito();
    digitalWrite(led_1, HIGH);  // accende led impianto inserito
    if (stato_reed == HIGH) { // contatto porta aperto
      number1allarme();
      number2allarme();
      digitalWrite(led_2, HIGH);  // accende led segnalazione allarme
    }
    if (stato_tamper == HIGH) { // linea tamper aperta
      number1allarme();
      number2allarme();
      digitalWrite(led_2, HIGH); // accende led segnalazione allarme
    }
  }
  else if (stato_imp = false) { // flag impianto disinserito
    number1disinserito();
    number2disinserito();
    digitalWrite(led_1, LOW);  // spengne led a impianto disinserito
  }
}
void number1allarme()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Attenzione, centrale in allarme");
  Serial.write(0x1A);
  delay(1000);
}
void number2allarme()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Attenzione centrale in allarme");
  Serial.write(0x1A);
  delay(1000);
}
void number1inserito()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Sistema allarme inserito");
  Serial.write(0x1A);
  delay(1000);
}
void number2inserito()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Sistema allarme inserito");
  Serial.write(0x1A);
  delay(1000);
}
void number1disinserito()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Sistema allarme OFF");
  Serial.write(0x1A);
  delay(1000);
}
void number2disinserito()
{
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+39xxxxxxxxxxxxx");
  Serial.print("\"\r\n");
  delay(2000);
  Serial.print("Sistema allarme OFF");
  Serial.write(0x1A);
  delay(1000);
}
void lettura_sms() {
  if (mySerial.available()) {
    mySerial.readString().toUpperCase();                         // rendo maiuscola tutta la stringa per evitare errori di sintassi
    mySerial.readString().toCharArray(stringa, 100);              // converto la stringa message nell'array stringa
      strncpy(comando, stringa, 30);                                // copio in comando la prima parte del messaggio ricevuto ossia: +CMT "+39numerotelefono"
    Serial.println(comando);
      if (strncmp(comando, "+39xxxxxxxxx", 13) == 0) {             // poi controllo se in comando sia presente il numero del mittente autorizzato
      if (strncmp(comando, "ON", 2) == 0) {                       // e inserisco impianto
        stato_imp = true;
      }
      else if (strncmp(comando, "OFF", 3) == 0) {                  // o disinserisco impianto
        stato_imp = false;
      }
    }
    mySerial.print("AT+CMGDA=\"");
    mySerial.println("DEL ALL\"");                                // cancello tutti i messaggi
  }
}
0 Likes

#9

And fixed it yet again!

Pete.

1 Like

#10

not function , in serial monitor this message

[12030] Using static IP
[13591] IP:0.0.0.0
[13592] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on Arduino Mega

[13707] Connecting to blynk-cloud.com:8080
[18707] Connecting to blynk-cloud.com:8080
[23708] Connecting to blynk-cloud.com:8080
[28709] Connecting to blynk-cloud.com:8080
0 Likes

#11

Are you trying to connect using GPRS or ethernet?
Try removing all extra spaces from your ip addresses:

// Mac address should be different for each device in your LAN
byte arduino_mac[] = {0xDE,0xED,0xBA,0xFE,0xFE,0xED};
IPAddress arduino_ip (192,168,188,98);
IPAddress dns_ip (8,8,8,8);
IPAddress gateway_ip (192,168,188,001);
IPAddress subnet_mask (255,255,255,000);

Edit also which ethernet shield are you using?

0 Likes

#12

not function, :rage:
my shield is hanrun hr911105a chipset wiznet w5100

from my pc ping the arduino not find .
maybe ethernet shield is death

0 Likes

#13

Try changing your port to: 8442

Blynk.begin(auth, "blynk-cloud.com", 8442, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
0 Likes

#14

no, no and no…

I hope the code is correct … one solution change the eth shield

0 Likes

#15

You would be better-off going back to basics and trying a simple sketch from the sketch builder to
test your shield.

Pete.

0 Likes

#16

i have arder a new shield , maybe this is dead

0 Likes

#17

i have change arduino mega with the same ethernet shield and now this is the result

[12030] Using static IP
[13592] IP:192.168.188.97
[13592] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on Arduino Mega

[13715] Connecting to blynk-cloud.com:8080
[28788] Connecting to blynk-cloud.com:8080
[33789] Connecting to blynk-cloud.com:8080
[48819] Connecting to blynk-cloud.com:8080
[53820] Connecting to blynk-cloud.com:8080
[68849] Connecting to blynk-cloud.com:8080
[69066] Ready (ping: 58ms).
OK
0 Likes

#18

after 15 min

[12030] Using static IP
[13592] IP:192.168.188.97
[13592] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on Arduino Mega

[13715] Connecting to blynk-cloud.com:8442
[28788] Connecting to blynk-cloud.com:8442
[31948] Login timeout
[33948] Connecting to blynk-cloud.com:8442
[48977] Connecting to blynk-cloud.com:8442

:cold_face:

0 Likes

#19

now not have problem

1 Like

#20

How did you fix this?

In case someone searches this topic in future :wink:

0 Likes