Free Academic Seminars And Projects Reports
Interfacing Energy Meter having MODBUS RTU protocol with Arduino Uno - Printable Version

+- Free Academic Seminars And Projects Reports (https://easyreport.in)
+-- Forum: Seminars Topics And Discussions (https://easyreport.in/forumdisplay.php?fid=30)
+--- Forum: Engineering Seminars Topics (https://easyreport.in/forumdisplay.php?fid=7)
+---- Forum: Seminar Requests (https://easyreport.in/forumdisplay.php?fid=29)
+---- Thread: Interfacing Energy Meter having MODBUS RTU protocol with Arduino Uno (/showthread.php?tid=29080)



Interfacing Energy Meter having MODBUS RTU protocol with Arduino Uno - [email protected] - 08-17-2017

#include <LiquidCrystal.h>

#include <ModbusMaster.h>

#define METERSLAVEID 11

#define LEDPIN 13

// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// Create a software interface for meter (create a ModBusMaster node)

ModbusMaster node(METERSLAVEID);

void setup() {

// Initialising communication with meter

node.begin(9600);



// Setting up led

pinMode(LEDPIN, OUTPUT);



// set up the LCD's number of columns and rows:

lcd.begin(16, 2);



// Print a message to the LCD.

lcd.print("hello, world!");

//set data output enable pin to output mode



}

void loop() {

// Reading data from meter

// 1. Request data using readHoldingRegisters() (i think we need to enable the outputs before this)

// 2. Check whether data is available using node.ku8MBSuccess flag

// 3. If valid read data from buffer using node.getResponseBuffer()

uint16_t data[ 2]; //We are using array of two 16 bit because we are reading two registers of 16 bit from meter

uint8_t flag; //8 bit flag is required for error checking because we get 8 bit status

int final; //final result

//see comment 1





flag = node.readInputRegisters(30001, 2);

lcd.setCursor(0, 1);

// print the number of seconds since reset:

switch(flag)

{

case 0x01:

lcd.print("Illegal Function");

break;

case 0x02:

lcd.print("Illegal DataAddress");

break;

case 0x03:

lcd.print("Illegal DataValue");

break;

case 0x04:

lcd.print("Slave device Failure");

break;

case 0x00:

lcd.print("Success");

break;

case 0xE0:

lcd.print("Invalud Slave");

break;

case 0xE1:

lcd.print("Invalid Function");

break;

case 0xE2:

lcd.print("Time Out");

break;

case 0xE3:

lcd.print("Invalid CRC");

break;

}

if(flag == node.ku8MBSuccess){

//glow a led

digitalWrite(LEDPIN, HIGH);

//read data

data[0] = node.getResponseBuffer(0);

data[1] = node.getResponseBuffer(1);

final = data[0];

if(data[1] == 0xFF) //sign check

{

final = ( data[0]) + 1;

final = final * (-1);

}

}

else{

//unglow a led

digitalWrite(LEDPIN, LOW);

}

delay(1000);

}


Interfacing Energy Meter having MODBUS RTU protocol with Arduino Uno - akashkulkarni0014 - 08-17-2017

Please help me to interface rishabh energy meter EM 1340 with Arduino Uno. I have tried using ModbusMaster Library and SimpleModbus Library for coding in arduino. I have build RS485 to TTL converter using MAX485 IC and circuit which is given in SimpleModbus Library . I can share the code with you . My problem is that i am always getting Timeout Error . I checked on DSO the query at the converter end is not what is accepted , I mean when arduino sends query the message in form of square wave but at converter end their is loading . Please tell me what to do?

I am ready to share all information which , you just ask anything and please help me. Thank YOU Smile

The interface definition for meter is available online. I am not allowed to post page link here sorry just google search Rishabh Interface Definition and click on page link havin EM13XX and EM23XX