Hello, how can I convert the quad data from MODBUS to date-time?
0: 23
1: 514
2: 2310
3: 59000
there are many ways that data could be encoded.
Can you tell us what where this data comes from?
Does the data source have a page in a manual that describes how it is formatted?
Worst case, can you tell us what time you expect those values to become?
SE's electricity meter. Detail I found in the related document.
DATETIME DateTime 1/1/2000 – 12/31/2127 0xFFFFFFFFFFFFFFFF "DateTime coding format using 4 words as per IEC 870-5-4
Word 1
b0-b6: Year (0 - 127)
b7-b15: Reserved
Word 2
b0-b4: Day (1-31)
b5-b7: Weekday (1-7, 0 if not used)
b8-b11: Month (1-12)
b12-b15: Reserved
Word 3
b0-b5: Minutes (0-59)
b6: Reserved
b7: Time synchronization quality, 1 = non valid or non synchronization
b8-b12: Hour (0-23)
b13-b14: Reserved
b15: 0 = Standard time, 1 = Daylight Savings Time
Word 4
b0-b15: Millisecond (0 - 59999)
"
ok, well based on that info, I get this...
Demo Flow (use CTRL+I
to import)
[{"id":"29323ef4aa510c2a","type":"buffer-parser","z":"83556a18e3c2c577","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint16be","name":"year","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":"0x007F"},{"type":"uint16be","name":"day","offset":2,"length":1,"offsetbit":0,"scale":"1","mask":"0x000F"},{"type":"uint16be","name":"weekday","offset":2,"length":1,"offsetbit":0,"scale":">> 4","mask":"0x00F0"},{"type":"uint16be","name":"month","offset":2,"length":1,"offsetbit":0,"scale":">> 8","mask":"0x0F00"},{"type":"uint16be","name":"minutes","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":"0x001F"},{"type":"bool","name":"synchronization ","offset":4,"length":1,"offsetbit":7,"scale":"1","mask":""},{"type":"uint16be","name":"hour","offset":4,"length":1,"offsetbit":8,"scale":">> 8","mask":"0x1F00"},{"type":"uint16be","name":"millisecond","offset":6,"length":1,"offsetbit":8,"scale":">> 8","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":280,"y":940,"wires":[["d8b0fecef27998f5"]]},{"id":"e1f83894c0a794d9","type":"inject","z":"83556a18e3c2c577","name":"[23,514, 2310, 59000]","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[23,514, 2310, 59000]","payloadType":"json","x":300,"y":860,"wires":[["29323ef4aa510c2a"]]},{"id":"d8b0fecef27998f5","type":"debug","z":"83556a18e3c2c577","name":"debug 158","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":440,"y":940,"wires":[]}]
It may not be 100% correct (I might have the wrong bits or masks set) but it should give you the right direction.
PS, if you want the final result to be an actual JS Date object (or a Epoch timestamp) then you will need to use a function node and the Date
object to built it from the components in the buffer-parser result.
As a matter of interest, is that from a so called 'smart meter'? If so, how are you collecting the data?
Also SE stands for?
Can you teach me how you did it?
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.