Page 1 of 1

Omnik protocol

Posted: Tue Nov 22, 2016 8:58 pm
by ginorosi
I substituted a PVI 3.0 with 3.0 Omnik, on line research for Omnik logger result only WiFi loggin that intercepting the data flow to omnik portal:
https://github.com/Woutrrr/Omnik-Data-Logger
https://github.com/t3kpunk/Omniksol-PV-Logger
etc

but I wanted through RS485 / 422,
I would like to create a python script or php to read data from the serial.
I sniffed the transmissions between a solarlog 1000 and via RS422 Inverter with one USB485 on Rx+/Tx+ and one on RX-/TX-
String data from SL to inverter is :
"3a 3a 01 00 00 01 11 02 00 00 89"

the response string from inverter is
"3a 3a 00 01 01 00 11 82 20 00 e0 0e dc 0e d4 00 0a 00 0d 00 26 09 54 13 89 03 76 00 00 00 20 00 00 00 00 00 01 00 00 00 00 05 a5" is :
3a3a00010100118220 Header
00e0 Temp
0edc VP1
0ed4 VP2
000a IP1
000d IP2
0026 IAC
0954 VAC
1389 FRQ
0376 PAC
00000020 TOTAL ENERGY
00000000 HOURS TOTAL ????
0001 MODE ????
0000 ERROR ????
0000 ERROR ????
05a5 CHKSUM

I acquire a USB-RS422 on aliexpress , wait delivery ; I try to write a script to pass data to 123solar, if someone wants to help?

continue..... and sorry for english

Re: Omnik protocol

Posted: Mon Mar 27, 2017 9:31 pm
by ginorosi
Here at last , after many times , this script in Python, read true this adapter USB-RS422 https://it.aliexpress.com/item/YN4852-U ... a4e086a9dc the Omnik TL2 inverter ,
script p1.py

Code: Select all

import binascii
import serial
import struct
import time

a = 0
b = 0
d = 0

ser = serial.Serial()

ser.port="/dev/ttyUSB0"
ser.baudrate=9600
ser.parity=serial.PARITY_NONE
ser.stopbits=serial.STOPBITS_ONE
ser.bytesize=serial.EIGHTBITS
ser.timeout = 1
ser.open()
ser.flushInput() #flush input buffer, discarding all its contents
ser.flushOutput()#flush output buffer, aborting current output

ser.write(serial.to_bytes([0x3A,0x3A,0x01,0x00,0x00,0x00,0x10,0x04,0x00,0x00,0x89]))
time.sleep(.100)
ser.write(serial.to_bytes([0x3A,0x3A,0x01,0x00,0x00,0x00,0x10,0x04,0x00,0x00,0x89]))
time.sleep(.100)
ser.write(serial.to_bytes([0x3A,0x3A,0x01,0x00,0x00,0x00,0x10,0x04,0x00,0x00,0x89]))
time.sleep(.100)
ser.write(serial.to_bytes([0x3A,0x3A,0x01,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x85]))
d = ser.readline(27)
d = binascii.hexlify(d)
time.sleep(.100)

ser.write(serial.to_bytes([0x3a,0x3a,0x01,0x00,0x00,0x00,0x10,0x01,0x11,0x49,0x54,0x42,0x4e,0x33,0x30,0x32,0x30,0x31,0x36,0x37,0x56,0x33,0x30,0x32,0x37,0x10,0x04,0x59]))
d = ser.readline(12)
d = binascii.hexlify(d)

ser.write(serial.to_bytes([0x3a,0x3a,0x01,0x00,0x00,0x10,0x11,0x10,0x00,0x00,0xa6])) # richiesta dati trifase
#ser.write(serial.to_bytes([0x3a,0x3a,0x01,0x00,0x00,0x10,0x11,0x02,0x00,0x00,0x98])) # richiesta dati monofase
d = ser.read(112)
d = binascii.hexlify(d)

a = d[19:22]
TEMP = int(a,16)/10

a = d[23:26]
b = d[27:30]
VCC = (int(a,16)+int(b,16))/20

a = d[35:38]
b = d[39:42]
ICC = (int(a,16)+int(b,16))/10

a = d[47:50]
ICA = int(a,16)/10

a = d[59:62]
VCA = int(a,16)/10

a = d[70:74]
FRQ = int(a,16)/100

a = d[74:78]
PCA = int(a,16)

a = d[94:98]
KWHG = int(a,16)/100


if FRQ > 0:
   a = (str(TEMP) + " " + str(VCC) + " " + str(ICC) + " " + str(ICA) + " " + str(VCA) + " " + str(FRQ) + " " + str(PCA) + " " + str(KWHG) + " OK")
   print (a)
   RET = 'OK'
and the script omnik.php for protocol

Code: Select all

<?php

// Omnik.php is a program for reading the parameters out via RS422 of Omnik inverters.
// by Gino Rosi

$SDTE = date("Ymd H:i:s");
$d = array();
$FRQ = 0;

$a = exec("python /srv/http/123solar/scripts/protocols/p1.py");

$d = preg_split('/[[:space:]]+/', $a);

