Se sei già registrato           oppure    

Orario: 30/04/2024 00:16:20  

 

Energia Alternativa ed Energia Fai Da Te > Solare Fotovoltaico

VISUALIZZA L'ALBUM

Pagine: (9)   1   2   3   4   5   6   [7]   8   9    (Ultimo Msg)


Sirio Power raspberry/influxdb/grafana
FinePagina

maxsemp

Avatar
KiloWatt


Gruppo:Utente
Messaggi:244

Stato:



Inviato il: 13/07/2020 18:20:13

Porta USB e RJ45. Linverter è collegato a raspberry pi3 con raspbian stretch. Monitoro il mio impianto fv con metern.



---------------
Impianto fotovoltaico Off-Grid 3 kWp
10 moduli 300 W SUNERG
inverter Genius 50 - fw 32.40
8 batterie 200 Ah 12 V

 

emuland

Avatar
GigaWatt


Gruppo:Utente
Messaggi:4451

Stato:



Inviato il: 14/07/2020 08:28:35

posta gli errori, ripeto cosi è impossibile fare troubleshooting



---------------
4A per mmq per Legge
Rane Fritte, cavallette, bagarozzi e cotillon! Venite fuori alla festa!

 

maxsemp

Avatar
KiloWatt


Gruppo:Utente
Messaggi:244

Stato:



Inviato il: 14/07/2020 13:28:24

Sì, scusatemi.
Il codice che ho testato è quello che postato sopra. Non sono esperto di python, infatto è da poco che ho cominciato a sbatterci la testa contro.
Grazie.


>>> import sys
>>> import crcmod
if comando == 'QPIGS':
    nbytes = 110
elif comando == 'QID':
    nbytes = 18
elif comando == 'QFLAG':
    nbytes = 15
elif comando == 'QPI':
    nbytes = 8
elif comando == 'QMOD':
    nbytes = 5
else:

    print ('Command not found')
    sys.exit(0)

calc_crc(comando)
print('Command='), comando
print('CRC='),crc

crc1=crc[0:4]
crc2=crc[0:2]+crc[4:6]

crc1=int(crc1, base=16)
crc2=int(crc2, base=16)

fd = open('/dev/hidraw0', 'r+')
fd.write(comando+chr(crc1)+chr(crc2)+'\r')
r = fd.read(nbytes).encode('string-escape')

s = r.split("")
print (s)

i = s[0][1:].split(" ")
print (i)

fd.close()>>> import time
>>>
>>> comando = 'QPIGS'
>>>
>>> xmodem_crc_func = crcmod.mkCrcFun(0x11021, rev=False, initCrc=0x0000, xorOut=0x0000)
>>>
>>> def calc_crc(comando):
...     global crc
...     crc = hex(xmodem_crc_func(comando))
...     return crc
...
>>> # calcular crc
... comando = raw_input("Enter command (qflag, qid, qmod, qpi, qpigs): ")
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
NameError: name 'raw_input' is not defined
>>> comando = comando.upper()
>>> if comando == 'QPIGS':
...     nbytes = 110
... elif comando == 'QID':
...     nbytes = 18
... elif comando == 'QFLAG':
...     nbytes = 15
... elif comando == 'QPI':
...     nbytes = 8
... elif comando == 'QMOD':
...     nbytes = 5
... else:
...
  File "<stdin>", line 12

    ^
IndentationError: expected an indented block
>>>     print ('Command not found')
  File "<stdin>", line 1
    print ('Command not found')
    ^
IndentationError: unexpected indent
>>>     sys.exit(0)
  File "<stdin>", line 1
    sys.exit(0)
    ^
IndentationError: unexpected indent
>>>
>>> calc_crc(comando)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 3, in calc_crc
  File "/usr/local/lib/python3.5/dist-packages/crcmod/crcmod.py", line 432, in crcfun
    return fun(data, crc, table)
TypeError: Unicode-objects must be encoded before calculating a CRC
>>> print('Command='), comando
Command=
(None, 'QPIGS')
>>> print('CRC='),crc
CRC=
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'crc' is not defined
>>>
>>> crc1=crc[0:4]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'crc' is not defined
>>> crc2=crc[0:2]+crc[4:6]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'crc' is not defined
>>>
>>> crc1=int(crc1, base=16)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'crc1' is not defined
>>> crc2=int(crc2, base=16)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'crc2' is not defined
>>>
>>> fd = open('/dev/hidraw0', 'r+')
>>> fd.write(comando+chr(crc1)+chr(crc2)+'\r')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'crc1' is not defined
>>> r = fd.read(nbytes).encode('string-escape')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'nbytes' is not defined
>>>
>>> s = r.split("")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'r' is not defined
>>> print (s)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 's' is not defined
>>>
>>> i = s[0][1:].split(" ")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 's' is not defined
>>> print (i)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'i' is not defined
>>>
>>> fd.close()



