IOT2000 Siemens Slow

Hi everyone, I am writing to you because I bought a Siemens IOT2020 from there.
I state that I have been using Arduino UNO / mega / due cards with wifi and Ethernet shield for a long time as well as Esp 8266 …
I made a test skeg to connect the IOT2020 with Blynk …


#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxx";
int i=1;
void setup()
{
  // Debug console
  Serial.begin(115200);
  Blynk.begin(auth);
  // You can also specify server:
  //Blynk.begin(auth, "blynk-cloud.com", 80);
  //Blynk.begin(auth, IPAddress(192,168,0,80), 8080);
}

void loop()
{
  //delay(1000);
  i=i+1;
  Blynk.virtualWrite(V1,i);
  Serial.println(i);
  Blynk.run();
}

As you can see from the serial monitor it is very slow, it loops every 10 seconds.

06:27:54.923 -> [824] Getting IP...
06:27:55.925 -> [1829] IP:192.168.0.53
06:27:55.925 -> [1837] 
06:27:55.958 ->     ___  __          __
06:27:55.958 ->    / _ )/ /_ _____  / /__
06:27:55.958 ->   / _  / / // / _ \/  '_/
06:27:55.991 ->  /____/_/\_, /_//_/_/\_\
06:27:55.991 ->         /___/ v0.5.4 on Arduino
06:27:55.991 -> 
06:27:55.991 -> [1888] Connecting to blynk-cloud.com:80
06:27:56.130 -> [2030] Ready (ping: 89ms).
06:28:11.296 -> 2
06:28:21.381 -> 3
06:28:31.431 -> 4
06:28:41.486 -> 5
06:28:51.544 -> 6
06:29:01.606 -> 7
06:29:11.656 -> 8
06:29:24.826 -> 9
06:29:31.760 -> 10
06:29:41.811 -> 11
06:29:51.856 -> 12
06:30:02.057 -> 13
06:30:12.128 -> 14
06:30:22.737 -> 15
06:30:32.978 -> 16
06:30:42.185 -> 17

I kindly ask you if you can help me understand the cause.

I am thinking this might be because with the delay in the void loop, it has to reconnect to blynk every loop.

Thanks for replying, as you go the “delay (1000)” has the “//” so it is not compiled.

from terminal the ping is good.

PING 192.168.0.53 (192.168.0.53): 56 data bytes
64 bytes from 192.168.0.53: icmp_seq=0 ttl=64 time=11.032 ms
64 bytes from 192.168.0.53: icmp_seq=1 ttl=64 time=3.628 ms
64 bytes from 192.168.0.53: icmp_seq=2 ttl=64 time=7.241 ms
64 bytes from 192.168.0.53: icmp_seq=3 ttl=64 time=7.731 ms
64 bytes from 192.168.0.53: icmp_seq=4 ttl=64 time=7.261 ms
64 bytes from 192.168.0.53: icmp_seq=5 ttl=64 time=13.162 ms
64 bytes from 192.168.0.53: icmp_seq=6 ttl=64 time=1.998 ms
64 bytes from 192.168.0.53: icmp_seq=7 ttl=64 time=6.416 ms
64 bytes from 192.168.0.53: icmp_seq=8 ttl=64 time=1.862 ms
64 bytes from 192.168.0.53: icmp_seq=9 ttl=64 time=6.390 ms
64 bytes from 192.168.0.53: icmp_seq=10 ttl=64 time=7.094 ms

You should never put Blynk.virtualWrites in the void loop.
You’re using a very old version of the Blynk library.

Pete.

You’re right and I apologize, I usually use BlinkTimer, mine was just a test …
Now I have changed and the problem is the same.

#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
BlynkTimer timer;
char auth[] = "xxxxxxxxxxxxxxxxxxxxx";
int i=1;

void myTimerEvent()
{
  i=i+1;
  Blynk.virtualWrite(V1,i);
  Serial.println(i);
}

