fhainz
September 19, 2020, 9:59am
1
Hello!
I'm trying to find a modbus tcp client library for my arduino uno wifi rev. 2 for several days. I tried a few but none really fits well.
This is an homeautomation project and i want to read/write Inputs and Outputs on my Siemens Logo 8 PLC . To do this I need a least functions 01 (read coils), 02 (read discrete input), 05 (write single coil).
Can anybody help me? Maybe with MsgModbus Lib? I started to play with arduinos 4 weeks ago. So i'm still at the beginning.
Thank you!
1 Like
Juraj
September 19, 2020, 11:26am
2
this sketch has Modbus TCP client without a library
#include <avr/wdt.h>
#include <UIPEthernet.h> // or <Ethernet.h>
#include <SD.h>
#include <TimeLib.h>
#include <StreamLib.h>
#define VERSION "1.00"
const byte FNC_H_READ_REGS = 0x03;
const byte FNC_I_READ_REGS = 0x04;
const byte FNC_WRITE_SINGLE = 0x06;
const byte FNC_ERR_FLAG = 0x80;
const int MODBUS_CONNECT_ERROR = -10;
const int MODBUS_NO_RESPONSE = -11;
const byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
const byte INPUT_PIN = 3;
const byte SD_CS_PIN = 4;
This file has been truncated. show original
fhainz
September 19, 2020, 11:36am
3
Juraj:
this sketch has Modbus TCP client without a library
IsgModbusTcpSG/IsgModbusTcpSG/IsgModbusTcpSG.ino at master · JAndrassy/IsgModbusTcpSG · GitHub
This sketch is only for functions 03, 04, 06. Am i right?
const byte FNC_H_READ_REGS = 0x03;
const byte FNC_I_READ_REGS = 0x04;
const byte FNC_WRITE_SINGLE = 0x06;
I need functions 01, 02 and 05.
You can refer to this Arduino-powered Modbus/TCP device project on Hackster
Juraj
September 19, 2020, 2:03pm
5
fhainz:
This sketch is only for functions 03, 04, 06. Am i right?
const byte FNC_H_READ_REGS = 0x03;
const byte FNC_I_READ_REGS = 0x04;
const byte FNC_WRITE_SINGLE = 0x06;
I need functions 01, 02 and 05.
there is not much difference. you can modify the two functions