Hi all, i am trying to use my arduino as a modbus master to send 1 bit of data through RTU.
When press my digital input from arduino master, modbus poll & modbus tester throw up errors and i cannot receive the data correctly. I have been trying to debug this for many days now and have been unsuccessful, i have re wired my project and checked my code but still cannot figure out these errors.
On Modbuspoll i get " checksum error" and when no inputs pressed "timeout error", i have included my wiring and code below along with pictures of the errors that i am receiving.
I also get read rs port error & or illegal response when using mbustester
I am trying to send the data through the address 0x10001 in order for my slave to read the input of 1 which is sent from the digital input on the arduino.
Hardware:
Arduino Uno
5V TTL to Rs485 Module
SH-U10 USB to RS485 Converter
Push Button
LCD
Code:
#include <ModbusMaster.h>
#include <LiquidCrystal.h>
#define MAX485_DE 11
#define MAX485_RE_NEG 10
ModbusMaster node;
LiquidCrystal lcd(8, 2, 4, 5, 6, 7);
void preTransmission()
{
digitalWrite(MAX485_RE_NEG, 1);
digitalWrite(MAX485_DE, 1);
}
void postTransmission()
{
digitalWrite(MAX485_RE_NEG, 0);
digitalWrite(MAX485_DE, 0);
}
const int button1 = 10;
const int button2 = 11;
const int button3 = 12;
const int button4 = 13;
void setup() {
lcd.begin(14, 2);
pinMode(button3, INPUT);
pinMode(MAX485_RE_NEG, OUTPUT); //declaring pinmode output for max485
pinMode(MAX485_DE, OUTPUT); //declaring pinmode output for max485
lcd.print("Welcome!");
delay(1000);
lcd.clear();
lcd.print("Project Simulation");
delay(1000);
digitalWrite(MAX485_RE_NEG, 0); //initialise
digitalWrite(MAX485_DE, 0); //initialise
Serial.begin(9600);
node.begin(1, Serial); //Slave ID as 1
node.preTransmission(preTransmission); //Callback for configuring RS-485 Transreceiver correctly
node.postTransmission(postTransmission);
}
void loop() {
int a = digitalRead(button3);
if (a == 1)
{
node.writeSingleRegister(0x10001, 1);
delay(1000);
lcd.setCursor(0, 1);
lcd.print("S1: HIGH");
}
}
I also receive an error whilst compiling although i am able to upload this to the device and other functions work ie, lcd print functioning correct when press digital input
warning: large integer implicitly truncated to unsigned type [-Woverflow]
node.writeSingleRegister(0x10001, 1);







