Chat freely about anything...

User avatar
By Adamos19
#91100 Hello everyone!

I have ESP-01 board connected as STA MODE (station) to the router WIFI (access point).
I found interesting library in the internet (settimino.h) allow us to connection ESP and PLC.
I have S7-1200 connected to this router via ethernet cable with accessible option PUT-GET communication enabled on the PLC side.
When the ESP try to call DB read function, then ESP reset. I don't know why. Had somebody the same problems?

I presented all code below and some screens from the ESP debugger. What is the problem?!

Code: Select all/*
  ESP8266 Blink by Simon Peter
  Blink the blue LED on the ESP-01 module
  This example code is in the public domain

  The blue LED on the ESP-01 module is connected to GPIO1
  (which is also the TXD pin; so we cannot use Serial.print() at the same time)

  Note that this sketch uses LED_BUILTIN to find the pin with the internal LED

// Wifi  -> #define S7WIFI
// Cable -> #define S7WIRED

#define S7WIFI

#include <ESP8266WiFi.h>
#include "Settimino.h"

// byte mac[] = { 0xE0, 0xDC, 0xA0, 0xE3, 0xF3, 0x3C };

char* ssid     = "SteviaAutomation_2.4G";
char* password = "Stevia\"Automation\"!";

IPAddress ip(192,168,1,99); // Local Address
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);
IPAddress PLC(192,168,1,199);   // PLC Address

byte Buffer[512];

S7Client * Client = new S7Client();

unsigned long Elapsed; // To calc the execution time

void setup()
     while (!Serial) {
      ; // wait for serial port to connect. Needed for Leonardo only
    // Start the WiFi Library
    WiFi.config(ip, gateway, subnet);
    WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED)
    Serial.println("WiFi connected");

bool Connect()
    int Result=Client->ConnectTo(PLC,
                                  0,  // Rack (see the doc.)
                                  0); // Slot (see the doc.)
    Serial.print("Connecting to ");Serial.println(PLC);
    if (Result==0)
      Serial.print("Connected ! PDU Length = ");
      Serial.println("Connection error");
    return Result==0;
void CheckError(int ErrNo)
  Serial.print("Error No. 0x");
  Serial.println(ErrNo, HEX);
  // Checks if it's a Server Error => we need to disconnect
  if (ErrNo & 0x00FF)
    Serial.println("SERVER ERROR, disconnecting.");
byte ReadDB(int StartAddress)     // get specific bytes from SIMATIC DB block
  int Result;
  byte Receive;
  // Connecting...
  while (!Client->Connected)
    if (!Connect())

  // call read area from SIMATIC
  Result=Client->ReadArea(S7AreaDB,     // DB identifier
                         2,            // DB Number = 53
                         StartAddress, // Start Address
                         1,            // Number of bytes to read
                         &Receive);    // Pointer to Destination Area
  // data overwriting (for simulation purposes)
  //Result = 0;
  //Receive = 0x00;
  if (Result==0)
    return Receive;

void loop()
  Serial.print("Data from the PLC: ");
  Serial.println(ReadDB(2));   // Read one byte from the 2.0 start address
ESP decoded log file