Author Topic: Reading Magnum Energy RS485 infromation  (Read 1020 times)

CharlesG

  • Newby
  • *
  • Posts: 12
Reading Magnum Energy RS485 infromation
« on: November 04, 2019, 04:19:22 PM »
I have just released a new Python package that supports reading all know packets of Magnum Energy data.

https://pypi.org/project/pymagnum/

Please let me know what you think.

ClassicCrazy

  • Hero Member
  • *****
  • Posts: 2670
Re: Reading Magnum Energy RS485 infromation
« Reply #1 on: November 05, 2019, 12:53:34 PM »
I don't have any Magnum equipment but thanks for your efforts - sure those who do will appreciate it.

Larry
system one
Classic 150 , 5s4p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system two
Classic 150 ,5s 135 watt Kyocero , 16s Calb 100AH LiFePO4 , Outback VFX 3648 inverter
system three
Midnite KID MPPT 24 DC in to  12 volt AGM batterie

Watt_

  • Newby
  • *
  • Posts: 35
Re: Reading Magnum Energy RS485 infromation
« Reply #2 on: November 15, 2019, 12:36:23 PM »
Hello Charles

Sad that life gets in the way of projects.  >:(
I look forward to looking into your project here, further.

I purchased a magnum charge controller but,it is still sitting under now what can be described as more projects...

I have opened and reviewed you python code, If you don't mind, where did you come up with the list of device identifiers,  thanks.
« Last Edit: November 18, 2019, 03:04:09 AM by Watt_ »

Watt_

  • Newby
  • *
  • Posts: 35
Re: Reading Magnum Energy RS485 infromation
« Reply #3 on: November 18, 2019, 03:01:42 AM »
root@pi3bplus:/home/pi# pip3 install pymagnum-1.0.0.tar.gz
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Processing ./pymagnum-1.0.0.tar.gz
Requirement already satisfied: pyserial in /usr/lib/python3/dist-packages (from pymagnum==1.0.0) (3.2.1)
Building wheels for collected packages: pymagnum
  Building wheel for pymagnum (setup.py) ... done
  Created wheel for pymagnum: filename=pymagnum-1.0.0-cp35-none-any.whl size=15505 sha256=ecad9ef85ff09efee9d41ff5216bf898b1ab5b567f5f5fe5d137cac2c3b2d2fe  Stored in directory: /root/.cache/pip/wheels/88/b3/66/732629d2cf6966399bfb55a5a1e52661ba15f5548cf51c44fb
Successfully built pymagnum
Installing collected packages: pymagnum
  Found existing installation: pymagnum 1.0.0
    Uninstalling pymagnum-1.0.0:
      Successfully uninstalled pymagnum-1.0.0
Successfully installed pymagnum-1.0.0
root@pi3bplus:/home/pi#

root@pi3bplus:/home/pi# python3 -m serial.tools.list_ports
bash: python3 -m serial.tools.list_ports: command not found

root@pi3bplus:/home/pi# python3 -m magnum.tools.magtest -d /dev/ttyUSB0
bash: python3 -m magnum.tools.magtest -d /dev/ttyUSB0: No such file or directory
root@pi3bplus:/home/pi#



If I mess about a bit, i can get data from the magnum setup but without knowing your code, I can't tell if it is reliable.

Options:cleanpackets=True, device='/dev/ttyUSB0', packets=50, timeout=0.001
Length: 5 UNKNOWN   =>FC000075BC
Length: 6 UNKNOWN   =>01013316221E
Length: 5 UNKNOWN   =>7301040002
Length: 4 UNKNOWN   =>5900FF00
Length: 6 UNKNOWN   =>00DA8A643C20
Length: 5 UNKNOWN   =>0000D2BE88
Length: 6 UNKNOWN   =>0014005A0078
Length: 3 UNKNOWN   =>0478A2
Length: 3 UNKNOWN   =>000001
Length: 6 UNKNOWN   =>FB000079BB01
Length: 6 UNKNOWN   =>013316221E73
Length: 5 UNKNOWN   =>0100000259
Length: 3 UNKNOWN   =>00FF00
Length:20 UNKNOWN   =>00DA8A643C200000D2BE880014602800200A00A3
Length: 2 RTR_91    =>9120
Length:13 UNKNOWN   =>000001FB000079BB0100331622
Length: 5 UNKNOWN   =>1E73010000
Length: 4 UNKNOWN   =>025900FE
Length: 4 UNKNOWN   =>0000DA8A
Length: 6 UNKNOWN   =>643C200000D2
Length: 5 UNKNOWN   =>BE8800143C
Length: 6 UNKNOWN   =>3C00200000A4
Length: 4 UNKNOWN   =>000001FC
Length: 5 UNKNOWN   =>000079BB01
Length: 6 UNKNOWN   =>003316221E73
Packets:25 of 50 with 24 UNKNOWN, in 0.75 seconds

And the error i got...

/usr/bin/python3: Error while finding module specification for 'magnum/tools/magtest.py' (AttributeError: module 'magnum/tools/magtest' has no attribute '__path__')

Thank you
« Last Edit: November 18, 2019, 03:04:52 AM by Watt_ »

CharlesG

  • Newby
  • *
  • Posts: 12
Re: Reading Magnum Energy RS485 infromation
« Reply #4 on: November 18, 2019, 09:28:16 AM »
Re Reply #2

I'm not exactly sure of "list of devices". I have a copy of Magnum Energy's document, from 2013, describing the packets they send. It covers many many different packets. I made up names for each packet and one for each device. The choice was subjective.

If you mean the device names for each type of  inverter model, I got those from the documentation.

CharlesG

  • Newby
  • *
  • Posts: 12
Re: Reading Magnum Energy RS485 infromation
« Reply #5 on: November 18, 2019, 09:40:18 AM »
Re reply #3

I have posted more details on GitHub
https://github.com/CharlesGodwin/pymagnum/issues/3

malkierian

  • Newby
  • *
  • Posts: 12
Re: Reading Magnum Energy RS485 infromation
« Reply #6 on: March 27, 2020, 06:56:53 PM »
Hey, Charles, just discovered this after wanting to set up some network monitoring of my magnums (I have two inverters connected to an ARTR). My first question is, does this work only on the Raspberry? I wanted to test it on my laptop before I bought a Pi to run it, but I don't know if I can even test it without having a Pi plugged in. If it does work on Windows, I ran the python port test and came up with only COM3. But it says there doesn't seem to be a network. Does that just mean I don't have the right wires connected?

CharlesG

  • Newby
  • *
  • Posts: 12
Re: Reading Magnum Energy RS485 infromation
« Reply #7 on: March 27, 2020, 09:29:38 PM »
Thanks for your interest. The short answer is the software runs on a Windows machine. I do all my development and most testing on a Windows platform.

The long answer - it depends. You must be sure to install Python 3 on your windows machine. https://www.python.org/downloads/windows/

Once python 3 is installed you just need to follow the instructions in the documentation. https://pymagnum.readthedocs.io/en/latest/ The instructions are Pi focused but that is the usual user. Wherever the documents refer to python3 or pip3, just use python and pip

You didn't specify in your query if you have a RS-485 USB dongle. You will need to buy the RS485 USB dongle.

The testing part will respond with COMx answers on a Windows machine. Use the result in place of the documented linux type device names. For example
Code: [Select]
magtest -d com3
If you get nothing, double check your wiring. On ARTR router stick to P5 and P6 to connect. If you get giberish, try reversing the wires on the dongle.

I have an unanswered question about multiple inverters that is described here.  https://github.com/CharlesGodwin/pymagnum/issues/5

When you get your system working I'd be interested in your results with the test I outlined in the issue.

You may need to use two dongles. I just don't know until I get test results.

Thanks

My email address is included in the Feedback section of the documentation.

ner0tic

  • Newby
  • *
  • Posts: 5
Re: Reading Magnum Energy RS485 infromation
« Reply #8 on: March 31, 2020, 07:41:26 AM »
Hey, Charles, just discovered this after wanting to set up some network monitoring of my magnums (I have two inverters connected to an ARTR). My first question is, does this work only on the Raspberry? I wanted to test it on my laptop before I bought a Pi to run it, but I don't know if I can even test it without having a Pi plugged in. If it does work on Windows, I ran the python port test and came up with only COM3. But it says there doesn't seem to be a network. Does that just mean I don't have the right wires connected?
I'm currently running Charles' application on a rPi3b flawlessly.  I used a cheap rs485 to usb adapter wire to an old phone jack and a rj11 plugged into my inverter.

I also run Graham's application on the same pi to talk to my classic 150. 

I have more recently "hacked" the 2 apps together into a single python script to transmit all the data from the two sources to my home assistant (homeassistant.io) running on a rPi4 via MQTT.

example of the mqtt messages received:
Code: [Select]
Message 26 received on powerpi/classic at 7:47 AM:
{
    "datetime": "2020-03-31T07:47:45-04:00",
    "device": "Classic",
    "data": {
        "pcb_revision": 4,
        "unit_type": 150,
        "build_year": 2015,
        "build_month": 8,
        "build_day": 17,
        "info_flag_bits_3": 10,
        "ignore": null,
        "mac_1": 109,
        "mac_0": 112,
        "mac_3": 15,
        "mac_2": 0,
        "mac_5": 96,
        "mac_4": 29,
        "ignore_2": null,
        "unit_id": 1047461849,
        "status_roll": 36864,
        "restart_timer_ms": 1,
        "avg_battery_voltage": 56.1,
        "avg_pv_voltage": 57.7,
        "avg_battery_current": 0.8,
        "avg_energy_today": 0,
        "avg_power": 44,
        "charge_stage": 4,
        "charge_state": 4,
        "avg_pv_current": 0.5,
        "last_voc": 98.4,
        "highest_pv_voltage_seen": 1460,
        "match_point_shadow": 0,
        "amphours_today": 0,
        "lifetime_energy": 4955.3,
        "lifetime_amphours": 90318,
        "info_flags_bits": -1308610556,
        "battery_temperature": 13.4,
        "fet_temperature": 22.4,
        "pcb_temperature": 29.9,
        "no_power_timer": 0,
        "log_interval": 300,
        "modbus_port_register": 502,
        "float_time_today": 0,
        "absorb_time": 14400,
        "reserved_1": 8,
        "pwm_readonly": 1307,
        "reason_for_reset": 4,
        "equalize_time": 7200,
        "wbjr_cmd_s": 53,
        "wbjr_raw_current": 0,
        "skip": null,
        "wbjr_pos_amphour": 0,
        "wbjr_neg_amphour": 0,
        "wbjr_net_amphour": 0,
        "wbjr_battery_current": 0,
        "wbjr_crc": 0,
        "shunt_temperature": -50,
        "soc": 100,
        "skip2": null,
        "remaining_amphours": 430,
        "skip3": null,
        "total_amphours": 430,
        "mppt_mode": 3,
        "aux1_and_2_function": 3853,
        "name_0": 76,
        "name_1": 67,
        "name_2": 83,
        "name_3": 65,
        "name_4": 73,
        "name_5": 83,
        "name_6": 0,
        "name_7": 67,
        "temp_regulated_battery_target_voltage": 59.1,
        "nominal_battery_voltage": 48,
        "ending_amps": 0,
        "reason_for_resting": 1,
        "app_rev": 2056,
        "net_rev": 2045
    }
}
QoS: 0 - Retain: false
Message 25 received on powerpi/bmk at 7:47 AM:
{
    "datetime": "2020-03-31T07:47:45-04:00",
    "device": "BMK",
    "data": {
        "revision": "1.0",
        "soc": 94,
        "vdc": 56.04,
        "adc": 19.6,
        "vmin": 43.02,
        "vmax": 62.47,
        "amph": -31,
        "amphtrip": 6553.5,
        "amphout": 52300,
        "Fault": 1,
        "Fault_Text": "Normal"
    }
}
QoS: 0 - Retain: false
Message 24 received on powerpi/inverter at 7:47 AM:
{
    "datetime": "2020-03-31T07:47:45-04:00",
    "device": "INVERTER",
    "data": {
        "revision": "5.1",
        "mode": 8,
        "mode_text": "BULK",
        "fault": 0,
        "fault_text": "None",
        "vdc": 56,
        "adc": 20,
        "VACout": 116,
        "VACin": 180,
        "invled": 1,
        "invled_text": "On",
        "chgled": 1,
        "chgled_text": "On",
        "bat": 17,
        "tfmr": 39,
        "fet": 28,
        "model": 115,
        "model_text": "MS4448PAE",
        "stackmode": 0,
        "stackmode_text": "Stand Alone",
        "AACin": 11,
        "AACout": 9,
        "Hz": 60.1
    }
}
« Last Edit: March 31, 2020, 07:48:43 AM by ner0tic »

CharlesG

  • Newby
  • *
  • Posts: 12
Re: Reading Magnum Energy RS485 infromation
« Reply #9 on: March 31, 2020, 08:16:46 AM »
Fabulous. I'm glad it is useful for you.

ClassicCrazy

  • Hero Member
  • *****
  • Posts: 2670
Re: Reading Magnum Energy RS485 infromation
« Reply #10 on: March 31, 2020, 12:42:57 PM »
You might be interested in this DIY github page for Classic stuff .
The MQTT from raspberry pi to classic monitor just got a lot better .
https://github.com/ClassicDIY

Larry
system one
Classic 150 , 5s4p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system two
Classic 150 ,5s 135 watt Kyocero , 16s Calb 100AH LiFePO4 , Outback VFX 3648 inverter
system three
Midnite KID MPPT 24 DC in to  12 volt AGM batterie