ok so i have now modified the code to work with hardwareserial and i am getting a different response as attached.
#include <Arduino.h>
// Uses PJRC AltSoftSerial library which is better than the standard SoftwareSerial library (IMHO)
// Get it here: https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html
//
// All pin numbers are for an Arduino UNO.
#include <AltSoftSerial.h>
// MAX485 : RO to pin 8 & DI to pin 9 when using AltSoftSerial
#define RE 11
#define DE 12
// const byte msg1[] = {0x27, 0x0F, 0x20, 0x01,
// 0x02, 0x04, 0x02, 0x10, 0x1A, 0x1B, 0x04, 0x02, 0x04, 0x05, 0x03, 0x81, 0x06,
// 0x80, 0x2A, 0xAA };
// const byte msg1[] = {0x27, 0x0E, 0xFE, 0x01,
// 0x00, 0x02, 0x02, 0x03, 0x04, 0x02, 0x2E, 0x2F, 0x02, 0x02, 0x94, 0x95,
// 0x2A, 0xAA };
// const byte msg1[] = {0x27, 0x0E, 0xFE, 0x01,
// 0x00, 0x02, 0x02, 0x03, 0x04, 0x02, 0x2E, 0x2F, 0x02, 0x02, 0x94, 0x95,
// 0x2A};
// const byte msg1[] = {0x27, 0x0F,0x20,0x04,0x02,0x10,0x1A,0x1B,0x4,0x02,0x05,0x03,0x81,0x06,0x80,0x2A};
// const byte msg1[] = {0x27,0x0E, 0xFE,
// 0x01, 0x00, 0x02, 0x02, 0x03, 0x04, 0x02, 0x2E, 0x2F, 0x02 ,0x02, 0x94,
// 0x95, 0xA2, 0xAA};
// const byte msg1[] = {0x27,0x03, 0xe7,
// 0x02, 0x95,
// 0x4E, 0xD6};
// const byte msg1[] = {0x27, 0x2e, 0xe7, 0x00, 0x02, 0x15, 0xb4, 0xa5, 0xb3, 0xa7, 0xaa, 0xa6, 0xac, 0xa9, 0xb1, 0xa4,
// 0xad ,0xb0, 0xa3, 0xb2, 0xaf, 0xab, 0xa8, 0xb6, 0x51, 0xae, 0xb5, 0x0b, 0x13, 0x10, 0x02, 0x0f,
// 0x0d, 0x0c, 0x0e, 0x14, 0x12, 0x01, 0x13, 0x16, 0x09, 0x07, 0x0a, 0x6c, 0x08, 0x00, 0x15, 0x05,
// 0xcb, 0x6c};
// const byte msg1[] = {0x27, 0x07, 0xEF, 0x01,
// 0x03, 0x81,0x00,0x06,0x92,0xD};
const byte msg1[] = {0x27,0x0f, 0xef, 0x01,
0x02, 0x04, 0x02, 0x10, 0x1A, 0x1B, 0x04, 0x02, 0x04, 0x05, 0x03, 0x81, 0x06,
0x92, 0xA4};
// byte values[11];
AltSoftSerial swSerial;
void setup() {
Serial.begin(9600);
// set this to the required baud rate - max of 19200 baud
swSerial.begin(9600);
pinMode(RE, OUTPUT);
pinMode(DE, OUTPUT);
// put RS-485 into receive mode
digitalWrite(DE, LOW);
digitalWrite(RE, LOW);
// delay( 1000 );
}
void loop() {
uint32_t startTime;
uint8_t rxByte;
Serial.println("Sending command");
Serial.print("Response: ");
// put the MAX485 into transmit mode
digitalWrite(RE, HIGH);
digitalWrite(DE, HIGH);
// send the message
Serial.write( msg1, sizeof(msg1) );
// wait for all of the message to be sent
Serial.flush();
// put the MAX485 back into receive mode
digitalWrite(RE, LOW);
digitalWrite(DE, LOW);
startTime = millis();
// wait for up to 2 seconds for any reply and print out any received bytes
while ( millis() - startTime < 2000UL ) {
if ( Serial.available() ) {
rxByte = Serial.read();
Serial.print( rxByte, HEX );
Serial.print( " " );
}
}
Serial.println();
Serial.println();
// 5 second delay, then repeat the whole process again
// delay( 5000 );
}
it appears as though i am getting a response which does not include the start delimiter reply of 0x24.
the length and destination is correct as well as the source address