Programma MONITOR per la lettura contatori EASTRON [GUIDA]

Discussioni relative al software di monitoraggio energetico METERN
ilmarchese
Messaggi: 22
Iscritto il: 11/06/2020, 15:02

Re: Programma MONITOR per la lettura contatori EASTRON [GUIDA]

Messaggioda ilmarchese » 06/07/2020, 12:48

Flane ha scritto:Qui sul forum per i contatori trifase c'è solo monitor.

Ma con tutta la confusione che è stata fatta sopra io non ho capito se sei riuscito a configurare monitor e se hai una lettura completa dei dati del contatore trifase da monitor.


Non ho ancora ottenuto una lettera completa del contatore trifare



ilmarchese
Messaggi: 22
Iscritto il: 11/06/2020, 15:02

Re: Programma MONITOR per la lettura contatori EASTRON [GUIDA]

Messaggioda ilmarchese » 07/07/2020, 9:14

Flane ha scritto:posta il contenuto del file monitor.conf


ecco il contenuto

Codice: Seleziona tutto

[General]
Port1Dev = /dev/ttyUSB0
Port1Speed = 9600
Port1NBit = 8
Port1Stop = 2
Port1Par = N
;Port2Dev = /dev/ttyUSB1
;Port2Speed = 9600
;Port2NBit = 8
;Port2Stop = 2
;Port2Par = N
Delay = 1               ; Delay time between reading the sensors (sec)
Retry = 3               ; Number of retry on modbus
useMQTT = no           ; Indicate if MQTT is used (valid value are yes/no)
MQTThost = localhost    ; IP Address o FQDN of MQTT broker
MQTTport = 1883         ; TCP/IP port of MQTT broker
MQTTkeepalive = 60      ; keepalive
MQTTusername =          ; username for auth. Leave black for no auth
MQTTpassword =          ; password for auth. Leave black for no auth

[Sensor1]
Name = Consumi          ; Description
Type = 3                ; Sensor type --> SDM120
Port = 1                ; Number of communication port
Address = 1             ; Sensor's modbus address
Delay = 1               ; Delay time (sec)
NumOp = 0               ; Number of correction to do (0 = no correction)
Par1 = 1                ; Number of sensor's value to correct
C1 = 0                  ; Correction value
Op1 = +                 ; Operation (+, -, *, /)
ID = 1                  ; MeterID
OutputType = 2          ; Output format (1=123solar, 2=meterN, 3=detailed)
OutFile = /dev/shm/metern1.txt         ; Full path of output file
MQTTtopic = casa/energia/consumi       ; topic where data are published

;[SensorXX]
;Name = Consumi pdc         ; Description
;Type = 2                ; Sensor type --> SDM220/SDM230
;Port = 1                ; Number of communication port
;Address = 7             ; Sensor's modbus address
;Delay = 1               ; Delay time (sec)
;NumOp = 0               ; Number of correction to do (0 = no correction)
;Par1 = 1                ; Number of sensor's value to correct
;C1 = 0                  ; Correction value
;Op1 = +                 ; Operation (+, -, *, /)
;ID = 7                  ; MeterID
;OutputType = 2          ; Output format (1=123solar, 2=meterN, 3=detailed)
;OutFile = /dev/shm/metern7.txt         ; Full path of output file
;MQTTtopic = casa/energia/pdc           ; topic where data are published

;[SensorXX]
;Name = Generic Modbus   ; Description
;Type = 20               ; Sensor type
;Port = 1                ; Number of communication port
;Address = 1             ; Sensor's modbus address
;Delay = 1               ; Delay time (sec)
;Register = 1            ; First register to read
;NumReg = 40              ; Number of register to read
;RegType = I             ; Register type (I=Input, H=Holding)
;NumOp = 0               ; Number of correction to do (0 = no correction)
;Par1 = 1                ; Number of sensor's value to correct
;C1 = 0                  ; Correction value
;Op1 = +                 ; Operation (+, -, *, /)
;ID = 1                 ; ID Meters
;OutputType = 2          ; Output format (1=123solar, 2=meterN, 3=detailed)
;OutFile = /dev/shm/metern1.txt        ; Full path of output file
;MQTTtopic = casa/energia/counter       ; topic where data are published

