Blink led on master request
nex2000 opened this issue · comments
Hello
I'm not very good at programming , but i'm using this library with great results it works great, kudos to the author.
i couldn't catch the event to make a led turn on or blink every time the master sends a request. Could anyone help me? I attach the source
Regards
`#include <WiFi.h>
#include <ModbusIP_ESP8266.h>
const int relayCtrlPin = 2;
const int tempPin = A3;
const char ssid []= "--------------------";
const char password []= "--------------";
ModbusIP modbusTCPServer;
void setup() {
Serial.begin(115200);
pinMode(relayCtrlPin, OUTPUT);
digitalWrite(relayCtrlPin, LOW);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
modbusTCPServer.slave(502);
modbusTCPServer.addCoil(0x00);
modbusTCPServer.addHreg(0x00);
}
void loop() {
modbusTCPServer.task();
digitalWrite(relayCtrlPin, modbusTCPServer.Coil(0X00));
modbusTCPServer.Hreg(0X00, analogRead(tempPin));
delay(10);
}
`