---------------
Impianto fotovoltaico Off-Grid 3 kWp
10 moduli 300 W SUNERG
inverter Genius 50 - fw 32.40
8 batterie 200 Ah 12 V

 

eliafino

Avatar
GigaWatt


Gruppo:MODERATORE
Messaggi:1419

Stato:



Inviato il: 14/07/2020 15:21:15

Sera ragazzi, ho messo su grafana, direi fantastico! Pochi minuti di configurazione e i grafici sono già belli che pronti! Per la produzione devo ancora installare il sensore di corrente tra regolatore di carica e batteria... spero presto.

grafana



Modificato da eliafino - 20/07/2020, 11:00:49


---------------
Impianto Fotovoltaico "eliafino" in Tempo Reale.
http://www.eliafino.it:3000/d/solare/impianto-fotovoltaico-eliafino

 

Luca450Mhz

Avatar
GigaWatt


Gruppo:Utente
Messaggi:3204

Stato:



Inviato il: 14/07/2020 16:28:45

Bello il nuovo sito di monitoraggio!
Scusa eliafino perché non fai una lettura diretta dello shunt del PCM? Io faccio così con Arduino per conoscere la corrente in circolo..



---------------
Pannelli: 6975 Wp (poli e mono). Inverter UPS PSW7 6kW 48V toroidale con switch comandato dal mio sistema di domotica (RaspberryPi + vari Wemos D1 Mini - ESP8266). Regolatore di carica: Mpp Solar PCM8048.
Batterie: 24 elementi trazione pesante 315Ah C5 48V.

 

eliafino

Avatar
GigaWatt


Gruppo:MODERATORE
Messaggi:1419

Stato:



Inviato il: 14/07/2020 16:40:50

CITAZIONE (Luca450Mhz, 14/07/2020 16:28:45 ) Discussione.php?215740&7#MSG95

Bello il nuovo sito di monitoraggio!
Scusa eliafino perché non fai una lettura diretta dello shunt del PCM? Io faccio così con Arduino per conoscere la corrente in circolo..

Grazie! Sì l'idea è quella, ho preso un PZEM-017 per leggere sia tensione che corrente.



---------------
Impianto Fotovoltaico "eliafino" in Tempo Reale.
http://www.eliafino.it:3000/d/solare/impianto-fotovoltaico-eliafino

 

maxsemp

Avatar
KiloWatt


Gruppo:Utente
Messaggi:244

Stato:



Inviato il: 14/07/2020 17:09:34

CITAZIONE (eliafino, 14/07/2020 15:21:15 ) Discussione.php?215740&7#MSG94

Sera ragazzi, ho messo su grafana, direi fantastico! Pochi minuti di configurazione e i grafici sono già belli che pronti! Per la produzione devo ancora installare il sensore di corrente tra regolatore di carica e batteria... spero presto.

grafana


Bello!!! Ma i dati li prendi da "/dev/hidraw0" o da USBx?



---------------
Impianto fotovoltaico Off-Grid 3 kWp
10 moduli 300 W SUNERG
inverter Genius 50 - fw 32.40
8 batterie 200 Ah 12 V

 

eliafino

Avatar
GigaWatt


Gruppo:MODERATORE
Messaggi:1419

Stato:



Inviato il: 14/07/2020 17:24:39

CITAZIONE (maxsemp, 14/07/2020 17:09:34 ) Discussione.php?215740&7#MSG97

Bello!!! Ma i dati li prendi da "/dev/hidraw0" o da USBx?

Con raspberry leggo /dev/hidraw0 e poi mando a MySQL su una VPS dedicata



---------------
Impianto Fotovoltaico "eliafino" in Tempo Reale.
http://www.eliafino.it:3000/d/solare/impianto-fotovoltaico-eliafino

 

maxsemp

Avatar
KiloWatt


Gruppo:Utente
Messaggi:244

Stato:



Inviato il: 14/07/2020 17:57:09

Anch'io vorrei leggere da hidraw0, ma fino adesso no ci sono riuscito.



---------------
Impianto fotovoltaico Off-Grid 3 kWp
10 moduli 300 W SUNERG
inverter Genius 50 - fw 32.40
8 batterie 200 Ah 12 V

 

eliafino

Avatar
GigaWatt


Gruppo:MODERATORE
Messaggi:1419

Stato:



Inviato il: 14/07/2020 18:47:17

CITAZIONE (maxsemp, 14/07/2020 17:57:09 ) Discussione.php?215740&7#MSG99

Anch'io vorrei leggere da hidraw0, ma fino adesso no ci sono riuscito.

Prova con questo codice python2

#!/usr/bin/python

import os, sys
import time

