I am trying to communicate with this, amplifier WDT 11, using RS485 and Arduino Uno but it doesn't work.
I have gone through multiple examples but i can't get this to work.
Any help will be greatly apprieciated!!!@!@
Connection setup:
WDT11 outputs:
A -> A on RS 485
B -> B on RS 485
RS 485:
B-> as above
A-> as above
VCC -> 5V on Arduino Uno
GND -> GND on Arduino Uno
DI -> TX on Arduino Uno
DE: -> 3
RE: -> 3
RO: -> RX on Arduino Uno.
Code
#include <ModbusMaster.h>
#define MAX485_DE 3
// instantiate ModbusMaster object
ModbusMaster node;
void preTransmission()
{
digitalWrite(MAX485_DE, 1);
}
void postTransmission()
{
digitalWrite(MAX485_DE, 0);
}
void setup()
{
pinMode(MAX485_DE, OUTPUT);
// Init in receive mode
digitalWrite(MAX485_DE, 0);
// Modbus communication runs at 115200 baud
Serial.begin(115200);
// Modbus slave ID 1
node.begin(1, Serial);
// Callbacks allow us to configure the RS485 transceiver correctly
node.preTransmission(preTransmission);
node.postTransmission(postTransmission);
}
bool state = true;
void loop()
{
uint8_t result;
// Read 16 registers starting at 0x3100)
result = node.readInputRegisters(0x03, 1);
if (result == node.ku8MBSuccess)
{
Serial.print(node.getResponseBuffer(0x00));
Serial.println();
}
delay(1000);
}
you have written you want to read from Device 0, but in the code you are addressing address 1. 0 and 1 don't fit together. If your device Address ist really 0, you should use 0 as address in the code to get response from your device 0.
for me it looks like as you want to use the modbus communication on Serial and do debug messages on Serial.
This will not work.
Which example are you following? Please link to the project or to the source you are using.
ernando Tanco
vor 9 Monaten @Antony Cartwright You are using the SAME port for debugging and modbus communication!!!!! The Arduino serial terminal y receiving the modbus packet and shows that boxes messages. And... the EPSolar 4215BN is receiving the Serial.print commands…. To solve this you shoud use another serial port for transmit and receive modbus. Arduino nano has got only 1 hardware serial port, you shoud use a "software serial port", like SoftwareSerial.h
Do you understand that?
And provide more information:
Which controller are you using?
post a schematic how you have wired everything.
show a clear picture of your setup or as many as necessary clearly each wire?
If you are limited to the existing UNO, I propose you read about Soft Serial and try to connect Modbus on a soft serial connection. that should work. I hope you also find some example sketches for this library using soft serial...
by the way, nice schematic, proper images ... well done.
check the soft serial documentation - I assume 115200 ist much to fast. Bring it down to 9600 (and your device) or consider to use a Mega which provides 4 hardware serials.
I've just ordered Arduino Mega in order to get rid of any problems with multiple serials and RS 485 just to make sure the one that i am using is working properly.
Thanks a lot for your help and please visit this topic every now and then :), just in case I need some help with Arduino Mega