Reading values from an electric power analyzer (rs485-modbus)

Hi guys,

I am pretty new to the arduino, and this is my first post… please be kind :slight_smile:

Senario:

Arduino uno r3.
Small rs485 board (http://img.dxcdn.com/productimages/sku_163849_3.jpg)
Ducati Smart 96 Piu

With the code below I was able to send a correct packet request, I can tell because the power enalyzer displays the “Send” icon which it only does if it has been polled correct so I presume that is fine, however, I can’t print the response from the analyzer.
I am still trying to figure it out… been at it for a while now, I decided to post on the hope that someone could point something out that I missed.

Any help is muchly appreciated!

Cheers,

Jared.

#include <SoftwareSerial.h>

#define rxPin 13
#define txPin 12

SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);

byte  buf[] = { 31, 3, 0, 1, 0, 48, 23, 160 };

void setup() {

    Serial.begin(9600);

    pinMode(rxPin, INPUT);
    pinMode(txPin, OUTPUT);

    mySerial.begin(9600);
}

void loop() {

    mySerial.write(buf[0]);
    mySerial.write(buf[1]);
    mySerial.write(buf[2]);
    mySerial.write(buf[3]);
    mySerial.write(buf[4]);
    mySerial.write(buf[5]);
    mySerial.write(buf[6]);
    mySerial.write(buf[7]);

    delay(2000);

    Serial.println("Data from port:");
    while (mySerial.available()) {
        char inByte = mySerial.read();
        Serial.write("Data");
        Serial.print(inByte, HEX);
        delay(10);
    }
    Serial.println("");
    
}

A wiring diagram would be nice.

You need to manage DE in your code. Assert prior to sending, de-assert after sending and prior to reading. Do some research on RS485 to understand why you need this.

Hi David,

Thanks for getting back to me.
I actually managed to figure it out in the end.
I found all the necessary info here:ftp://ftp.ducatienergia.com/ducatisistemi/ for the benefit of others.
I'll post more later.
Thanks again for helping out!

Jared.