void setup()
{
  Serial.begin(115200);
  Blynk.begin(auth);
  timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
  Blynk.run();
  timer.run();
}

I forgot, I apologize for my English, I am Italian …

As you can see, Blynk’s library is updated

Is there anyone who uses the Simmens IOT2000 with Blynk?

I did some tests, if I insert in the sketch two Blynk.virtualWrite the waiting time for writing the date doubles, if I put three Blynk.virtualWrite the data update time triples.
Another test I did is to modify the Refresh Iternal on the “Widget” “Value Display”, if I set it on “Push” the transmission time is 5/6 seconds, if or I put 1 according to the application Blynk goes “OffLine”, if I put it at 15 seconds the update time is 15 seconds.
I hope that with this information someone can help me, thanks.

If you remove the Blynk part does it loop faster or as expected?

Hi Idb, or made several tests, I removed Blynk.virtualWrite and as you can see the loop cycle is 5 seconds.

#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
BlynkTimer timer;
char auth[] = "xxxxxxxxxxxxxxxxx";
int i=1;
float mem;

void myTimerEvent()
{
  mem=millis()/1000;
  //Blynk.virtualWrite(V1,i);
  Serial.println(i);
  Serial.println(millis()/1000-mem);
  i=i+1;
}

void setup()
{
  Serial.begin(115200);
  Blynk.begin(auth);
  timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
  Serial.println("");
  Serial.println("test");
  Serial.println("");
  Blynk.run();
  timer.run();
}

17:04:13.107 -> [784] Getting IP...
17:04:14.117 -> [1788] IP:192.168.1.18
17:04:14.117 -> [1798] 
17:04:14.117 ->     ___  __          __
17:04:14.155 ->    / _ )/ /_ _____  / /__
17:04:14.155 ->   / _  / / // / _ \/  '_/
17:04:14.155 ->  /____/_/\_, /_//_/_/\_\
17:04:14.155 ->         /___/ v0.5.4 on Arduino
17:04:14.155 -> 
17:04:14.189 -> [1845] Connecting to blynk-cloud.com:80
17:04:14.292 -> [1982] Ready (ping: 79ms).
17:04:24.435 -> 
17:04:24.435 -> test
17:04:24.435 -> 
17:04:29.426 -> 1
17:04:29.426 -> 0.00
17:04:29.426 -> 
17:04:29.426 -> test
17:04:29.426 -> 
17:04:34.486 -> 2
17:04:34.486 -> 0.00
17:04:34.486 -> 
17:04:34.486 -> test
17:04:34.486 -> 
17:04:39.447 -> 3
17:04:39.447 -> 0.00
17:04:39.447 -> 
17:04:39.447 -> test
17:04:39.447 -> 
17:04:44.509 -> 4
17:04:44.509 -> 0.00
17:04:44.509 -> 
17:04:44.509 -> test
17:04:44.509 -> 

Other test I have removed Blynk.begin (auth); and now the Loop is normal

#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
BlynkTimer timer;
char auth[] = "xxxxxxxxxxxxxxxxx";
int i=1;
float mem;

void myTimerEvent()
{
  mem=millis()/1000;
  //Blynk.virtualWrite(V1,i);
  Serial.println(i);
  Serial.println(millis()/1000-mem);
  i=i+1;
}

void setup()
{
  Serial.begin(115200);
  //Blynk.begin(auth);
  timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
  Serial.println("");
  Serial.println("test");
  Serial.println("");
  Blynk.run();
  timer.run();
}

17:07:07.614 -> 
17:07:07.614 -> test
17:07:07.614 -> 
17:07:07.614 -> 
17:07:07.614 -> test
17:07:07.614 -> 
17:07:07.614 -> 
17:07:07.614 -> test
17:07:07.614 -> 
17:07:07.614 -> 
17:07:07.614 -> test
17:07:07.614 -> 
17:07:07.614 -> 
17:07:07.614 -> test
17:07:07.614 -> 
17:07:07.614 -> 
17:07:07.614 -> test
17:07:07.614 -> 
17:07:07.614 -> 
17:07:07.614 -> test
17:07:07.614 -> 
17:07:07.614 -> 
17:07:07.614 -> test
17:07:07.614 -> 
17:07:07.614 -> 
17:07:07.614 -> test
17:07:07.614 -> 
17:07:07.614 -> 
17:07:07.614 -> test
17:07:07.614 -> 
17:07:07.614 -> 
17:07:07.614 -> test

