-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Which USB to RS485 converter to use #2
Comments
Hi @stuartornum , The dip switches must all be down (the first dip switch sets the speed: 115200 vs 9600 Bd). Cheers and don't hesitate if you need more info ! |
PS: I don't know the pinout on the one you showed, but I'm pretty sure that it doesn't match the Pylontech RJ45 pinout ! You'd need a custom RJ45 patch cable (easy to crimp). It's easy to do with the one I showed above because you can just take a standard RJ45/ethernet cable, cut it in half and take the two strands you're interested in |
Awesome, thanks @Frankkkkk - I've ordered exactly the same from Amazon. I also asked the question to the seller regarding the pinout for the converter I have... no response yet. I'll keep you posted... thanks again! |
Hi @Frankkkkk , I managed to get my hands on the USB RS485 adapter you referenced above. Also, made a new cable from some CAT6 on to a RJ45 (568b). As per the Pylontech manual it says pin 7 and 8 are recommended for RS485, so converting that to 568b we get (Pin 7: brown/white, Pin 8: brown). I get the following when trying to run the library:
I also switched the brown/brown-white wires around on the RS485-to-USB adapter to see if I got a different output, I did...: `
Any thoughts? Thanks again for your help! Really appreciate it. (I'm using a Raspberry Pi 3b+) |
Hi, How are your dip switches set ? They should be all four off (down). Which pylontech modules have you got (model) ? It would be great to show the received raw frame by either adding a Cheers ! |
I suppose that your first wiring must be correct as the frame passed the checksum validation. Maybe your setup is a bit different than mine and we must change the frame protocol. If you can manage to dump the raw frame I can try to check the differences and patch the lib ;-) |
Hi @Frankkkkk , thanks for getting back to me.
Debug out from printing L169: Cheers |
Well, I managed to decode part of the frame:
But I specified the protocol manually: get_values_fmt = construct.Struct(
"NumberOfModules" / construct.Byte,
"Module" / construct.Array(1, construct.Struct(
"NumberOfCells" / construct.Int8ub,
"CellVoltages" / construct.Array(construct.this.NumberOfCells, ToVolt(construct.Int16sb)),
"NumberOfTemperatures" / construct.Int8ub,
"AverageBMSTemperature" / ToCelsius(construct.Int16sb),
"GroupedCellsTemperatures" / construct.Array(construct.this.NumberOfTemperatures - 1, ToCelsius(construct.Int16sb)),
"Current" / ToAmp(construct.Int16sb),
"Voltage" / ToVolt(construct.Int16ub),
"Power" / construct.Computed(construct.this.Current * construct.this.Voltage),
"RemainingCapacity" / DivideBy1000(construct.Int16ub),
"_undef1" / construct.Int8ub,
"TotalCapacity" / DivideBy1000(construct.Int16ub),
"CycleNumber" / construct.Int16ub,
)),
"foobar" / construct.Int8ub,
"foobar" / construct.Int8ub,
"foobar" / construct.Int8ub,
"foobar" / construct.Int8ub,
"foobar" / construct.Int8ub,
"foobar" / construct.Int8ub,
"Module2" / construct.Array(1, construct.Struct(
"NumberOfCells" / construct.Int8ub,
"CellVoltages" / construct.Array(construct.this.NumberOfCells, ToVolt(construct.Int16sb)),
"NumberOfTemperatures" / construct.Int8ub,
"AverageBMSTemperature" / ToCelsius(construct.Int16sb),
"GroupedCellsTemperatures" / construct.Array(construct.this.NumberOfTemperatures - 1, ToCelsius(construct.Int16sb)),
"Current" / ToAmp(construct.Int16sb),
"Voltage" / ToVolt(construct.Int16ub),
"Power" / construct.Computed(construct.this.Current * construct.this.Voltage),
"RemainingCapacity" / DivideBy1000(construct.Int16ub),
"_undef1" / construct.Int8ub,
"TotalCapacity" / DivideBy1000(construct.Int16ub),
"CycleNumber" / construct.Int16ub,
)),
"greedy" / construct.GreedyRange(construct.Byte),
"TotalPower" / construct.Computed(lambda this: sum([x.Power for x in this.Module])),
"StateOfCharge" / construct.Computed(lambda this: sum([x.RemainingCapacity for x in this.Module]) / sum([x.TotalCapacity for x in this.Module])),
) There seems to be some extra bytes sent after the first module (written as
Interesting though Cheers ! |
And the code if you want to try manually: def get_values(self):
#self.send_cmd(2, 0x42, b'FF')
#f = self.read_frame()
rf = b'~2002460010F011020F0CCD0CCE0CCC0CCE0CCB0CCC0CCD0CCC0CCD0CCB0CCC0CCD0CCD0CCE0CCC050BE10BCD0BCD0BD70BCDFFC3BFFDFFFF04FFFF0234007F300121100F0CCA0CCA0CCB0CCC0CCA0CCC0CCB0CCB0CCB0CCB0CCB0CCA0CCC0CCC0CCB050BEB0BCD0BCD0BCD0BC3FFD1BFE5FFFF04FFFF0292005FB400C350C4A7\r'
ff = self._decode_hw_frame(raw_frame=rf)
f = self._decode_frame(ff)
print(f)
print(f.info[1:])
# infoflag = f.info[0]
d = self.get_values_fmt.parse(f.info[1:])
return d |
Hi @Frankkkkk , Apologies for the delay in getting back to you:
Thanks for your help on this, it's really is appreciated |
I believe I've switched the US2000 to become the master, however, the documentation says to always use the US3000 as the primary when you have a mixture of US2000's/US3000's. Here is the output:
I'm not sure how much I believe some of the numbers, "StateOfCharge" for example...? |
Hi, I suppose we could patch the decoding to handle US3000 as primary modules.. It's strange though. Sadly I don't have one so I can't really test this edge case. Maybe we could add a warning in the readme as a workaround. As for the If that's okay with you, I'll just add a warning for this edge case in the readme, and maybe in the future we can fix the US3000-US2000 bug ? Cheers |
I would like to assist on this, what would be the preferred next steps. I have both US2000 and US3000 with the 3000 as the primary right now |
Hello,
If I insert a Do you have any idea what could be wrong? |
Without any change now I get the following result as raw_data: What does the header mean or how can I remove it? |
Hi @michaelhutter Indeed it is strange as part of the second frame looks valid enough. Is your cable shielded or near high-enough EM radiations ? Did you try changing your USB-rs485 converter ? Cheers |
The first adapter which I bought did not work at all. The second adapter is working but gives these extra bytes in the beginning. |
I am still struggling with my Pylontech US3000C. If I run @Frankkkkk Can you explain what is the difference between |
@michaelhutter i not python guy but I want to create pylontech emulator and investigate this scripts and pylon protocol description. Get_values and get_values_single is the same command but values hardcoded address as 255. I didn't find this address descruption in pylontech documentation. 2 is number of battery if we have more than one pattery. 52 => 7E 30 30 35 32 34 36 34 46 30 30 30 30 46 44 39 35 0D Could you execute these requests with HTerm 9https://www.der-hammer.info/pages/terminal.html) on real battery? Just copy 7E .. OD an send to battery? |
Hello, unsure if I should make a new issue. I tried using an ethernet - USB adapter and the unit (US3000c) just beeps like crazy. So probably it's the wrong adapter? Thanks! |
Hi @EmCeBeh , yes please create a new issue. Unless I'm mistaken, even though they both use the same form factor (RJ45), the protocols are completely different. You need an RS485 adapter, and not ethernet ! Cheers ! |
Hi @Frankkkkk
Would you mind letting us know what hardware you are using to communicate with the Pylontech batteries. For example, which USB to RS485 cable you are using, which OS/Hardware etc.
I'm struggling with a Raspberry Pi 3B+ and USB to RS485 adapter (https://www.amazon.com/gp/product/B08RDZVP49)
Cheers!
The text was updated successfully, but these errors were encountered: