IOT2000 Siemens Slow

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!

I did a test to see the sending times with Blynk.virtualWrite, with ESP8266

17:41:03.511 -> Connected to WiFi at 192.168.0.52
17:41:04.720 -> Initializing SD card...initialization done.
17:41:05.886 ->    Retard mills :  66.00
17:41:07.015 ->    Retard mills :  65.00
17:41:08.497 ->    Retard mills :  67.00
17:41:09.094 ->    Retard mills :  65.00
17:41:09.962 ->    Retard mills :  66.00
17:41:13.115 ->    Retard mills :  67.00
17:41:13.718 ->    Retard mills :  65.00
17:41:14.911 ->    Retard mills :  67.00
17:41:15.526 ->    Retard mills :  66.00
17:41:18.658 ->    Retard mills :  67.00
17:41:19.282 ->    Retard mills :  66.00
17:41:20.502 ->    Retard mills :  67.00
17:41:23.633 ->    Retard mills :  67.00
17:41:24.254 ->    Retard mills :  66.00
17:41:24.846 ->    Retard mills :  65.00
17:41:27.987 ->    Retard mills :  67.00

Times are clearly shorter … always in mills
I sang victory too early

Sorry I forgot to write the most important thing, the sopa test was done with an ESP8266, it has been connected for over a year and it works very well … I guess I will go back to my old ESP and abandon the Siemens

I guess it depends what you want to use it for. If you’re using a home automation system then maybe think about your overall architecture.
I prefer an MQTT based system for HA, as it gives lots of control and great integration with other products. I then use Node-Red as an MQTT/Blynk bridge, as well as a bridge to other services such as Amazon Alexa, Ikea Tradfri and Philips Hue etc.

I tend to go for a very dispersed system, with lots of devices runni9ng MQTT code and all interacting with each other via Node-Red and all controllable via Blynk through the Node-Red gateway.
It also means that you don’t need to use the freaded Blynk Bridge to get multiple devices to talk to each other, which is always a bonus.

Pete.

Thanks Pete is very interesting what you wrote to me, I have to study a little everything you say …
A home energy control system with SDM120, sensors, relays etc. is already in operation. it works very well and thanks to your work with Blynk, it was not very complex to do it.

Now I would like to implement the system with the Bridge function, with various devices connected to the Eternet network.
I’m looking for an alternative alternative to ESP because I would like to connect everything to the Eternet network, that’s why I’m trying with Il Simens.
The deeper reason is that I know the Di Arduino programming language, and out of laziness, perhaps, I would not want to study other forms of language.

Node-Red is a graphical system, where you drag ‘nodes’ around and join them together with bits of spaghetti. You can write functions to do specific things, but the language used to do that is so similar to the C++ language that it is very easy to learn - but most things can be done without complex functions.

Here’s an intro to the way that I use Blynk…

Pete.

Thanks I will read it with great interest.