Thank you for your interest, do you have any idea what the reason is?
I am afraid that this IOT2020 chassis is not very compatible with Blynk, and I will have to abandon…

I also tried to remove #define BLYNK_PRINT Serial, it’s always slow …
I also removed the BlynkTimer timer function and the loop is always slow 5 seconds.

I’m not familiar with this Siemens device and I believe it’s not popular in this community. You have 2 options, dig the Blynk library and try to find where it slow it down. Or use the HTTP API

Thanks Thanks Idb …
You are fantastic!
I tried to transmit the data with HTTP API GET

http://blynk-cloud.com/xxxxxxxxxxxxxxxxxxx/get/V2

IT WORKS!! The delay is 0.3 second, is that right?

#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
BlynkTimer timer;
char auth[] = "axxxxxxxxxxxxxxxxxxxxxxxx";
const char* host = "blynk-cloud.com";
unsigned int port = 8080;
byte mac[] = { 0xE0, 0xDC, 0xA0, 0x18, 0xB7, 0x41 }; //E0:DC:A0:18:B7:41 
EthernetClient client;
#define SDCARD_CS 4
int i=1;
float mem;

      void connectNetwork()
{
  Serial.println("Connecting to Ethernet...");
  pinMode(SDCARD_CS, OUTPUT);
  digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    while (true);
  }

  // Give the Ethernet shield a second to initialize
  delay(1000);
  Serial.println("Ethernet connected");
}


bool httpRequest(const String& method,
                 const String& request,
                 String&       response)
{
  Serial.print(F("Connecting to "));
  Serial.print(host);
  Serial.print(":");
  Serial.print(port);
  Serial.print("... ");
  if (client.connect(host, port)) {
    Serial.println("OK");
  } else {
    Serial.println("failed");
    return false;
  }

  client.print(method); client.println(F(" HTTP/1.1"));
  client.print(F("Host: ")); client.println(host);
  client.println(F("Connection: close"));
  if (request.length()) {
    client.println(F("Content-Type: application/json"));
    client.print(F("Content-Length: ")); client.println(request.length());
    client.println();
    client.print(request);
  } else {
    client.println();
  }

  //Serial.println("Waiting response");
  int timeout = millis() + 5000;
  while (client.available() == 0) {
    if (timeout - millis() < 0) {
      Serial.println(">>> Client Timeout !");
      client.stop();
      return false;
    }
  }

  //Serial.println("Reading response");
  int contentLength = -1;
  while (client.available()) {
    String line = client.readStringUntil('\n');
    line.trim();
    line.toLowerCase();
    if (line.startsWith("content-length:")) {
      contentLength = line.substring(line.lastIndexOf(':') + 1).toInt();
    } else if (line.length() == 0) {
      break;
    }
  }

  //Serial.println("Reading response body");
  response = "";
  response.reserve(contentLength + 1);
  while (response.length() < contentLength && client.connected()) {
    while (client.available()) {
      char c = client.read();
      response += c;
    }
  }
  client.stop();
  return true;
}

void myTimerEvent()
{
  mem=millis();
  String response;
  unsigned long value = millis();
  // Send value to the cloud
  // similar to Blynk.virtualWrite()
  Serial.print("Sending value: ");
  Serial.println(value);
  String putData = String("[\"") + value + "\"]";
  if (httpRequest(String("PUT /") + auth + "/update/V2", putData, response)) {
    if (response.length() != 0) {
      Serial.print("WARNING: ");
      Serial.println(response);
    }
  }
  Serial.println("Reading value");
  if (httpRequest(String("GET /") + auth + "/get/V2", "", response)) {
    Serial.print("Value from server: ");
    Serial.println(response);
  }
  //Serial.print("Retard sec:  ");
  //Serial.println(millis()/1000-mem);
  Serial.print("   Retard mills :  ");
  Serial.println(millis()-mem);
}

void setup()
{
  Serial.begin(9600);
  connectNetwork();
  timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
  timer.run();
}

From this test can you understand why it is slow with Blynk.virtualWrite?
Could you give me some indications to find the problem on Blynk library?

Result

09:11:09.126 -> Reading value
09:11:09.126 -> Connecting to blynk-cloud.com:8080... OK
09:11:09.144 -> Value from server: ["3450"]
09:11:09.144 ->    Retard mills :  360.00
09:11:09.698 -> Sending value: 4450
09:11:09.698 -> Connecting to blynk-cloud.com:8080... OK
09:11:09.878 -> Reading value
09:11:09.878 -> Connecting to blynk-cloud.com:8080... OK
09:11:10.054 -> Value from server: ["4450"]
09:11:10.054 ->    Retard mills :  384.00
09:11:10.678 -> Sending value: 5450
09:11:10.714 -> Connecting to blynk-cloud.com:8080... OK
09:11:10.861 -> Reading value
09:11:10.861 -> Connecting to blynk-cloud.com:8080... OK
09:11:11.041 -> Value from server: ["5450"]
09:11:11.041 ->    Retard mills :  368.00
09:11:11.689 -> Sending value: 6450
09:11:11.689 -> Connecting to blynk-cloud.com:8080... OK
09:11:11.862 -> Reading value
09:11:11.862 -> Connecting to blynk-cloud.com:8080... OK
09:11:12.036 -> Value from server: ["6450"]
09:11:12.036 ->    Retard mills :  367.00
09:11:12.676 -> Sending value: 7450
09:11:12.709 -> Connecting to blynk-cloud.com:8080... OK
09:11:12.884 -> Reading value
09:11:12.884 -> Connecting to blynk-cloud.com:8080... OK
09:11:13.023 -> Value from server: ["7450"]
09:11:13.057 ->    Retard mills :  356.00
09:11:13.686 -> Sending value: 8450
09:11:13.686 -> Connecting to blynk-cloud.com:8080... OK
09:11:13.856 -> Reading value
09:11:13.888 -> Connecting to blynk-cloud.com:8080... OK
09:11:14.063 -> Value from server: ["8450"]
09:11:14.063 ->    Retard mills :  375.00
09:11:14.695 -> Sending value: 9450
09:11:14.695 -> Connecting to blynk-cloud.com:8080... OK
09:11:14.864 -> Reading value
09:11:14.864 -> Connecting to blynk-cloud.com:8080... OK
09:11:15.041 -> Value from server: ["9450"]
09:11:15.041 ->    Retard mills :  365.00
09:11:15.683 -> Sending value: 10450

Sounds about right as you’re opening and closing the TCP socket at every request.

1 Like

Indeed if I remove the Reading Value the delay is 160 millis

09:20:01.998 -> Sending value: 2450
09:20:01.998 -> Connecting to blynk-cloud.com:8080... OK
09:20:03.203 ->    Retard mills :  1199.00
09:20:03.203 -> Sending value: 3651
09:20:03.203 -> Connecting to blynk-cloud.com:8080... OK
09:20:03.379 ->    Retard mills :  176.00
09:20:03.984 -> Sending value: 4450
09:20:04.022 -> Connecting to blynk-cloud.com:8080... OK
09:20:04.163 ->    Retard mills :  182.00
09:20:05.007 -> Sending value: 5450
09:20:05.007 -> Connecting to blynk-cloud.com:8080... OK
09:20:05.155 ->    Retard mills :  163.00

Sorry I had found an error, now I have corrected it the delay is 160 millis.

Thanks again because I discovered a new thing!