Emoncms + Victron CCGX + My Battery App

Hello all,

I have recently built and installed a ESS recently consisting of a 4.8Kwh Battery, Victron Multiplus 2 with a Colour Control GX as a web interface.

With the new release of the My Battery App im trying to figure a way of importing the SOC of the battery into my inputs on my Emonhub which is a Rpi 3b.

I have a good read at the interfer page (link below) and tried writing my own in the emon config but I cannot get them to show up via modbus tcp. I have modbus tcp enabled and I am looking at specific registers in Home assistant.

I think another interfer via modbus for the CCGX would be great. especially with the roll out of the My Battery App.

This the following code i edited but didnt work.

[[ModbusTCP]]    
    Type = EmonModbusTcpInterfacer
    [[[init_settings]]]
         modbus_IP = 192.168.0.80
         modbus_port = 502          # Portclient listens on
    [[[runtimesettings]]]
         register = 843
         rType = uint16
         # nodeid used to match with node definition in nodes section below. Can be set to any integer value not previously used.
         nodeId = 27
         # Channel to publish data to should leave as ToEmonCMS
         pubchannels = ToEmonCMS,            
         interval = 1

[[27]]
     nodename = Multiplus
     [[[rx]]]
       names = Battery_State_of_Charge
       datacodes = 0
       scales = 1
       units = %

See modbus link for registers below.

https://www.victronenergy.com/live/ccgx:modbustcp_faq

Any help or feedback would be great :slight_smile:

Thanks

Gareth

1 Like

Can you post the emonhub log - set the log level to DEBUG first. Post a section of log from restarting the emonhub service please.

Hi,

Thanks for the quick reply. Heres a snapshot.