$I1V = $d[1];
$I1A = $d[2];
$I1P = $I1V * $I1A;
$I2V = 0;
$I2A = 0;
$I2P = 0;
$FRQ = $d[5];
$G1V = $d[4];
$G1A = $d[3];
$G1P = $d[6];
$EFF = ($G1P/$I1P)*100;
$INVT = $d[0];
$BOOT = 0;
$KWHT = $d[7];

if ($FRQ > 0) {
      $RET = 'OK';
}

?>
I'm sorry because some installers profit from the work of Jean Mark, selling logger, and other forums peddle your work for them

Re: Omnik protocol

Posted: Tue Mar 28, 2017 6:56 am
by jeanmarc
Hi Gino,
Thanks for the work. Is there any _startup.php and _check.php scripts ?
Is the pooling fast ?

Could you tell me who are the installers that sell 123solar ?
I have to remind them that it's illegal :evil:

Re: Omnik protocol

Posted: Tue Mar 28, 2017 10:06 am
by ginorosi
There are no portals that sell, but in other forums exist installers that mount your system, they do it for free I have doubts.
The script works on Omnik TL2 with RS485 , That in reality is a RS422 4 wire.
Location and list code of error and mode inverter are unknown , the reading is less than a second on Orange PI One, a problem that the total kwh have a decimal and the average is 1200w of the resolution, the total day have 2 decimal and minimum resolution is 120w , the graph as a hacksaw

check
<?php
if(!defined('checkaccess')){die('Direct access not permitted');}
$ILEAK = 0;
$RISO = 0;
$PPEAK = 0;
$PPEAKOTD = 0;
$RET = 'NOK'; // No output
// Info file
// unset no info $CMD_INFO = "";
// Alarm
// unset no alarm $CMD_ALARM = "";
?>
startup
<?php
if(!defined('checkaccess')){die('Direct access not permitted');}
$CMD_INFO = "";
?>

Re: Omnik protocol

Posted: Mon Nov 06, 2017 1:09 pm
by ginorosi
I rewritten the script all in PHP :

Code: Select all

<?php

// Omnik.php is a program for reading the parameters out via RS422 of Omnik inverters.
// by Gino Rosi

$SDTE = date("Ymd H:i:s");
$data = array();
$FRQ = 0;

include_once('PhpSerial.php');

$serial = new PhpSerial;
$serial->deviceSet("/dev/ttyUSB0");
$serial->confBaudRate(9600);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl("none");

$serial->deviceOpen();

$str = "\x3a\x3a\x01\x00\x00\x00\x10\x04\x00\x00\x89";
$serial->sendMessage($str);
usleep(100000);

$serial->sendMessage($str);
usleep(100000);

$serial->sendMessage($str);
usleep(100000);

$str = "\x3a\x3a\x01\x00\x00\x00\x10\x00\x00\x00\x85";
$serial->sendMessage($str);
$read = $serial->readPort();

$str = "\x3a\x3a\x01\x00\x00\x00\x10\x01\x11\x49\x54\x42\x4e\x33\x30\x32\x30\x31\x36\x37\x56\x33\x30\x32\x37\x10\x04\x59";
$serial->sendMessage($str);
$read = $serial->readPort();

$str = "\x3a\x3a\x01\x00\x00\x10\x11\x10\x00\x00\xa6";
$serial->sendMessage($str);
$read = $serial->readPort();

$data = bin2hex($read);

$INVT= hexdec(substr($data, 18, 4))/10;

$I1V= (hexdec(substr($data, 22, 4))+hexdec(substr($data, 26, 4)))/20;
if ($I1V < 100) {
      $I1V = 360;
}

$I1A= (hexdec(substr($data, 34, 4))+hexdec(substr($data, 38, 4)))/10;

$I1P = $I1V * $I1A;

$G1A= hexdec(substr($data, 46, 4))/10;

$G1V= hexdec(substr($data, 58, 4))/10;

$FRQ= hexdec(substr($data, 70, 4))/100;

$G1P= hexdec(substr($data, 74, 4));

$KWHT= hexdec(substr($data, 93, 5))/100;

$BOOT = 0;

if ($FRQ > 0) {
      $RET = 'OK';
      print $FRQ;
}

?>
If launch from terminal omnik.php work's good , if launch 123solar from terminal and press button START green ok work's and live data is OK ; but booting normally, not START 123solar/admin button is STOP red and not change button START green only STOP , what is the problem , the libraries all long PhpSerial.php?

Re: Omnik protocol

Posted: Mon Nov 06, 2017 7:37 pm
by jeanmarc
:idea: Enable debug and reboot to see what it say

Re: Omnik protocol

Posted: Fri Nov 10, 2017 2:46 pm
by ginorosi
Ok , i try tomorrow

Re: Omnik protocol

Posted: Sat Nov 11, 2017 1:05 pm
by ginorosi
Resolved! :D the error this
11/11/2017 12:20:11 Stopping 123Solar

11/11/2017 12:20:14 Starting 123Solar

PHP Fatal error: No stty availible, unable to run. in /srv/http/123solar/scripts/protocols/PhpSerial.php on line 55
11/11/2017 12:28:26 Starting 123Solar
search and modify the PhpSerial.php https://stackoverflow.com/questions/233 ... it-working

Now is very fast , ans less resource is minimal respect to python.

Thank's