I came post this topic to share my undergraduate thesis, I'm about to deliver the project later this year 2019, I would like to take some questions with you.
The project consists of collecting data via physical sensor (soil moisture) connected to the analog port ESP8266-12E. The same ESP8266-12E (Modbus Master) Card will send data via Modbus TCP / IP Protocol from master to client. My client will be the Raspberry pi 3 card, which in turn contains the CODESYS (Modbus Client) software installed and running internally, which will receive the data collected by ESP.
I am using Arduino IDE to program ESP, the installed libraries were:
-------------------------------------------------- --------------------------
Modbus.h
ModbusIP_ESP8266.h
-------------------------------------------------- --------------------------
I performed the Holding Registers tests according to the code below:
-------------------------------------------------- --------------------------
/ *
Modbus-Arduino Example - Test Holding Register (Modbus IP ESP8266)
Set Holding Register (offset 100) with initial value 0xABCD
You can get or set this holding register
Copyright by André Sarmento Barbosa
http://github.com/andresarmento/modbus-arduino
* /
#include <ESP8266WiFi.h>
#include <Modbus.h>
#include <ModbusIP_ESP8266.h>
// Modbus Registers Offsets (0-9999)
const int TEST_HREG = 100;
// ModbusIP object
ModbusIP mb;
void setup () {
Serial.begin (115200);
mb.config ("WirelessName", "password");
while (WiFi.status ()! = WL_CONNECTED) {
delay (500);
Serial.print (".");
}
Serial.println ("");
Serial.println ("WiFi connected");
Serial.println ("IP address:");
Serial.println (WiFi.localIP ());
mb.addHreg (TEST_HREG, 0xABCD);
}
void loop () {
// Call once inside loop () - all magic here
mb.task ();
}
-------------------------------------------------- --------------------------
So far I was successful, I performed the simple test and checked the value 0xABCD in the Modbus simulator, but when connecting with my Modbus CODESYS Client, I noticed that the connection was intermittent.
Has anyone here in the community ever had this problem, or have a similar project? Could you give me a hand?
Thank you very much in advance!
I will be available for any information you may need to resolve this case together.