2020-07-04 20:10:07,324 DEBUG    RFM2Pi     acknowledged command: > 0q
2020-07-04 20:10:07,326 DEBUG    MainThread Setting MQTT subchannels: ['ToEmonCMS']
2020-07-04 20:10:07,328 DEBUG    MainThread Setting MQTT pubchannels: ['ToRFM12']
2020-07-04 20:10:07,329 INFO     MainThread Setting MQTT nodevar_format_enable: 1
2020-07-04 20:10:07,330 INFO     MainThread Setting MQTT node_format_enable: 1
2020-07-04 20:10:07,331 INFO     MainThread Setting MQTT nodevar_format_basetopic: emon/
2020-07-04 20:10:07,332 INFO     MainThread Creating EmonHubEmoncmsHTTPInterfacer 'emoncmsorg' 
2020-07-04 20:10:07,334 DEBUG    MainThread Setting emoncmsorg subchannels: ['ToEmonCMS']
2020-07-04 20:10:07,335 DEBUG    MainThread Setting emoncmsorg pubchannels: ['ToRFM12']
2020-07-04 20:10:07,336 INFO     MainThread Setting emoncmsorg url: https://emoncms.org
2020-07-04 20:10:07,336 INFO     MainThread Setting emoncmsorg senddata: 1
2020-07-04 20:10:07,337 INFO     MainThread Setting emoncmsorg apikey: set
2020-07-04 20:10:07,338 INFO     MainThread Setting emoncmsorg sendstatus: 1
2020-07-04 20:10:07,339 INFO     MainThread Creating EmonModbusTcpInterfacer 'ModbusTCP' 
2020-07-04 20:10:07,341 ERROR    MainThread PYMODBUS NOT PRESENT BUT NEEDED !!
2020-07-04 20:10:07,341 DEBUG    MainThread Setting ModbusTCP rType: uint16
2020-07-04 20:10:07,342 DEBUG    MainThread Setting ModbusTCP interval: 1
2020-07-04 20:10:07,343 DEBUG    MainThread Setting ModbusTCP nodeId: 27
2020-07-04 20:10:07,343 DEBUG    MainThread Setting ModbusTCP pubchannels: ['ToEmonCMS']
2020-07-04 20:10:07,344 DEBUG    MainThread Setting ModbusTCP register: 843
2020-07-04 20:10:07,428 DEBUG    RFM2Pi     device settings updated: E i5 g210 @ 433 MHz
2020-07-04 20:10:07,529 DEBUG    RFM2Pi     acknowledged command: > 1p
2020-07-04 20:10:07,834 DEBUG    RFM2Pi     acknowledged command: <nn> i     - set node ID (standard node ids are 1..30)
2020-07-04 20:10:07,938 DEBUG    RFM2Pi     acknowledged command: <n> b      - set MHz band (4 = 433, 8 = 868, 9 = 915)
2020-07-04 20:10:08,041 DEBUG    RFM2Pi     acknowledged command: <nnnn> o   - change frequency offset within the band (default 1600)
2020-07-04 20:10:08,254 DEBUG    RFM2Pi     acknowledged command: <nnn> g    - set network group (RFM12 only allows 212, 0 = any)
2020-07-04 20:10:08,360 DEBUG    RFM2Pi     acknowledged command: <n> c      - set collect mode (advanced, normally 0)
2020-07-04 20:10:08,572 DEBUG    RFM2Pi     acknowledged command: ...,<nn> a - send data packet to node <nn>, request ack
2020-07-04 20:10:08,678 DEBUG    RFM2Pi     acknowledged command: ...,<nn> s - send data packet to node <nn>, no ack
2020-07-04 20:10:08,784 DEBUG    RFM2Pi     acknowledged command: <n> q      - set quiet mode (1 = don't report bad packets)
2020-07-04 20:10:08,892 DEBUG    RFM2Pi     acknowledged command: <n> x      - set reporting format (0: decimal, 1: hex, 2: hex+ascii)
2020-07-04 20:10:09,207 DEBUG    RFM2Pi     acknowledged command: <hchi>,<hclo>,<addr>,<cmd> f     - FS20 command (868 MHz)
2020-07-04 20:10:09,314 DEBUG    RFM2Pi     acknowledged command: <addr>,<dev>,<on> k              - KAKU command (433 MHz)
2020-07-04 20:10:09,520 DEBUG    RFM2Pi     device settings updated: E i5 g210 @ 433 MHz
2020-07-04 20:10:09,627 DEBUG    RFM2Pi     Discarding RX frame 'unreliable content'? 9 64 240 193 38 8 142 20 112 0 216 20 150 123 32 8 8 71 60 4 241 (-92)
2020-07-04 20:10:09,733 DEBUG    RFM2Pi     Discarding RX frame 'unreliable content'? 13 17 20 234 48 124 0 0 193 150 204 168 128 (-93)
2020-07-04 20:10:12,071 DEBUG    RFM2Pi     7 NEW FRAME : OK 10 198 1 0 0 16 0 2 0 40 94 48 117 48 117 48 117 (-38)
2020-07-04 20:10:12,074 DEBUG    RFM2Pi     7 Timestamp : 1593893412.07
2020-07-04 20:10:12,075 DEBUG    RFM2Pi     7 From Node : 10
2020-07-04 20:10:12,076 DEBUG    RFM2Pi     7    Values : [454, 0, 16, 2, 241.04, 3000, 3000, 3000]
2020-07-04 20:10:12,077 DEBUG    RFM2Pi     7      RSSI : -38
2020-07-04 20:10:12,077 DEBUG    RFM2Pi     7 Sent to channel(start)' : ToEmonCMS

Thanks Gareth

First problem! Always look for errors in log files!!

Quick search on the community for pymodbus throws up this answer

You need to restart the service once installed…

sudo systemctl restart emonhub.service

However, I think the RFM2Pi config might be wrong - can you post that part of the config as well please.

Do you have an emonBase card? if not comment out the RFM2Pi interfacer config.

Hi,

Thanks I will do that from now on :slight_smile:

I enabled SSH today and used the command sudo apt-get install python3-pymodbus . I got an error. Pymodbus is not located in the package.

Ive had a look on github but not sure which one to add to the sd card .

Could you point me in the right direction of what file i need to add to the sd card please?

Cheers

Gareth

Try doing sudo apt update first although another user has had an issue with this.

Hi,

Got myself into a bit of mess with the ‘sudo apt update’. I was running the 2018 emonbase sd card image and the discrete sampling software on my emontxv3 and the ‘sudo apt update’ stalled half way through :frowning:

Tried to reboot and nothing…

So I reflashed the emonbase sd card with the lastest 2019 image and uploaded the latest continuous monitoring firmware onto the emontx. All the input were present and working.

I then used putty to complete the sudo apt update and it all updated and installed pymodbus. Will have a play this weekend and see if I can get the victron modubus registering on the input page.

I will keep you update :slight_smile:

cheers

1 Like

Its much easier to activate mqtt on the venus and use mqtt.
After that use nodered or any parser to get the desired values…

I might have a go with MQTT. I dont have node red running on anything atm.

I have pymodbus up and running now, but more errors. Can seem to find the answer to this one. See below.

My code in the emonhub config is this.

[[ModbusTCP]]    
    Type = EmonModbusTcpInterfacer
    [[[init_settings]]]
         modbus_IP = 192.168.0.80
         modbus_port = 502          # Portclient listens on
    [[[runtimesettings]]]
         rName = Battery State of Charge (System), Battery Voltage (System)
         register = 843, 840
         nReg = 1, 1
         rType = uint16, uint16
         # nodeid used to match with node definition in nodes section below. Can be set to any integer value not previously used.
         nodeId = 27
         # Channel to publish data to should leave as ToEmonCMS
         pubchannels = ToEmonCMS,            
         interval = 10

[[27]]
     nodename = Multiplus
     [[[rx]]]
       names = Battery State of Charge (System), Battery Voltage (System)
       datacodes = H, H
       scales = 1, 10
       units = %, V

any help would be much appreciated :slight_smile:

cheers

Edit - formatted text. BT, Moderatorr

HI all,

For those who have a CCGX connected to a multiplus/quattro and want to read registers via Modbus TCP and import them to the inputs page of emoncms. I have worked out the code that is required for the config file in the interfacers section of the emonhub.

As @James_Hill mentioned the unit ID must be included as there is multiple unit ID’s/slaves on the Victron VE Bus system. See below.

I wanted the SOC and charge/discharger power feed for the My Solar & Battery app.

[[ModbusTCP]]    
    Type = EmonModbusTcpInterfacer
    [[[init_settings]]]
         modbus_IP = 192.168.x.x
         modbus_port = 502         
     [[[runtimesettings]]]
         rName = Battery State of Charge (System), Input Voltage Phase 1, Grid Power, Battery Power, 
         register = 31, 4, 821, 843
         nReg = 1,1,1,1
         nUnit = 239, 239, 100, 100
         rType = uint16, uint16, uint16, int16
         nodeId = 27
         pubchannels = ToEmonCMS,            
         interval = 10

[[27]]
     nodename = Multiplus
     [[[rx]]]
       names = Battery State of Charge (System), Input Voltage Phase 1, Grid Power, Battery Power, 
       datacodes = H,H,h,h
       scales = 0.1,0.1,1,1
       units = %, V, W, W

Cheers

Gareth

1 Like

Can someone help me pls? I am trying to set up Emoncms to access my CCGX, but I am unsure exactly where this config file gets edited in. Worried I might install in the wrong place. Can someone show their full config file & location please?
My Emoncms is on an Intel NUC, & pymodbus has been installed.

Thanks, Doug (safe in Overcast Sunny Australia! Hope Donnie Trump gets over his Covid? )

If you are trying to do the same as @gjones84, you are going to modify emonhub config.

In installing emoncms on an NUC, how did you do it and is emonhub running?

image

Thanks Brian,
I installed from the Github image, & I think I disabled all the Pi bits. (I used the rPi user name etc as standard, cos it was easier!)
Emoncms is running fine, & it is getting data from my monitor. I Installed pymodbus, & that seems fine.
What I wish to achieve is to get the battery SOC from the CCGX, so that I can emulate the Victron Dashboard data (in some yet to be determined form).
My system is 2 of Solaredge 5Kw inverters, currently 15Kw of panels, thew Victron Charger/Inverter & Zenaji Batteries (Which are Lithium Titanate manufactured in Melbourne, Australia)

Hi Doug,

I have done this and it is all up and running and working fine. Once you have pymodbus installed and running. Log into your emonbase locally.

Then click the three bars at top left. Click emon hub. Select edit config. Scroll down to interfaces and insert my code. Restart and go to inputs and it should all be there :slightly_smiling_face:.

Once you have that you can configure the My Solar Battery App.

Hope that helps.

Cheers

Gareth

Are you on a generic Linux install or a Pi one?

On to an NUC? Or do you mean you ran the scripts?

How? emonhub? HTTP? MQTT?

Unless I understand more how you have set emoncms up on the NUC I’ll not be able to help much as there are simply too many variables.

Can you click on the button Copy as Markdown next to Server Information on the Admin page and paste into a reply here please (no further formatting required).

Server Information

Server Information

Services

  • emoncms_mqtt :- Active Running
  • feedwriter :- Active Running - sleep 300s 360 feed points pending write
  • service-runner :- Activating Auto-restart
  • redis-server :- Active Running
  • mosquitto :- Active Running
  • demandshaper :- Active Running

Emoncms

Server

  • OS :- Linux 5.4.0-48-generic
  • Host :- pi-desktop | pi-desktop | (192.168.1.182)
  • Date :- 2020-10-03 21:28:33 AEST
  • Uptime :- 21:28:33 up 22:37, 1 user, load average: 0.34, 0.19, 0.13

Memory

  • RAM :- Used: 42.89%
    • Total :- 3.74 GB
    • Used :- 1.6 GB
    • Free :- 2.13 GB
  • Swap :- Used: 0.00%
    • Total :- 2 GB
    • Used :- 0 B
    • Free :- 2 GB
      Write Load Period

Disk

  • / :- Used: 8.87%
    • Total :- 109.04 GB
    • Used :- 9.67 GB
    • Free :- 93.79 GB
    • Write Load :- n/a
  • /boot/efi :- Used: 1.53%
    • Total :- 510.98 MB
    • Used :- 7.8 MB
    • Free :- 503.19 MB
    • Write Load :- n/a

HTTP

  • Server :- Apache/2.4.41 (Ubuntu) HTTP/1.1 CGI/1.1 80

MySQL

  • Version :- 5.5.5-10.3.22-MariaDB-1ubuntu1
  • Host :- localhost:6379 (127.0.0.1)
  • Date :- 2020-10-03 21:28:33 (UTC 10:00‌​)
  • Stats :- Uptime: 81468 Threads: 10 Questions: 42422 Slow queries: 0 Opens: 45 Flush tables: 1 Open tables: 39 Queries per second avg: 0.520

Redis

  • Version :-
    • Redis Server :- 5.0.7
    • PHP Redis :- 5.3.1
  • Host :- localhost:6379
  • Size :- 103 keys (926.98K)
  • Uptime :- 0 days

MQTT Server

  • Version :- Mosquitto 1.6.9
  • Host :- localhost:1883 (127.0.0.1)

PHP

  • Version :- 7.4.3 (Zend Version 3.4.0)
  • Modules :- apache2handler bz2 calendar Core ctype curl date dom v20031129exif FFI fileinfo filter ftp gd gettext hash iconv json libxml mbstring mosquitto v0.4.0mysqli mysqlnd vmysqlnd 7.4.3openssl pcre PDO pdo_mysql Phar posix readline redis v5.3.1Reflection session shmop SimpleXML sockets sodium SPL standard sysvmsg sysvsem sysvshm tokenizer xml xmlreader xmlwriter xsl Zend OPcache zip v1.15.6zlib
Client Information

Client Information

HTTP

  • Browser :- Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 Cyberfox/52.9.1
  • Language :- en-US,en;q=0.5

Window

  • Size :- 2545 x 1343

Screen

  • Resolution :- 2560 x 1440

(end)
Thanks Brian, realising I am well out of my depth (but prepared to learn). I am a hardware man!
I realise that I do not know how all the s/w fits together, except in a basic way.

regards, Doug

You didn’t say how you did the install.

But, when you did the install, you did not install emonhub. You will need to do that.

I think you can just clone the emonhub repo and run the install. As I do not know where or how you installed the scripting part of emoncms, I can’t advise where to install it to.

On the Pi systems that is all in /opt/openenergymonitor.

The standard pi one :+1:

Yes much simpler as emonhub is installed by default.

Hi Gareth,

I realise that this thread is quite old now, but I’m trying to do exactly the same as you did. It seems to run MODBUS successfully, but then I get this in the logfile:

I’d be grateful if you had any advice!

Thanks,

John.