Jump to content

Axpert software


Gnome
 Share

Recommended Posts

Hi all

So I've been using my own software for some time and it has been pretty much a hack job.  I recently put in some work and got it so it is easy to install on a Raspberry Pi.  It'll actually run on any operating system, but I really don't have time to test it everywhere.  So if you are one of the souls that want to test it on another platform that would be greatly appreciated (along with what you had to do).

I've written a very simple tutorial on how to get it running on an RPi.  Everything is open source, so if you have questions let me know about that aspect.

Why release this now?

Because charging money for this prohibits better software from being created.  I'm hoping we can start a community effort to get something half decent for the Axpert without money being involved.

What does it provide?

Right now, not that much.  It allows you to send commands to your Axpert over HTTP.

For example:

# serial port
curl -X PUT -d 'QPIGS' 'http://${Raspberry PI IP}:8080/axpert/serial/command'; echo ''
(241.1 50.0 230.1 50.0 0253 0192 005 381 54.60 000 100 0031 0000 000.0 00.00 00000 00010101 00 00 00000 110

# usb port
curl -X PUT -d 'QPIGS' 'http://${Raspberry PI IP}:8080/axpert/usb/command'; echo ''
(000.0 00.0 230.0 50.0 0230 0181 004 348 50.50 000 083 0029 0000 000.0 00.00 00003 00010000 00 00 00000 010

That sucks, it doesn't do anything

Well the idea is to remove the barrier of communicating with the inverter.  Now you can create a simple HTML + AJAX or Python web-client or whatever you want to interact with the inverter using fabulous HTTP.

So you want me to invest effort in a GUI?

Yes, please 😛

I'll be doing some myself but coding is my day job, so I try not do too much of it outside of work.  If we can create a simple HTML page, the install script can be changed to download that HTML page so that you can use that.

Technicals

The actual software works as follows:

It is a C library that make use of libserialport and HIDAPI to communicate with the inverter.  Those libraries are much better than any other libraries available in any other programming language (under my own testing).  That is why I went with C on this one.  I have an implementation I wrote in both Java and Ruby and the reliability and performance is just meh.

The C library itself is wrapped in a FastCGI process.  My code then makes use of nginx to handle all the web-server related code.

If you don't like nginx, just about every web-server out there supports FastCGI so the world is your oyster.   Additionally if you think the code suck, go ahead and change it up.  It is GPLV3 however, so if you are thinking of using it in your own code you wish to sell, think again.

Edited by Gnome
Link to comment
Share on other sites

Not sure if this is the right place to ask but how can I communicate with my axpert inverter? I don't use utility to charge the batteries but before loadshedding it's nice to have charged batteries, asking my wife to fiddle with settings is a bit of a schlep. Was thinking of using a arduino to just send serial data of the charger source priority when wife pushes a button and when I push another button settings get changed back automatically. Would this be possible? 

Link to comment
Share on other sites

4 hours ago, Gnome said:

Why release this now?

Because charging money for this prohibits better software from being created.  I'm hoping we can start a community effort to get something half decent for the Axpert without money being involved.

Thank you, been waiting for something like this for a long time.. hope this would be a huge success.. 

Link to comment
Share on other sites

4 hours ago, booysenc said:

Not sure if this is the right place to ask but how can I communicate with my axpert inverter?

Haha why not, may as well get the ball rolling eh?

4 hours ago, booysenc said:

charger source priority <snip> Would this be possible? 

Looks like it is possible

Quote

3.8 POP<NN><cr>: Setting device output source priority

Computer: POP<NN><CRC><cr>

Device: (ACK<CRC><cr> if device accepts this command, otherwise, responds (NAK<CRC><cr>

Set output source priority, 00 for utility first, 01 for solar first, 02 for SBU priority

So in order to change it you must send the following command

POP00

If you are using the code I wrote above you do a HTTP PUT request with 'POP00' or to be exact:

# serial port
curl -X PUT -d 'POP00' 'http://${Raspberry PI IP}:8080/axpert/serial/command'

# usb port
curl -X PUT -d 'POP00' 'http://${Raspberry PI IP}:8080/axpert/usb/command'

This is just using curl which is a command line utility.

4 hours ago, booysenc said:

Was thinking of using a arduino to just send serial data of the charger source priority when wife pushes a button and when I push another button settings get changed back automatically. Would this be possible? 

Yep, definitely possible to use an Arduino.  I was actually thinking of creating a Arduino version.  If you want to save a tiny bit of time, you can make use of the CRC code I wrote and disable the table method (because Arduino does not have enough memory for Table method).  It isn't really noticeable slower IMO.

Using that code you would take POP00, create the CRC using the CRC functions:

const char* command = "POP00";
voltronic_crc_t crc = calculate_voltronic_crc(command, strlen(command));

write_c_string_serial(command, strlen(command));
write_byte_to_serial(crc & 0xff);
write_byte_to_serial((crc >> 8) & 0xff);
write_c_string_serial("\r");

Then to read I would suggest looking at read loop.

Not sure how much coding you have done, so this might be a bit overwhelming to you.

Some other things:

Serial port data logic levels from the Axpert aren't compatible with Arduino.  So the voltages are too high.  You'll need to deal with this I think.

When I have some time I may look into an Arduino adapter in my code but right now, I'd rather focus on creating a web interface because most people can happily afford a Raspberry Pi and it offers the option of a lot more functionality.

Also some of the inverters only have USB and communicating with them using Arduino will not be trivial.

Hope this gets you going :)

Link to comment
Share on other sites

4 hours ago, Jaco de Jongh said:

Thank you, been waiting for something like this for a long time.. hope this would be a huge success.. 

Thanks, this evening I just created a simple dashboard.  I'll make an some time in the week, then at least there will some really simple stuff.

Hoping if we get the boll rolling people will be more willing to invest time in it.

Lots of work ahead.  But my aim was to put down a web server and a way to interact with the hardware.  Because the web-server I'm using is nginx, you can easily add your own pages to it, or other web stuff to it and it will all be hosted from that one server (on your local network).  For those not familiar with nginx, it is like Apache or any other web-server.  Super fast and really easy to setup.

Of all the features offered by other solutions (including watch power), the features in order of time required to make it happen are:

  • GUI:  This will require quite a bit of time.  Especially because I think creating a web based system makes the most sense.  That way you can view it on your phone, tablet, PC, whatever you want.  We may even be able to just make use of EmonCMS but when I looked at their documentation I found it a bit hard to understand their integration points.  I'll have to do a code dive and that'll require a bit more time than I have right now
  • BMS: I don't even own a BMS, so step 1 is either getting one or having someone else write the code.  But I would simply do the same as the Axpert software above.  Put the BMS on a web interface.  That way you can interact with it over HTTP as if it is on the web and people can just create HTML pages to interact with it.
  • History: Keeping a history of previous commands so you can setup some like metrics or the like.  This isn't a lot of work but it is some work.
  • Sonoff: This is pretty trivial.  I don't own a sonoff but I built my own sort of "sonoff" using Arduino and I already have that integrated.  Lots of options here.
Link to comment
Share on other sites

Just an update, right now this is pretty crappy to use, I realize that.  But the backend is pretty solid.  This is me calling the inverter over USB.

$ time curl -X PUT -d 'QPI' 'http://192.168.0.12:8080/axpert/usb/command'
(PI30
real	0m0.059s
user	0m0.008s
sys	0m0.006s

$ time curl -X PUT -d 'QPIGS' 'http://192.168.0.12:8080/axpert/usb/command'
(244.1 50.0 230.1 50.0 0138 0091 002 382 54.60 000 100 0031 0000 000.0 00.00 00000 00010101 00 00 00000 110
real	0m0.580s
user	0m0.008s
sys	0m0.006s

$ time curl -X PUT -d 'QPIRI' 'http://192.168.0.12:8080/axpert/usb/command'
(230.0 21.7 230.0 50.0 21.7 5000 5000 48.0 46.0 42.0 57.6 54.6 2 20 020 1 0 2 9 01 0 0 54.0 0 1 050 1
real	0m0.647s
user	0m0.008s
sys	0m0.006s

$ time curl -X PUT -d 'QFLAG' 'http://192.168.0.12:8080/axpert/usb/command'
(EbckxyzDajuv
real	0m0.069s
user	0m0.008s
sys	0m0.006s

The commands above are just making a HTTP PUT request to my Raspberry Pi and timing how long it takes. The time it takes depends on the command.  The fastest is QPI which is just the protocol version.  But the time it takes is consistent with every other solution I've tested.  The HTTP part only adds about 1-3ms to the total time.  Negligible compared to the time the Axpert spends.

I also wrote a solution in Java which ended up adding a total of 300ms extra to each command.  Ruby had close to the same performance as the C version.  In both cases I opted for the C solution because the serial port code in Java is truly terrible and unreliable.  The USB code in Java is even worse.  Ruby was a bit better but not great either.  Overall the C code runs on any operating system for both USB and Serial and it does so reliable.  Last thing you want is for the inverter communication to suddenly stop, you need to start things, etc. it is super annoying.

I should add I tested most of my code using the Serial interface but I switched to USB to make the tutorial and now I've been using it ever since and it is actually quite reliable, to my surprise 😛

Btw. this is all tested on Axpert King, hence the output voltage being so different from input voltage

Edited by Gnome
Link to comment
Share on other sites

1 hour ago, flamegrilled said:

1591771730_Screenshot_20200311-082423_HomeAssistant.thumb.jpg.8efeb6a38cf89e0488279cc362547b6a.jpg

Using the ICC Rpi to get this info from the Axpert into HA.There is your " GUI:  This will require quite a bit of time.  "

What is HA?  This is on your phone I assume?  Looks promising.

Link to comment
Share on other sites

Nice, I'll check it out!

Oh btw:

3 hours ago, flamegrilled said:

Can I assume this is the device's serial no?

Nope.  It is enabled and disabled flags.  This ain't my first rodeo 😛

Edited by Gnome
Link to comment
Share on other sites

11 hours ago, Gnome said:

BMS: I don't even own a BMS, so step 1 is either getting one or having someone else write the code.  But I would simply do the same as the Axpert software above.  Put the BMS on a web interface.  That way you can interact with it over HTTP as if it is on the web and people can just create HTML pages to interact with it.

For Pylontech Batteries (Comms to its BMS) it would be the same principle: You just send the "pwr" command and it replies with the info: SOC, charging/discharging amps, temperatures, etc.

Link to comment
Share on other sites

35 minutes ago, JacquesVDM said:

For Pylontech Batteries (Comms to its BMS) it would be the same principle: You just send the "pwr" command and it replies with the info: SOC, charging/discharging amps, temperatures, etc.

But does it have a CRC at the end, etc.

Ditto for the Victron BMS' that some people use, etc.

I'm hesitant to write software for something I can't test, but happy to help anyone that wants to make it happen (ie> help them code up something and they test it, etc.)

Link to comment
Share on other sites

54 minutes ago, Gnome said:

Ditto for the Victron BMS' that some people use, etc.

It's a part of the VE.Direct protocol which is used by solar chargers, battery monitors and the low end Phoenix inverters.

Link to comment
Share on other sites

3 minutes ago, plonkster said:

It's a part of the VE.Direct protocol which is used by solar chargers, battery monitors and the low end Phoenix inverters.

Standard is published (officially or unofficially)?  Or there is already good software for it that is free?

How are things on that side of the world?

Link to comment
Share on other sites

1 hour ago, Gnome said:

Standard is published (officially or unofficially)?  Or there is already good software for it that is free?

Officially published. In the whitepapers section on the website.

The ve-direct interface software is available as part of the official venus firmware, which you can also get for the Raspberry pi, or packaged as debian packages. It puts the values on dbus, so you need to learn how to use that 🙂

1 hour ago, Gnome said:

How are things on that side of the world?

Same old same old. Load shedding. Politicians doing their thing... 🙂

 

Link to comment
Share on other sites

22 minutes ago, flamegrilled said:

Battery Management System i.e. Balancer or Battery Monitoring System 

Well, I assumed (correctly as it seems to me) that he made a mistake and he is referring to the BMV product. That uses the VE.Direct protocol which indeed uses a similar checksum on each frame. The BMSes sold by Victron are for their own batteries, and they aren't full-on BMSes, they are more like interfaces to the existing signalling lines in the batteries. The VE.Bus BMS merely communicates that analog information onto VE.Bus (so the Multi/Quattro can react to it), the MiniBMS and the older SmartBMS are used in DC-only systems. You're not supposed to communicate directly with VE.Bus, and the other two... well no comms port...

🙂

 

Link to comment
Share on other sites

1 hour ago, Sidewinder said:

Same old same old. 4 hours Load shedding at a time. Politicians still doing nothing...

Just move to the Republic of Cape Town. We still have 2 hours of load shedding (we only move to 4-hour slots at stage 6), but of course we have more of them (we're off three times a day at the moment). Our politicians are however having their own mud fight, what with Mmusi leaving, Patricia kicked out, Helen on the side... 🙂

I do however like this new de Ruyter guy. Every few days BusinessTech (some semi-trustworthy news site) publishes something about his latest meeting with Scopa or some other parliamentary committee and they try to make it sound as if the guy took a grilling... but when you read the article you just cringe all the time about how bad the objections are from the ministers, and you feel like you want to cheer on the CEO who just sticks to his story.

Link to comment
Share on other sites

7 hours ago, Gnome said:

Well BMV product is a BMS correct?

No. It lacks some basic things a BMS should have... like disconnecting if a cell goes too high, or balancing cells. The BMV's function is to keep track of the SOC, which is something it has in common with some BMSes... though not all.

Link to comment
Share on other sites

This looks very promising for relaying and updating setting on the voltronic inverters:

https://github.com/ned-kelly/docker-voltronic-homeassistant

This uses mqtt topics to send the info to home assistant. I just need to find a way to get the PylonTech BMS info sent via mqtt to my home assistant.  Home assistant then allows you to build rules relating to time of day and state of charge.

image.thumb.png.ca479f120c50a10529610aed87fd3abc.png

 

By remotely setting values via MQTT you can implement many more complex forms of automation (triggered from Home Assistant) such as:

  • Changing the power mode to 'solar only' during the day, but then change back to 'grid mode charging' for your AGM or VLRA batteries in the evenings, but if it's raining (based on data from your weather station), set the charge mode to PCP02 (Charge based on 'Solar and Utility') so that the following day there's plenty of juice in your batteries...

  • Programatically set the charge & float voltages based on additional sensors (such as a Zigbee Temperature Sensor, or a DHT-22 + ESP8266) - This way if your battery box is too hot/cold you can dynamically adjust the voltage so that the batteries are not damaged...

  • Dynamically adjust the inverter's "solar power balance" and other configuration options to ensure that you get the most "bang for your buck" out of your setup...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...