fd = os.open('/dev/hidraw0', os.O_RDWR | os.O_NONBLOCK)
os.write(fd, 'QPIGS\r')
time.sleep(0.2)
r = os.read(fd, 137).encode('string-escape')

while r.find('r') == -1 :
	time.sleep(.1)
	r = r + os.read(fd, 137).encode('string-escape')

s = r.split("")
print s

os.close(fd)
sys.exit(0)



---------------
Impianto Fotovoltaico "eliafino" in Tempo Reale.
http://www.eliafino.it:3000/d/solare/impianto-fotovoltaico-eliafino

 

emuland

Avatar
GigaWatt


Gruppo:Utente
Messaggi:4451

Stato:



Inviato il: 14/07/2020 19:19:39

CITAZIONE (maxsemp, 14/07/2020 18:47:17 ) Discussione.php?215740&7#MSG93

Sì, scusatemi.
Il codice che ho testato è quello che postato sopra. Non sono esperto di python, infatto è da poco che ho cominciato a sbatterci la testa contro.
Grazie.


>>> import sys
>>> import crcmod
if comando == 'QPIGS':
    nbytes = 110
elif comando == 'QID':
    nbytes = 18
elif comando == 'QFLAG':
    nbytes = 15
elif comando == 'QPI':
    nbytes = 8
elif comando == 'QMOD':
    nbytes = 5
else:

    print ('Command not found')
    sys.exit(0)

calc_crc(comando)
print('Command='), comando
print('CRC='),crc

crc1=crc[0:4]
crc2=crc[0:2]+crc[4:6]

crc1=int(crc1, base=16)
crc2=int(crc2, base=16)

fd = open('/dev/hidraw0', 'r+')
fd.write(comando+chr(crc1)+chr(crc2)+'\r')
r = fd.read(nbytes).encode('string-escape')

s = r.split("")
print (s)

i = s[0][1:].split(" ")
print (i)

fd.close()>>> import time
>>>
>>> comando = 'QPIGS'
>>>
>>> xmodem_crc_func = crcmod.mkCrcFun(0x11021, rev=False, initCrc=0x0000, xorOut=0x0000)
>>>
>>> def calc_crc(comando):
...     global crc
...     crc = hex(xmodem_crc_func(comando))
...     return crc
...
>>> # calcular crc
... comando = raw_input("Enter command (qflag, qid, qmod, qpi, qpigs): ")
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
NameError: name 'raw_input' is not defined
>>> comando = comando.upper()
>>> if comando == 'QPIGS':
...     nbytes = 110
... elif comando == 'QID':
...     nbytes = 18
... elif comando == 'QFLAG':
...     nbytes = 15
... elif comando == 'QPI':
...     nbytes = 8
... elif comando == 'QMOD':
...     nbytes = 5
... else:
...
  File "<stdin>", line 12

    ^
IndentationError: expected an indented block
>>>     print ('Command not found')
  File "<stdin>", line 1
    print ('Command not found')
    ^
IndentationError: unexpected indent
>>>     sys.exit(0)
  File "<stdin>", line 1
    sys.exit(0)
    ^
IndentationError: unexpected indent
>>>
>>> calc_crc(comando)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 3, in calc_crc
  File "/usr/local/lib/python3.5/dist-packages/crcmod/crcmod.py", line 432, in crcfun
    return fun(data, crc, table)
TypeError: Unicode-objects must be encoded before calculating a CRC
>>> print('Command='), comando
Command=
(None, 'QPIGS')
>>> print('CRC='),crc
CRC=
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'crc' is not defined
>>>
>>> crc1=crc[0:4]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'crc' is not defined
>>> crc2=crc[0:2]+crc[4:6]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'crc' is not defined
>>>
>>> crc1=int(crc1, base=16)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'crc1' is not defined
>>> crc2=int(crc2, base=16)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'crc2' is not defined
>>>
>>> fd = open('/dev/hidraw0', 'r+')
>>> fd.write(comando+chr(crc1)+chr(crc2)+'\r')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'crc1' is not defined
>>> r = fd.read(nbytes).encode('string-escape')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'nbytes' is not defined
>>>
>>> s = r.split("")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'r' is not defined
>>> print (s)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 's' is not defined
>>>
>>> i = s[0][1:].split(" ")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 's' is not defined
>>> print (i)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'i' is not defined
>>>
>>> fd.close()



A spanne e da smartphone.

L indentazione ê errata

Non riconosce alcune variabili (forse per l indentazione)

Quel codice che hai postato non so se funziona, se vuoi un po' di supporto su quello che ho modificato io posso provare a dartelo.

Sul codice scritto da altri e non verificato non ê il top



---------------
4A per mmq per Legge
Rane Fritte, cavallette, bagarozzi e cotillon! Venite fuori alla festa!

 

maxsemp

Avatar
KiloWatt


Gruppo:Utente
Messaggi:244

Stato:



Inviato il: 15/07/2020 14:27:16

