Fjoao
Hello, I have tried and managed to successfully implement TLS encapsulation over Modbus data on the ESP32 (unfortunately, only as a client). What I've achieved so far includes:
  • Automatically loading certificates
  • Establishing a connection with a server
  • Implementing three different types of connections (ServerSideOnlyTLS, IncludeClientSideTLS, InsecureTLS)
  • Communicating securely
However, I have faced some challenges that I resolved (though I'm not sure if it was in the best way), and there are still others that I need some solutions or ideas for.
  • I had to add FreeRTOS to the project to separate the connection settings from the PLC program settings into different cores; otherwise, the TLS handshake, which lasts about 700ms, would significantly delay the PLC program.
  • For some reason, there seems to be a delay in the PLC program routine cycle, even when placed on a separate core.
    The second problem is what I still haven't been able to solve. From my investigations, the routine cycle is 20ms. For testing, I set an LED to blink every 250ms. For some unknown reason, every ninth blink takes longer. I haven't calculated this exact time, but even if I increase the blinking interval, it always occurs on the ninth time and seems to last the same duration.
Initially, I thought it might be related to the cycle I set in the TLS connection task, but after trying different values, the same issue occurs, always on the ninth time. If anyone has any tips, I would appreciate it!
 
Note: There are two tasks, one deals with the PLC program and the other with WiFi and TLS; the connection task is on the main core while the PLC task is on the second core.
 
I had to make some modifications to a few files: Baremetal.ino, ModbusSlave.h, ModbusSlave.cpp, and ArduinoUploadDialog.python.
 
Below are some images:

[203128%2F8768598%2Fmceclip0]
 
[203128%2F8768613%2Fmceclip0]
Reply 0 0
thiagoralves
Wow!!! I’m impressed! This is pretty awesome. The only downside is that the other end must implement the same TLS encapsulation otherwise it won’t work. And Modbus over TLS is not a very common thing. Have you thought about improving the MQTT blocks instead and adding secure MQTT to OpenPLC?
Reply 0 0
Reply