supremesports
Hi,

I'm running into a new problem. I decided to test the ESP8266 as a generic TCP device. I will have some devices for which the arduino Uno/Nano with ethernet shield won't be the best choice. The ESP8266 being WIFI makes it the best device for few of my locations.

I downloaded a sketch with the library ModbusIP_ESP8266.h and trying to get the registers to read/write. I've been able to write a coil with ease, then I tried to add a Hreg and an Ireg, This fails in OpenPLC and gives the following error repetitively:
Connected to MB device TestESP8266
Modbus Read Holding Registers failed on MB device TestESP8266: Connection reset by peer
Modbus Write Holding Registers failed on MB device TestESP8266: Bad file descriptor
Device TestESP8266 is disconnected. Attempting to reconnect...

While the coil still works (flash every second as programmed in the ladder), I'm not getting the word registers to do anything. I've been working on this all day and I'm not able to make it work. I tried to force values into the registers directly into the ESP8266 and they show up in Radzio, but OpenPLC doesn't seem to get them.

Please advise 🙂
Quote 0 0
thiagoralves
Apparently there is a problem with the ESP8266 firmware as is being discussed here:  https://openplc.discussion.community/post/modbus-and-esp8266-problems-9902649?pid=1306065720

However, if you’re getting errors every time, it is possible that you have added an invalid configuration on the slave device config. Did you select ESP8266 from the list or are you creating your own from the Generic Modbus TCP?
Quote 0 0
supremesports
I'm creating my own from the Generic Modbus TCP.
Quote 0 0
supremesports
I tried with a different version of ModbusIP_ESP8266.h (https://github.com/emelianov/modbus-esp8266) and now it works for the registers, but not for the coils and switches... It also fixed the "keep alive" function.
So, I'm still trying to find a solution to get all four functions (coils, switches, read and write registers) to work...
Quote 0 0
supremesports
Soooo, it works 😃 

Two things, it looks like I set too many registers, I tried to setup my default number of coils/switches/registers and it appears to be too much. I brought it back to only 1 coil, one read register and 1 write register. For now, it works.
Also, in the IDE sketch, to get data to communicate properly, you need to remove the "delay(100);"
Quote 0 0
thiagoralves
Why aren’t you using the firmware from the OpenPLC website?
Quote 0 0
supremesports
Because it limits the number of different registers being generated... Just to start, I need 3 Holding registers and 5 input registers OpenPLC - ESP8266 limits.jpg 
Quote 0 0
thiagoralves
I'm talking about the firmware on the device. This one:  http://www.openplcproject.com/getting-started-esp8266

The number of registers you define on the slave settings must match the number of registers defined in the firmware, otherwise you will get errors. That's why you can't change these numbers when you select the ESP8266 from the list, because they were already set to match what is in the firmware. If you want to use more registers, you will have to modify the firmware to have more registers, and then you can use Generic Modbus with the number of registers you defined in the firmware
Quote 1 0
supremesports
Ah OK, I suppose this firmware is working very good? I'll test it tonight or tomorrow to see 🙂 My tonight's project is to switch everything to my Raspberry Pi in order to separate the OpenPLC network from my IPTV/internet network as it seems to overload the network and eventually I'm losing TV or WiFi...
Quote 0 0
supremesports
RPi install FAILED 🙁
Ok, so after an evening installing my Rasbian OS and waiting over an hour to install OpenPLC, the install finally failed saying therE's not enough space on my device. I'll go purchase a larger SD card tomorrow, simply wondering how much space OpenPLC needs on the RPi? In order to get an appropriate SD card. Thanks 🙂
Quote 0 0
thiagoralves
OpenPLC needs at least 1GB of free storage to be installed. After installation it consumes only about 50MB or so...
Quote 0 0
supremesports
Ok, I fixed the problem, it was because I installed the full version of Raspbian with desktop. Since I don't want or need it, I reinstalled the terminal version (Raspbian Lite). It works now...
Quote 0 0