CITAZIONE (eliafino, 14/07/2020 18:47:17 ) Discussione.php?215740&7#MSG100

CITAZIONE (maxsemp, 14/07/2020 17:57:09 ) Discussione.php?215740&7#MSG99
Anch'io vorrei leggere da hidraw0, ma fino adesso no ci sono riuscito.

Prova con questo codice python2

#!/usr/bin/python

import os, sys
import time

fd = os.open('/dev/hidraw0', os.O_RDWR | os.O_NONBLOCK)
os.write(fd, 'QPIGS\r')
time.sleep(0.2)
r = os.read(fd, 137).encode('string-escape')

while r.find('r') == -1 :
	time.sleep(.1)
	r = r + os.read(fd, 137).encode('string-escape')

s = r.split("")
print s

os.close(fd)
sys.exit(0)


Non gira, purtroppo.
Lancio il file e la risposta è questa: ['(NAKss\r\x00']



---------------
Impianto fotovoltaico Off-Grid 3 kWp
10 moduli 300 W SUNERG
inverter Genius 50 - fw 32.40
8 batterie 200 Ah 12 V

 

emuland

Avatar
GigaWatt


Gruppo:Utente
Messaggi:4451

Stato:



Inviato il: 15/07/2020 14:50:25

CITAZIONE (maxsemp, 15/07/2020 14:27:16 ) Discussione.php?215740&7#MSG102

CITAZIONE (eliafino, 14/07/2020 18:47:17 ) Discussione.php?215740&7#MSG100
CITAZIONE (maxsemp, 14/07/2020 17:57:09 ) Discussione.php?215740&7#MSG99
Anch'io vorrei leggere da hidraw0, ma fino adesso no ci sono riuscito.

Prova con questo codice python2

#!/usr/bin/python

import os, sys
import time

fd = os.open('/dev/hidraw0', os.O_RDWR | os.O_NONBLOCK)
os.write(fd, 'QPIGS\r')
time.sleep(0.2)
r = os.read(fd, 137).encode('string-escape')

while r.find('r') == -1 :
	time.sleep(.1)
	r = r + os.read(fd, 137).encode('string-escape')

s = r.split("")
print s

os.close(fd)
sys.exit(0)


Non gira, purtroppo.
Lancio il file e la risposta è questa: ['(NAKss\r\x00']



prova a fornirgli il CRC

non so col tuo ma una cosa tipo :
(in byte)

"\x51\x50\x49\x47\x53\xB7\xA9\x0D";



---------------
4A per mmq per Legge
Rane Fritte, cavallette, bagarozzi e cotillon! Venite fuori alla festa!

 

maxsemp

Avatar
KiloWatt


Gruppo:Utente
Messaggi:244

Stato:



Inviato il: 15/07/2020 15:07:16

Ciao emuland.
Ho fatto la prova che mi hai suggerito e questa è la risposta:



[code]>>>
>>> import os, sys
>>> fd = os.open("/dev/hidraw0", os.O_RDWR|os.O_NONBLOCK)
>>> os.write(fd, "\x51\x50\x49\x47\x53\xB7\xA9\x0D\r")
9
>>> os.read(fd, 512)
'(232.0 4'
>>>


Qualcosa restituisce, ma mi sembra manchino altri dati.



---------------
Impianto fotovoltaico Off-Grid 3 kWp
10 moduli 300 W SUNERG
inverter Genius 50 - fw 32.40
8 batterie 200 Ah 12 V

 

maxsemp

Avatar
KiloWatt


Gruppo:Utente
Messaggi:244

Stato:



Inviato il: 15/07/2020 15:35:17

Ho fatto anche questa prova:

import os, sys
import time

fd = os.open('/dev/hidraw0', os.O_RDWR | os.O_NONBLOCK)
os.write(fd, "\x51\x50\x49\x47\x53\xB7\xA9\x0D\r")
time.sleep(0.2)
r = os.read(fd, 137).encode('string-escape')

while r.find('r') == -1 :
	time.sleep(.1)
	r = r + os.read(fd, 137).encode('string-escape')

s = r.split("/")
print s

os.close(fd)
sys.exit(0)


La risposta è la seguente:

['(232.9 49.9 229.9 49.9 0275 0201 005 434 54.10 002 100 0052 0006 069.1 53.99 00000 00110110 00 00 00329 110\x81\xa1\r\x00\x00']


Quindi adesso funziona!



---------------
Impianto fotovoltaico Off-Grid 3 kWp
10 moduli 300 W SUNERG
inverter Genius 50 - fw 32.40
8 batterie 200 Ah 12 V

 
 InizioPagina
 

Pagine: (9)   1   2   3   4   5   6   [7]   8   9    (Ultimo Msg)

Versione Mobile!

Home page       TOP100-SOLAR      Home page forum