Hi guys,
I'm currently working on a project involving reading data from a Schneider Acti 9 Power Meter and sending the data through Arduino to the internet. I'm having a problem with reading data from the power meter to the Arduino. The main library I'm using is the Simple Modbus Master library. The code I have right now is as the following. The output of this code, for some reason, is 769.
#include <SimpleModbusMaster.h>
#include <SoftwareSerial.h>
//////////////////// Port information ///////////////////
#define baud 9600
#define timeout 1000
#define polling 200 // the scan rate
#define retry_count 10
// used to toggle the receive/transmit pin on the driver
#define TxEnablePin 2
#define LED 13
#define RX 8
#define TX 7
// The total amount of available memory on the master to store data
#define TOTAL_NO_OF_REGISTERS 1
// This is the easiest way to create new packets
// Add as many as you want. TOTAL_NO_OF_PACKETS
// is automatically updated.
enum
{
PACKET1,
//PACKET2,
TOTAL_NO_OF_PACKETS // leave this last entry
};
SoftwareSerial Modbus(RX,TX);
// Create an array of Packets to be configured
Packet packets[TOTAL_NO_OF_PACKETS];
// Masters register array
unsigned int regs[TOTAL_NO_OF_REGISTERS];
void setup()
{
// Initialize each packet
modbus_construct(&packets[PACKET1], 1, READ_HOLDING_REGISTERS, 1845, 2, 0);
//modbus_construct(&packets[PACKET2], 1, PRESET_MULTIPLE_REGISTERS, 1, 1, 0);
// Initialize the Modbus Finite State Machine
modbus_configure(&Serial, baud, SERIAL_8N1, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS, regs);
pinMode(LED, OUTPUT);
}
void loop()
{
modbus_update();
long temp = (long)regs[0]<<16|regs[1]; //?
Serial.println(readRegs[0]); //?
}
I'm still very new to Modbus. I've haven't fully understood it. Please help