ESPEasy-modbus tcp

Moderators: grovkillen, Stuntteam, TD-er

Message
Author
noignavi
New user
Posts: 1
Joined: 21 Jan 2018, 19:28

ESPEasy-modbus tcp

#1 Post by noignavi » 21 Jan 2018, 20:00

Hi all!
I just got a Wemos ESP 8266, with integrated oled display and battery. I was able to flash several images to keep confidence with it.
I installed also platformio and tried to play with it.

I am really interested to integrate modbus tcp slave into the device, because it can be used as low cost device for several sensors, and connect it to scada applications where wiring is difficult to be used.

I am new with this device and ESPEasy, so I found here (h.t.t.p://en.trialcommand.com/blog/esp8266-slave-modbus-tcpip-no-libraries/) a working code for modbus tcp slave and I tried to put it into ESPEasy.ino using platformio, and deleting some rows not useful or already present into ESPEasy.ino. I started putting all the code into the main loop, and I was successful to create a working image, but when I connect with a modbus master, I get all the modbus values, but clock on the display and I think most of the operations stop. Webserver keeps working. If I disconnect, clock on the display works fine. I think this happens because the code:

Code: Select all

while (client.connected()) {
is in the main loop, so until the master is connected, the rest of code is not executed.
If I try to execute the code only one time and replacing an "if" to the "while", I get only one data and the ESPEasy disconnects the master.

I could use the device with only modbus funtions, but I like Espeasy and I would keep all the features.

Is there any way to have the additional added code working as a daemon like the webserver?

Thank you.

TD-er
Core team member
Posts: 9906
Joined: 01 Sep 2017, 22:13
Location: the Netherlands

Re: ESPEasy-modbus tcp

#2 Post by TD-er » 22 Jan 2018, 00:52

I was already working on some Modbus implementation for the SenseAir CO2 sensors.
And then decided it would be great to have it as a basic protocol like I2C now is in ESPeasy.
So it is being worked on right now (well... in my mind for a month or 2 now).
Last months I have been really busy on fixing all those other issues for the v2.0 release.
But when that is finished, I will try to get Modbus out as soon as possible.

Just for inspiration, you can have a look at the last few commits I made in this test branch: https://github.com/TD-er/ESPEasy/commit ... e/senseair
But I think adding something like the Modbus protocol is quite some work. The protocol itself is quite a steep learning curve to start with.

But in the basics, it is actually just grabbing registers from an addressed device, so that can be done in a cycle and then start doing other tasks.

Who is online

Users browsing this forum: No registered users and 15 guests