Closed oussama415 closed 4 years ago
Sorry but I can't help you too much...
look at the frame you send using the original program (WRITE):
and compare with this: https://github.com/reaper7/SDM_Energy_Meter/blob/master/SDM.cpp#L82
first byte is a node id and looks good == 0x01,
third and fourth byte looks good too, because they specify the register number we want to read (0x00, 0x0e),
fifth and sixth byte looks good too, your program and this library sends 0x00 and 0x02
but note the second byte ! ! ! My lib send 0x04 value at this position (read from 3X input registers): https://github.com/reaper7/SDM_Energy_Meter/blob/master/SDM.h#L76
but Your program reads values from another register (holding registers), and send 0x03 value as second byte...
so...try to change defined SDM_B_02 value from 0x04 to 0x03 at: https://github.com/reaper7/SDM_Energy_Meter/blob/master/SDM.h#L76
i think i have a problem with configuration how can i modify configuration like this
in SDM_Config_User.h uncomment and / or modify the appropriate values in the right places depending on whether you use hardware or software serial
#define SDM_UART_BAUD 9600
#if defined ( USE_HARDWARESERIAL )
#define SDM_UART_CONFIG SERIAL_8E1 //if hardware serial (parity EVEN)
#else
#define SDM_UART_CONFIG SWSERIAL_8E1 //if software serial (parity EVEN)
#endif
closed due to inactivity
hey @oussama415 ,
I have the same problem as you, did you find a solution?
I've done that already. You can check out: Its not based on that library and only reads the MeterData https://github.com/CSchoch/OR_WE_Energy_Meter
Hello, please I would like to adapt the SDM energy-meter library for my OR-WE-517 meter, I downloaded it, I modified the SDM.h file by modifying the addresses which correspond to the quantities that I want to measure this is SDM.h :
if !defined ( DERE_PIN )
define DERE_PIN NOT_A_PIN //default digital pin for control MAX485 DE/RE lines (connect DE & /RE together to this pin)
endif
if defined ( USE_HARDWARESERIAL )
if !defined ( SDM_UART_CONFIG )
endif
if defined ( ESP8266 ) && !defined ( SWAPHWSERIAL )
endif
if defined ( ESP32 )
endif
else
if defined ( ESP8266 ) || defined ( ESP32 )
endif
// #if !defined ( SDM_RX_PIN ) || !defined ( SDM_TX_PIN ) // #error "SDM_RX_PIN and SDM_TX_PIN must be defined in SDM_Config_User.h for Software Serial option)" // #endif
if !defined ( SDM_RX_PIN )
endif
if !defined ( SDM_TX_PIN )
endif
endif
if !defined ( MAX_MILLIS_TO_WAIT )
define MAX_MILLIS_TO_WAIT 500 //default max time to wait for response from SDM !!!!
endif
//------------------------------------------------------------------------------
define FRAMESIZE 9 //size of out/in array !!!!!!!!!
define SDM_REPLY_BYTE_COUNT 0x08 //:: 0x04 //number of bytes with data !!!!!!
define SDM_B_01 0x01 //BYTE 1 -> slave address (default value 1 read from node 1) !!!!!!!
define SDM_B_02 0x03 //::: //BYTE 2 -> function code (default value 0x04 read from 3X input registers) !!!!!! ::::::::
//ORNO registers
define ORNO_L1_VOLTAGE 0x000E //V /////////////
define ORNO_L2_VOLTAGE 0x0010 //V /////////////
define ORNO_L3_VOLTAGE 0x0012 //V /////////////
define ORNO_L1_CURRENT 0x0016 //A /////////////
define ORNO_L2_CURRENT 0x0018 //A /////////////
define ORNO_L3_CURRENT 0x001A //A /////////////
define ORNO_FREQUENCY 0x0014 //HZ /////////////
define SDM_B_05 0x00 //BYTE 5 !!!!!!
define SDM_B_06 0x02 //BYTE 6 !!!!!!!!!
//------------------------------------------------------------------------------
define SDM_ERR_NO_ERROR 0 //no error
define SDM_ERR_CRC_ERROR 1 //crc error
define SDM_ERR_WRONG_BYTES 2 //bytes b0,b1 or b2 wrong
define SDM_ERR_NOT_ENOUGHT_BYTES 3 //not enough bytes from sdm
define SDM_ERR_TIMEOUT 4 //timeout
//------------------------------------------------------------------------------ class SDM { public:
if defined ( USE_HARDWARESERIAL ) //hardware serial
if defined ( ESP8266 ) // on esp8266
elif defined ( ESP32 ) // on esp32
else // on avr
endif
else //software serial
if defined ( ESP8266 ) || defined ( ESP32 ) // on esp8266/esp32
else // on avr
endif
endif
private:
if defined ( USE_HARDWARESERIAL )
else
endif
if defined ( USE_HARDWARESERIAL )
if defined ( ESP8266 )
elif defined ( ESP32 )
endif
else
if defined ( ESP8266 ) || defined ( ESP32 )
endif
endif
};
endif //SDM_h`
and this is read data code :
`
include "SDM.h"
define ID_note 1
define de_pin 3
if defined ( USE_HARDWARESERIAL )
SDM sdm(Serial, 9600, de_pin);
else
include
SoftwareSerial swSerSDM(SDM_RX_PIN, SDM_TX_PIN); //10-rx, 11-tx
SDM sdm(swSerSDM, 9600, de_pin);
endif
void setup() { Serial.begin(9600);
sdm.begin();
}
void loop() {
Serial.println("..............................");
Serial.print("Voltage: "); Serial.print(sdm.readVal(ORNO_L3_VOLTAGE ), ID_note);
Serial.println("V");
delay(50);
Serial.print("Current: "); Serial.print(sdm.readVal(ORNO_L3_CURRENT ), ID_note);
Serial.println("A");
delay(50);
Serial.print("Power: "); Serial.print(sdm.readVal(ORNO_FREQUENCY ), ID_note);
Serial.println("W"); delay(50);
Serial.print(sdm.getErrCode());
delay(1000);
}`
this is an example of monitoring for my energy-meter, baudrait is 9600, Even, 8, 1
i get always nan value on serial monitor
Voltage: nanV Current: nanA Power: nanW 4..............................
Can you help me please !