;
; Sensor Type
;    1 --> SDM120
;    2 --> SDM220/SDM230
;    3 --> SDM630
;    5 --> TempLogger
;   20 --> Generic modbus slave
;
;
; OutputType
;    1 --> 123solar
;    2 --> MeterN
;    3 --> Esteso
;
;
; Detail sensor list value
;
; SDM120C - SDM220 - SDM230 List Value
;    1 --> VOLTAGE                     - METERN: ID_V   - MQTTtopic: /V
;    2 --> CURRENT                     - METERN: ID_C   - MQTTtopic: /C
;    3 --> POWER                       - METERN: ID_P   - MQTTtopic: /P
;    4 --> APPARENT POWER              - METERN: ID_AP  - MQTTtopic: /AP
;    5 --> REACTIVE POWER              - METERN: ID_RP  - MQTTtopic: /RP
;    6 --> POWER FACTOR                - METERN: ID_PF  - MQTTtopic: /PF
;    7 --> PHASE ANGLE                 - METERN: ID_PA  - MQTTtopic: /PA
;    8 --> FREQUENCY                   - METERN: ID_F   - MQTTtopic: /F
;    9 --> IMPORTED ENERGY             - METERN: ID_IE  - MQTTtopic: /IE
;   10 --> EXPORTED ENERGY             - METERN: ID_EE  - MQTTtopic: /EE
;   11 --> TOTAL ACTIVE ENERGY         - METERN: ID_TE  - MQTTtopic: /TE
;   12 --> IMPORTED REACTIVE ENERGY    - METERN: ID_IRE - MQTTtopic: /IRE
;   13 --> EXPORTED REACTIVE ENERGY    - METERN: ID_ERE - MQTTtopic: /ERE
;   14 --> TOTAL REACTIVE ENERGY       - METERN: ID_TRE - MQTTtopic: /TRE
;
; SDM630 List Value
;    1 --> VOLTAGE PHASE R             - METERN: ID_VR  -  MQTTtopic: /VR
;    2 --> VOLTAGE PHASE S             - METERN: ID_VS  -  MQTTtopic: /VS
;    3 --> VOLTAGE PHASE T             - METERN: ID_VT  -  MQTTtopic: /VT
;    4 --> CURRENT PHASE R             - METERN: ID_CR  -  MQTTtopic: /CR
;    5 --> CURRENT PHASE S             - METERN: ID_CS  -  MQTTtopic: /CS
;    6 --> CURRENT PHASE T             - METERN: ID_CT  -  MQTTtopic: /CT
;    7 --> POWER PHASE R               - METERN: ID_PR  -  MQTTtopic: /PR
;    8 --> POWER PHASE S               - METERN: ID_PS  -  MQTTtopic: /PS
;    9 --> POWER PHASE T               - METERN: ID_PT  -  MQTTtopic: /PT
;   10 --> APPARENT POWER PHASE R      - METERN: ID_APR  - MQTTtopic: /APR
;   11 --> APPARENT POWER PHASE S      - METERN: ID_APS  - MQTTtopic: /APS
;   12 --> APPARENT POWER PHASE T      - METERN: ID_APT  - MQTTtopic: /APT
;   13 --> REACTIVE POWER PHASE R      - METERN: ID_RPR  - MQTTtopic: /RPR
;   14 --> REACTIVE POWER PHASE S      - METERN: ID_RPS  - MQTTtopic: /RPS
;   15 --> REACTIVE POWER PHASE T      - METERN: ID_RPT  - MQTTtopic: /RPT
;   16 --> POWER FACTOR PHASE R        - METERN: ID_PFR  - MQTTtopic: /PFR
;   17 --> POWER FACTOR PHASE S        - METERN: ID_PFS  - MQTTtopic: /PFS
;   18 --> POWER FACTOR PHASE T        - METERN: ID_PFT  - MQTTtopic: /PFT
;   19 --> PHASE ANGLE PHASE R         - METERN: ID_PAR  - MQTTtopic: /PAR
;   20 --> PHASE ANGLE PHASE S         - METERN: ID_PAS  - MQTTtopic: /PAS
;   21 --> PHASE ANGLE PHASE T         - METERN: ID_PAT  - MQTTtopic: /PAT
;   22 --> AVERANGE VOLT TO NEUTRAL    - METERN: ID_AVN  - MQTTtopic: /AVN
;   23 --> AVERANGE LINE CURRENT       - METERN: ID_ALC  - MQTTtopic: /ALC
;   24 --> SUM LINE CURRENT            - METERN: ID_SLC  - MQTTtopic: /SLC
;   25 --> TOTAL POWER                 - METERN: ID_TP   - MQTTtopic: /TP
;   26 --> TOTAL APPARENT POWER        - METERN: ID_TAP  - MQTTtopic: /TAP
;   27 --> TOTAL REACTIVE POWER        - METERN: ID_TRP  - MQTTtopic: /TRP
;   28 --> TOTAL POWER FACTOR          - METERN: ID_TPF  - MQTTtopic: /TPF
;   29 --> TOTAL PHASE ANGLE           - METERN: ID_TPA  - MQTTtopic: /TPA
;   30 --> FREQUENCY                   - METERN: ID_F    - MQTTtopic: /F
;   31 --> IMPORTED ENERGY             - METERN: ID_IE   - MQTTtopic: /IE
;   32 --> EXPORTED ENERGY             - METERN: ID_EE   - MQTTtopic: /EE
;   33 --> REACTIVE IMPORTED ENERGY    - METERN: ID_RIE  - MQTTtopic: /RIE
;   34 --> REACTIVE EXPORTED ENERGY    - METERN: ID_REE  - MQTTtopic: /REE
;   35 --> VOLT RS                     - METERN: ID_VRS  - MQTTtopic: /VRS
;   36 --> VOLT ST                     - METERN: ID_VST  - MQTTtopic: /VST
;   37 --> VOLT TR                     - METERN: ID_VTR  - MQTTtopic: /VTR
;   38 --> AVERAGA VOLT LINE TO LINE   - METERN: ID_AVLL - MQTTtopic: /AVLL
;   39 --> NEUTRAL CURRENT             - METERN: ID_NC   - MQTTtopic: /NC
;   40 --> TOTAL ACTIVE ENERGY         - METERN: ID_TE   - MQTTtopic: /TE
;   41 --> TOTAL REACTIVE ENERGY       - METERN: ID_TRE  - MQTTtopic: /TRE
;
; Generic modbus slave List Value
;    Each register read by the sensor is published in this format
;        <ID>_<count>(<value>*-)
;        Eg. if the value of the second register read of the sensor with ID=3
;        are 100, in the output file there will be   3_2(100*-)
;        Similary the MQTTtopic will be: /2
;

