`/**
- Modbus slave example 3:
- The purpose of this example is to link a data array
- from the Arduino to an external device through RS485.
- Recommended Modbus Master: QModbus
- http://qmodbus.sourceforge.net/
*/
#include <ModbusRtu.h>
// assign the Arduino pin that must be connected to RE-DE RS485 transceiver
#define TXEN 4
const byte SwitchPin = 4;
// data array for modbus network sharing
uint16_t au16data_false[16] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0 };
uint16_t au16data_true[16] = {
1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1,1,1,1 };
/**
- Modbus object declaration
- u8id : node id = 0 for master, = 1..247 for slave
- port : serial port
- u8txenpin : 0 for RS-232 and USB-FTDI
-
or any pin number > 1 for RS-485
*/
Modbus slave(4,Serial,TXEN); // this is slave @1 and RS-485
void setup() {
pinMode(SwitchPin, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin( 9600 ); // baud-rate at 9600
slave.start();
}
void loop() {
if(digitalRead(SwitchPin)){
slave.poll(au16data_true, 16 );
digitalWrite(LED_BUILTIN,LOW);
} else
{
slave.poll(au16data_false, 16 );
digitalWrite(LED_BUILTIN,HIGH);
}
} `
i am getting this as error
fatal error: ModbusRtu.h: No such file or directory
#include <ModbusRtu.h>
^~~~~
compilation terminated.
exit status 1
Compilation error: ModbusRtu.h: No such file or directory