News:

To visit MidNite Solar click this link www.midnitesolar.com

Main Menu

modbus tcp data

Started by ner0tic, February 01, 2020, 08:20:15 AM

Previous topic - Next topic

ner0tic

Hello all, I am currently trying to read registers from my classic 150 via tcp into home assistant.  I seem to only be getting some data back.
For example,
I can read the current battery voltage, but I can not seem to read the PV voltage.
I have a sensor set up to read register 4115 and get my current battery voltage correctly
but when I set up a similar sensor to read register 4116 i only receive 0 (not unknown/undefned etc) see the attached image.

Grahams's app displays the proper data so I'm at a loss. I was just looking to get the basic data sensors set up at this stage.

here is my config for the sensors, in yaml format in their own package.

      # Battery Voltage
      - name: classic_battery_voltage
        hub: !secret midniteClassic_name
        register: 4114 #4115
        scale: 0.10
      # PV voltage
      - name: classic_pv_voltage
        hub: !secret midniteClassic_name
        register: 4115 #4116
        unit_of_measurement: V
        data_type: float
        scale: 0.10


I'm using a spec dated may 2013 as my reference.  I feel like I'm just missing something small and stupid (my usual M.O.)

Graham

Here is the code snip from my android app, the offsets are +1 of the register # so register[14] is 4115

                Register[] registers = modbusMaster.readMultipleRegisters(4100, 44);
                if (registers != null && registers.length == 44) {
                    readings.set(RegisterName.BatCurrent, registers[16].getValue() / 10.0f);
                    readings.set(RegisterName.Power, (float) registers[18].getValue());
                    readings.set(RegisterName.BatVoltage, registers[14].getValue() / 10.0f);
                    readings.set(RegisterName.PVVoltage, registers[15].getValue() / 10.0f);
                    readings.set(RegisterName.PVCurrent, registers[20].getValue() / 10.0f);
                    readings.set(RegisterName.EnergyToday, registers[17].getValue() / 10.0f);
                    readings.set(RegisterName.TotalEnergy, ((registers[26].getValue() << 16) + registers[25].getValue()) / 10.0f);
                    readings.set(RegisterName.ChargeState, MSBFor(registers[19].getValue()));
                    readings.set(RegisterName.InfoFlagsBits, ((registers[30].getValue() << 16) + registers[29].getValue()));

                    readings.set(RegisterName.BatTemperature, (short)registers[31].getValue() / 10.0f);
                    readings.set(RegisterName.FETTemperature, (short)registers[32].getValue() / 10.0f);
                    readings.set(RegisterName.PCBTemperature, (short)registers[33].getValue() / 10.0f);
                    readings.set(RegisterName.FloatTimeTodaySeconds, (short)registers[37].getValue());
                    readings.set(RegisterName.AbsorbTime, (short)registers[38].getValue());
                    readings.set(RegisterName.EqualizeTime, (short)registers[42].getValue());
                    int infoFlag = registers[29].getValue();
                    readings.set(RegisterName.Aux1, (infoFlag & 0x4000) != 0);
                    readings.set(RegisterName.Aux2, (infoFlag & 0x8000) != 0);
                } else {

you could also look at my ClassicMQTT project on github at https://github.com/graham22/ClassicMQTT
this publishes the classic modbus data to MQTT which can then be subscribed by Home Assistant...

Graham.
Off-Grid Island cottage, Lac Simon QC Canada
370 Ahrs @ 24V (4 8L16 batteries)
4 x 250watt panels on dual axis trackers http://tinyurl.com/hfpkgr5
Classic 150, Whizbang Jr.
Android Monitor: http://tinyurl.com/lomzq3s

mcsarge

You appear to be trying to read the PV volts as a float, it is not a float, but a number you divide by 10 that results in a float - just like the Bat Voltage.


      # Battery Voltage
      - name: classic_battery_voltage
        hub: !secret midniteClassic_name
        register: 4114 #4115
        scale: 0.10
      # PV voltage
      - name: classic_pv_voltage
        hub: !secret midniteClassic_name
        register: 4115 #4116
        unit_of_measurement: V
        data_type: float <<<<<<<<<<<<<Not a float
        scale: 0.10



Quote from: ner0tic on February 01, 2020, 08:20:15 AM
Hello all, I am currently trying to read registers from my classic 150 via tcp into home assistant.  I seem to only be getting some data back.
For example,
I can read the current battery voltage, but I can not seem to read the PV voltage.
I have a sensor set up to read register 4115 and get my current battery voltage correctly
but when I set up a similar sensor to read register 4116 i only receive 0 (not unknown/undefned etc) see the attached image.

Grahams's app displays the proper data so I'm at a loss. I was just looking to get the basic data sensors set up at this stage.

here is my config for the sensors, in yaml format in their own package.

      # Battery Voltage
      - name: classic_battery_voltage
        hub: !secret midniteClassic_name
        register: 4114 #4115
        scale: 0.10
      # PV voltage
      - name: classic_pv_voltage
        hub: !secret midniteClassic_name
        register: 4115 #4116
        unit_of_measurement: V
        data_type: float
        scale: 0.10


I'm using a spec dated may 2013 as my reference.  I feel like I'm just missing something small and stupid (my usual M.O.)
Off Grid Island in Ontario Canada (Beaverstone Bay)
Primary: Classic 150 + wbjr; 3s2p HES 270watt
Winter: SolarBoost 50 MPPT (into wbjr); 2 x Sharp NE-80EJEA 80watt
Pack: 4s2p ROLLS S6-460AGM 6V for 24V pack
Inverter/Charger: Trace DR2424
Call Sign: KG4EUF