I am working with a Fuji PRX3 Temperature Controller and attempting to get it to send the process value of the temperature to an arduino uno. I am not very good with arduino and am just starting with it so I have been using AI to guide me along in this process. I keep getting Modbus error 226 whenever I try to read the data displayed on the temperature controller. Attached are the wiring diagrams and arduino code.
`#include <ModbusMaster.h>
#include <SoftwareSerial.h>
// SoftwareSerial pins (MAX485)
SoftwareSerial rs485Serial(10, 11); // RX, TX
#define MAX485_DE_RE 2 // Connect both RE and DE of MAX485 here
ModbusMaster node;
void preTransmission() {
digitalWrite(MAX485_DE_RE, HIGH); // Enable transmit mode
delayMicroseconds(100); // Allow time to switch
}
void postTransmission() {
delayMicroseconds(100); // Wait before switching back
digitalWrite(MAX485_DE_RE, LOW); // Enable receive mode
}
void setup() {
pinMode(MAX485_DE_RE, OUTPUT);
digitalWrite(MAX485_DE_RE, LOW); // Start in receive mode
Serial.begin(9600); // For Serial Monitor
rs485Serial.begin(9600); // 9600 baud for RS-485 Modbus
// Slave ID = 1 (Addr on PXR3 must be 1)
node.begin(1, rs485Serial);
node.preTransmission(preTransmission);
node.postTransmission(postTransmission);
Serial.println("Reading from Fuji PXR3 via RS-485...");
}
void loop() {
// Read 1 holding register from address 0x1000 (PV: temperature)
uint8_t result = node.readHoldingRegisters(0x1000, 1);
if (result == node.ku8MBSuccess) {
uint16_t raw = node.getResponseBuffer(0);
float temperature = raw / 10.0; // Fuji uses 0.1°C resolution
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
}
else if (result == node.ku8MBResponseTimedOut) {
Serial.println(" Timeout (Modbus error 226): No response from PXR3.");
}
else {
Serial.print(" Modbus error code: ");
Serial.println(result);
}
delay(1000); // 1-second loop
}
`