sunpower327
Messaggi: 41
Iscritto il: 21/01/2018, 10:50

Re: Programma MONITOR per la lettura contatori EASTRON [GUIDA]

Messaggioda sunpower327 » 30/08/2020, 15:03

metus ha scritto:Hai provato a mettere sudo davanti al comando? (Sicuramente non è quello ma io ci proverei)
Inoltre controllerei i permessi dei file. [Per scrupolo rieseguirei tutti i comandi del primo post di questo topic

come supponevo avevo visto giusto il problema è la versione hardware del raspberryquello che funziona con monitor al comando uname -a mi da questo risultato:

Codice: Seleziona tutto

pi@raspberrypi:/var/www/comapps $ uname -a
Linux raspberrypi 4.14.50-v7+ #1122 SMP Tue Jun 19 12:26:26 BST 2018 armv7l GNU/Linux

si vede armv7 invece di armv6
quindi monitor non avendo i sorgenti non posso ricompilarlo per armv6 pazienza basta aver trovato l'inghippo.
ho semplicemente messo sd in un altro raspberry con hardware diverso.

sunpower327
Messaggi: 41
Iscritto il: 21/01/2018, 10:50

Re: Programma MONITOR per la lettura contatori EASTRON [GUIDA]

Messaggioda sunpower327 » 30/08/2020, 21:50

oggi dopo tanto tempo sono tornato su monitor e racconto i problemi in cui sono incappato:
fermo metern prima di fare qualsiasi test,
controllo il file di configurazione di monitor una decina di volte ma niente sempre msg di errore, alla fine vedo un post con il solito mio errore e dice di fermare anche 123solar ma io stò usando 1 solo contatore sdm120c poi andando su 123solar non configurato in quanto ho preso una immagine fatta da Flavio scopro che è ON collego anche le parole di Flavio che diceva che non era compatibile sul solito device e di default 123solar era configurato sul solito device. quindi lo fermo e lo disabilito con le info di Flavio che ho letto nel post più sopra.
testo con sudo ./monitor e non vedo nulla ma ha creato il file .txt nella ram virtuale /dev/shm/metern1.txt
che visualizzo con il comando cat /dev/shm/metern1.txt
riprovo con monitor -b il verbose e vedo che funziona.
cambio allora il file in /var/www/metern/config/config_daemond.php mettendo il doppio slash alle righe che non devono essere eseguite ed aggiungo le nuove

Codice: Seleziona tutto

<?php
if(!defined('checkaccess')){die('Direct access not permitted');}
// Manage com. apps daemon as 'http' user if needed

if (is_null($PID)) { // Stop Daemon
   //exec("pkill -f pooler485 > /dev/null 2>&1 &");
        exec("php /var/www/comapps/com_daemon_loop.php stop");
   #exec("pkill -f loadcheck > /dev/null 2>&1 &");   
} else { //Start
   //exec("pooler485 1 9600 /dev/ttyUSB0 > /dev/null 2>/dev/null &");
        exec("php /var/www/comapps/com_daemon_loop.php start");
   #exec("loadcheck > /dev/null 2>/dev/null &");
}
?>

modifico anche metern
/var/www/config/config_met1.php con i nuovi comandi

Codice: Seleziona tutto

<?php
if(!defined('checkaccess')){die('Direct access not permitted');}

// ### CONFIG FOR METER #1

$METNAME1="Consumi";
$TYPE1='Elect';
$PROD1=2;
$PHASE1=1;
$SKIPMONITORING1=false;
$ID1="1_IE";
$COMMAND1="pooler 1 IE energy";
$UNIT1="Wh";
$PRECI1=0;
$PASSO1=0;
$COLOR1='2E6CE5';
$PRICE1=0.16;
$LID1="1_P";
$LIVECOMMAND1="pooler 1 P power";
$LIVEUNIT1="W";
$EMAIL1="";
$POAKEY1='';
$POUKEY1='';
$TLGRTOK1='';
$TLGRCID1='';
$WARNCONSOD1=0;
$NORESPM1=false;

$cfgver=1580629442;
?>

riavvio metern e comincia a funzionare ma non vedo gli indicatori a parte la cpu_temp
allora ad intuito modifico la configurazione indicatori come da immagine
Immagine
ma gli indicatori non vanno allora controllo cosa fa il file reqsdm e scopro che con questo monitor così configurato non può lavorare e lo modifico non cancellando le righe ma mettendo il doppio slash // ops la guida diceva di usare reqsubmet me lo sono pescato.
/var/www/comapps/reqsdm.php

Codice: Seleziona tutto

#!/usr/bin/php
<?php
// This script will output a meterN compatible format for the main or live command
// You'll need to setup correct permission
// chmod +x reqsdm.php
// then
// ln -s /var/www/comapps/reqsdm.php /usr/local/bin/reqsdm
// Request command with 'reqsdm tensione' or 'reqsdm corrente' or ......

if (isset($_SERVER['REMOTE_ADDR'])) {
    die('Direct access not permitted');
}
if (!isset($argv[1])) {
   die("Abording: no valid argument given.\n");
      } elseif ($argv[1] == 'tensione') {
         //$outstr =  exec('cat /dev/shm/metern1.txt | egrep "^1_1\(" | grep "*V)"');
                        $outstr =  exec('cat /dev/shm/metern1.txt | egrep "^1_V\(" | grep "*V)"');
      } elseif ($argv[1] == 'corrente') {
         //$outstr =  exec('cat /dev/shm/metern1.txt | egrep "^1_2\(" | grep "*A)"');
         $outstr =  exec('cat /dev/shm/metern1.txt | egrep "^1_C\(" | grep "*A)"');
      } elseif ($argv[1] == 'freq') {
         //$outstr =  exec('cat /dev/shm/metern1.txt | egrep "^1_3\(" | grep "*Hz)"');
         $outstr =  exec('cat /dev/shm/metern1.txt | egrep "^1_F\(" | grep "*Hz)"');
      } elseif ($argv[1] == 'cospi') {
         //$outstr =  exec('cat /dev/shm/metern1.txt | egrep "^1_4\(" | grep "*F)"');
         $outstr =  exec('cat /dev/shm/metern1.txt | egrep "^1_PF\(" | grep "*F)"');
      } elseif ($argv[1] == 'cpu-temp') {
         $outstr =  exec('cat /sys/class/thermal/thermal_zone0/temp');
         $outstr = $outstr/1000;
         $outstr = "cpu($outstr*°C)";
      } elseif ($argv[1] == 'pdc-temp-m') {
              $url = 'http://192.168.1.99/json?tasknr=1';
              $pagina = file_get_contents($url);
         //grazie  MegaMarco83 modifica nuovo EspEasy
               $json_output = json_decode($pagina, true);
                        $val    = $json_output['TaskValues'][0]['Value'];
                        $outstr = ("pdctm($val*°C)\n");
      } elseif ($argv[1] == 'pdc-temp-r') {
              $url = 'http://192.168.1.99/json?tasknr=2';
              $pagina = file_get_contents($url);
               $json_output = json_decode($pagina, true);
                        $val    = $json_output['TaskValues'][0]['Value'];
                        $outstr = ("pdctr($val*°C)\n");   
      } elseif ($argv[1] == 'am2302t') {
              $url = 'http://192.168.1.100/json?tasknr=2';
              $pagina = file_get_contents($url);
               $json_output = json_decode($pagina, true);
                        $val    = $json_output['TaskValues'][0]['Value'];
                        $outstr = ("am2302t($val*°C)\n");   
      } elseif ($argv[1] == 'am2302u') {
              $url = 'http://192.168.1.100/json?tasknr=2';
              $pagina = file_get_contents($url);
               $json_output = json_decode($pagina, true);
                        $val    = $json_output['TaskValues'][1]['Value'];
                        $outstr = ("am2302u($val*%)\n");
      // and so on ....
           } else {
                        die("Usage: reqsdm (tensione|corrente|freq|cospi|cpu-temp)\n");
   }
echo "$outstr";
?>

riavvio metern e gli indicatori si mettono a funzionare
poi copio anche gli script monitor_protocol.tar dentro /var/www/metern/scripts
do il comando pi@raspberrypi:/var/www/metern/scripts $ sudo tar -xvvf monitor_protocol.tar
assegno a www-data proprietario e gruppo con chown
pi@raspberrypi:/var/www/metern/scripts $ sudo chown -R www-data:www-data *
e poi non so se serve ma rendo anche eseguibili con chmod
apparentemente sembra funzionare tutto ma se vado in admin e stoppo metern mi rimane la scritta ON fino a che non mi sposto di schermata , la solita cosa se da off torno a ON , a parte questo difetto mi sembra funzionare tutto.
prima di fare tutte le modifiche questo freeze non c'era.


poi altra cosa fermo metern do il comando sudo ./monitor mi crea il file correttamente in /dev/shm però se eseguo il verbose in realta ci sono degli errori ecco il comando ma non sempre vengono fuori dal convertitore rs485 usb al sdm120C ci sono 50 cm ma con sdm120c a sempre lavorato correttamente.

Codice: Seleziona tutto

pi@raspberrypi:/var/www/comapps $ sudo ./monitor -b

Input parameters: ./monitor -b

Config file: ./monitor.conf
Output file:
Output file opened
Config loaded
Initialization complete
2 section detected
MQTT setup complete: don't use MQTT
First communication device parameters successfully loaded
First communication device successfully initialized
One communication port detected
1 communication device successfully initialized
Communication device successful opened
Start reading sensor
Reading Sensor1 parameters from config
Sensor1 common parameters successful readed from config
Modbus context for Sensor1 successful set
Set slave address for Sensor1: 1
try to reading data from Sensor1
[01][04][00][00][00][02][71][CB]
Waiting for a confirmation...
ERROR Connection timed out: select
[01][04][00][00][00][02][71][CB]
Waiting for a confirmation...
ERROR Connection timed out: select
[01][04][00][00][00][02][71][CB]
Waiting for a confirmation...
ERROR Resource temporarily unavailable: read
ERROR modbus_read_input_registers (-1)
Address = 1, Reg = 18, nb = 2, res = -1
Error reading sensor 1
End reading sensor
First communication device successfully closed
Communication device successful closed
Ending operations
Config unloaded

Compdete.

pi@raspberrypi:/var/www/comapps $



ho fatto ulteriori prove e non mi sembra molto stabile avete provato a dare il comando con opzione -b?

capoccio1
Messaggi: 58
Iscritto il: 22/03/2017, 9:07

Re: Programma MONITOR per la lettura contatori EASTRON [GUIDA]

Messaggioda capoccio1 » 11/10/2020, 10:27

Salve a tutti, perdonate il mio limite di conoscenze di programmazione ma con quel poco di materiale e con l'aiuto della miniguida di Flane (ancora in fase di completamento) ho acquistato un terzo contatore da inserire sul mio impianto per monitorare i consumi della mansarda.
Attualmente metern funzionante è configurato con 2 contatori per leggere sia la produzione del mio impianto fotovoltaico che i consumi generali.

Sono stati inseriti i meters di default:
1 - Produzione
2 - Consumi
3 - Prelievi
4 - Immissioni
5 - Autoconsumo
I due contatori installati hanno come ID 1 (produzione), ID 2 (consumi), il terzo l'ho impostato con ID 6 (mansarda)
da riga di comando il contatore funziona:


Immagine

questi i vari passaggi:


Immagine

Immagine

Immagine

Immagine

Immagine

Immagine

non mi funziona anzi legge per un attimo i valori e poi torna tutto a zero in modo alternato, il valore della mansarda non lo visualizza mai, dove sbaglio?

Avatar utente
Flane
Messaggi: 2460
Iscritto il: 16/01/2016, 15:02

Re: Programma MONITOR per la lettura contatori EASTRON [GUIDA]

Messaggioda Flane » 11/10/2020, 18:13

Capoccio, il tuo problema non c'entra nulla con quesata discussione almeno che tu non uso il software MONITOR, ma sono certo di no.
Qui sei completamente OT.

TI HO RISPOSTO NELL'ALTRA DISCUSSIONE

s_p
Messaggi: 283
Iscritto il: 06/04/2017, 20:49

Re: Programma MONITOR per la lettura contatori EASTRON [GUIDA]

Messaggioda s_p » 21/12/2020, 13:36

buongiorno a tutti

onde evitare casini che posso comninare chiedo qualche info.
il mio target è rendere disponibili tutti i dati prodotti da MeterN e 123Solar al brocker mqtt.
Io ho 2 adattatori, uno per l'inverter Aurora e 1 per i SDM120, il programma monitor, che gentilmente Garluk ha messo a disposizione, può sostituire aurora in 123Solar ??


s_p
Messaggi: 283
Iscritto il: 06/04/2017, 20:49

Re: Programma MONITOR per la lettura contatori EASTRON [GUIDA]

Messaggioda s_p » 21/12/2020, 14:37

all'inizio di questo post, Garluk ha modificato il messaggio iniziale inserendo "monitor con 123solar" ma non mi è chiaro se sostituisce in todo il protocollo aurora, aggiungeno l'invio al broker mqtt


Torna a “MeterN”

Chi c’è in linea

Visitano il forum: Nessuno e 10 ospiti