Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

Tesla Wall Connector load sharing protocol

This site may earn commission on affiliate links.
Hmm, maybe. Easiest way to tell is to get another HPWC and see if those messages come across...we see them every 10 seconds or so.

Well, anyone who uses TWCManager on a newer TWC should see those messages printed as UNKNOWN MESSAGE and can report here. The other possibility is they are turned on by some flag I'm not using, though I don't know why my TWC set to master wouldn't have broadcast that flag when TWCManager pretends to be a slave.
 
@CDragon
More than half of your code is actually comments ! Thanks for the detailed explanation.

(Btw, I suppose your last function was very useful as a debugging tool. ;-) )

Tee hee. I actually never used the last function for anything but found it hilarious to imply it once had some purpose. There's even a second innuendo in the comment of that function... err... I mean sub.

I added more comments than usual to aid others in understanding, but I know I comment code more than most others because if I don't I'll have a hard time understanding it myself when I come back months later. Generally I comment anything that could be confusing/complex and use longer descriptive variable and function names that make sections understandable without needing comments.

Sadly, there is a big problem... The car was reporting state for 01 hours into the night but when I woke up, despite being told it has 3+ solar amps to charge with, it's gone into state 03 (won't charge). The debug output of when it went from 01 to 03 scrolled off the end of the buffer so I don't know wtf. I've updated the git repository to only output once-per-second heartbeat debug output when the output is different from the last second, or if it's been 10 mins since last output.

Same symptoms as if slave TMC lost connection to TMCManager, but I assume it did not. I woke the car, it said "Starting to charge..." then "Charging stopped" and "Start charging" button does nothing. It's been in this state at least an hour 15 mins (as far back as the log goes) so I'm dubious giving it more time will make it recover, but I'll keep waiting.

MITE46, any ideas how to get the car out of state 03 without re-plugging it?

Wait, idea just struck... If the car is giving up on the charger after some timeout (guessing 4 hours?) then the charger has to tease it with power for a couple minutes before that timeout hits. Just have to figure out what the timing is.

Piece of the log (0.25/3.93A means car is allowed 3.93A but only using 0.25A and ': 03 ' is the state 03 reported by slave TWC connected to the car):
Solar generating 996wH so limit car charging to 4.15A.
08:42:11: S 032e 0.25/3.93A: 03 0189 0019 0000 M: 05 019f 0000 0000
08:42:12: S 032e 0.25/4.15A: 05 019f 0019 0000 M: 00 0000 0000 0000
08:42:13: S 032e 0.25/4.15A: 03 019f 0019 0000 M: 00 0000 0000 0000
Solar generating 1029wH so limit car charging to 4.28A.
08:43:12: S 032e 0.25/4.15A: 03 019f 0019 0000 M: 05 01ac 0000 0000
08:43:13: S 032e 0.25/4.28A: 05 01ac 0019 0000 M: 00 0000 0000 0000
08:43:14: S 032e 0.25/4.28A: 03 01ac 0019 0000 M: 00 0000 0000 0000
Solar generating 1089wH so limit car charging to 4.53A.
08:44:13: S 032e 0.25/4.28A: 03 01ac 0019 0000 M: 05 01c5 0000 0000
08:44:14: S 032e 0.25/4.53A: 05 01c5 0019 0000 M: 00 0000 0000 0000
08:44:15: S 032e 0.25/4.53A: 03 01c5 0019 0000 M: 00 0000 0000 0000
Solar generating 1156wH so limit car charging to 4.81A.
08:45:14: S 032e 0.25/4.53A: 03 01c5 0019 0000 M: 05 01e1 0000 0000
08:45:15: S 032e 0.25/4.81A: 05 01e1 0019 0000 M: 00 0000 0000 0000
08:45:16: S 032e 0.25/4.81A: 03 01e1 0019 0000 M: 00 0000 0000 0000
 
Last edited:
It would be great if someone can make a video showcasing this...projects like these make me wanna go back to CS...I guess its never too late to learn something new! But a video with step by step instructions would be very very helpful

I know a lot of people love those videos! Personally, I hate watching someone ramble on and generally gloss over or forget a lot of important details, and you have to sit through 10+ mins to find all those details spread through the video and take notes on them or keep re-watching it... Drives me crazy. Of course, videos can be great as an overview or introduction to a topic to get people excited. Either way, I hate being on camera so maybe someone else can do that.

However, I will likely write a guide on how to set this up, if I can get it fully working myself. Until then, check out my guide on supplying 100% of your home's energy with solar power.
 
  • Like
Reactions: K-MTG
I know a lot of people love those videos! Personally, I hate watching someone ramble on and generally gloss over or forget a lot of important details, and you have to sit through 10+ mins to find all those details spread through the video and take notes on them or keep re-watching it... Drives me crazy. Of course, videos can be great as an overview or introduction to a topic to get people excited. Either way, I hate being on camera so maybe someone else can do that.

However, I will likely write a guide on how to set this up, if I can get it fully working myself. Until then, check out my guide on supplying 100% of your home's energy with solar power.

Looking forward to it
 
This is great! And great comments!

It has been reported that if two Tesla’s are plugged in, the one with the lowest charge will charge at a higher rate. I don’t see how that would be possible?

Thanks!

I've seen that report and it's definitely not possible for the master TWC to allocate more power to the car with lower battery percentage, at least with the protocol my TWC is using. Master TWC is not given any info about a slave car's battery percentage. MITE46 says I'm not getting a message that his TWCs are sending, so it's possible that newer TWCs send more info that might make the charge rate by battery percentage feature possible.

Another possibility is if you charge to 100% battery, the car starts limiting the power it will take when near 100% full. At that point, the slave TWC the car is connected to will report fewer amps being drawn and the master would logically allocate those extra amps to another car. I would only expect that situation when a car is pretty close to 100% as I don't think it limits power to under 40A much before 100% charge (I could be wrong).
 
Thanks!

I've seen that report and it's definitely not possible for the master TWC to allocate more power to the car with lower battery percentage, at least with the protocol my TWC is using. Master TWC is not given any info about a slave car's battery percentage. MITE46 says I'm not getting a message that his TWCs are sending, so it's possible that newer TWCs send more info that might make the charge rate by battery percentage feature possible.

Another possibility is if you charge to 100% battery, the car starts limiting the power it will take when near 100% full. At that point, the slave TWC the car is connected to will report fewer amps being drawn and the master would logically allocate those extra amps to another car. I would only expect that situation when a car is pretty close to 100% as I don't think it limits power to under 40A much before 100% charge (I could be wrong).

First post in this thread
- New Power Wall Connectors - "sharing" observation

I know I have read others as well, cannot find at the moment. It is mentioned in post number 2 of this current thread.
 
Last edited:

A guy in one of those threads claims his two cars are timed to finish charging at the same time. His install was apparently completed Sept 28 vs my Aug 23 order... If true, I missed the new version by a month. Blarg.

But the guy in your other post is claiming his TWCs purchased May 2016 or earlier have the feature as well, so... wha?

I noticed today that having the car set to charge to 130RM, somewhere around 110RM it started limiting charge current to 5.3A despite the charger protocol allowing 10A. So it seems like the car itself starts scaling back power farther away from target charge than I would expect. Maybe people are seeing that effect and interpreting it as the TWC doing the scaling? I think we need more data points and people posting precise experiments. Or people sending me logs captured from the RS485 pins would be even more difinitive.

You have motivated me to buy another Raspberry Pi.

If you're going to order a Pi, make sure it's a Pi Zero W. I watched their stock go from 92 this morning, 62 after lunch when I ordered, and 44 now... Popular! With this case it's fairly well insulated and only 2.9" x 1.5" x 0.5" (74.0mm x 39.0mm x 13.0mm). Also got this USB cable for the rs485 adapter and this power supply. MicroSD and MiniHDMI to HDMI are optional depending if you have them already.

They also coaxed me to impulse buy this USB power meter. I have other ways of measuring power but that just looks so convenient and pretty cheap. If the Pi Zero + rs485 draws few enough amps, maybe I'll consider trying to vampire it off some internal 5V power supply in the TWC... Gut still says that's a bad idea.
 
Last edited:
  • Helpful
Reactions: brkaus
I noticed today that having the car set to charge to 130RM, somewhere around 110RM it started limiting charge current to 5.3A despite the charger protocol allowing 10A. So it seems like the car itself starts scaling back power farther away from target charge than I would expect.

This is wrong. The 5A limit seems to be something the car does in response to something about the power scaling of the charger. Maybe it thinks a charger that offers so little power isn't safe so it pulls a minimum? People here report seeing the same problem. It seems to require setting the limit up to 21A to get it out of the 5A limit mode.

Few mins later I went back to tracking solar once per minute and within a couple minutes of solar waffling at various values between 12-13A, car went back to 5A limit mode.

Back to 21A for a bit, then tried a stable 13A and car seems fine there. More tests seem to show that the car doesn't like being asked to charge at fractional amps and will drop to 5A. If I have the charger stick to even, whole amps (12.00A, 13.00A, etc) it's working so far. Nope, back to 5A after a few minutes of shifting limits between 8A and 12A.

I also found yesterday that a couple hours of tracking solar below 5A caused the car to say "screw it" and refuse to charge until re-plugged.

I did keep the car from going into "screw it" mode 03 overnight by supplying 6A for 60 seconds every hour and it was charging fine (at 5A limit) this morning. At the same time, it lost at least 4RM overnight which means it was wasting power keeping the car waiting for power that rarely came. I could hear a soft fan running under the hood that I don't think is usually on. the screens did not light whenever the 6A was supplied and I could actually hear nothing change when it happened, not even the click (charge port locking?) that usually heralds a start of charging.

Also discovered that the car remembers the last hard limit I set on the UI during testing. I'd picked 17A at some point a few days ago and it wouldn't go over that value even when the TWC said 40A was fine. This is despite that same UI element showing the TWC's power limit at lower values. Interesting.

Anyway, still seems to be a lot of weird details to learn about how the car behaves.
 
Last edited:
  • Informative
  • Like
Reactions: brkaus and spottyq
@CDragon I think the J1772 spec, which Tesla charging is based on, specifies that the minimum pilot signal is 6A. So that may be why you are having problems when you set the level to something lower than that. (I think the Tesla master WC reserves a minimum of 6A for any car plugged in even if it isn't charging.)
Indeed, 6A is the minimum with J1772. Range is 6A-80A
 
  • Informative
Reactions: MP3Mike
Problems may be solved.

I discovered you can shut off charging by sending data bytes 05 00 00 00 00 00 from master. The relay in the TWC clicks, green lights stop cycling, and the car goes to sleep fully without the little fan running under the hood. Car reports state 03 which is that state I couldn't get out of before, but in this case, you can start charging again later as normal but it won't begin till the next time the car partly wakes to see there's power available. That seems to happen roughly every 15 minutes.

I checked out the J1772 protocol. It allows 6A to 51A in 0.6A increments and 55A to 80A in 2.5A increments. The TWC obviously has to translate whatever amp limits you give it to that protocol so those are the true level of control we have over power levels. So the only solution to preventing errors at low amp values may be to stop charging when your green energy source falls below 6A. That's what I'm doing for now, though I plan to test 5A as well because the car's UI allows you to go down to 5A.

The issue with the car falling back to 5A when changing amp limits seems to be that the car doesn't like when you raise amp limits. So I can set a 15A limit, change to 14, 13, 12, etc and the car is fine. As soon as I go from 12 to 13, the car drops to 5A. If I increase to 21A for 10 seconds, then go down to 13A, car is happy to go to 13A. Increasing to 20A or even 20.9A is not enough. What if I go from 21 to 22 or to 23? Not tested yet, though my solar panels never get near that power level. This behavior seems really bizarre but maybe it's a protection against some common failure mode of chargers that causes their reported amp limit to creep up gradually? Just wild guessing.

With these two fixes implemented, I think everything is working as desired. I'll need to see it running for a few days to be sure and then I'll update the git project.
 
Last edited:
@CDragon Not sure if it is exactly the same issue but recently users with a HPWC and a Maxem load balancer (they also uses the rs485 protocol) have reported similar behavior: when then Maxem raises the amps the car stays at 6A.
Could be a problem introduced after a certain software update.
(in Dutch, but you seem to master that language ;)):
Laadschnelheid blijft hangen bij smartcharging
 
@CDragon Not sure if it is exactly the same issue but recently users with a HPWC and a Maxem load balancer (they also uses the rs485 protocol) have reported similar behavior: when then Maxem raises the amps the car stays at 6A.
Could be a problem introduced after a certain software update.
(in Dutch, but you seem to master that language ;)):
Laadschnelheid blijft hangen bij smartcharging

Definitely sounds like the same problem. It's funny it sounds like a Tesla firmware change caused this problem less than a month before I started this project. It's possible they'll fix it in a future firmware update.

I tried rounding my amp limits to the nearest 0.6A value defined by the J1772 protocol and found that when I lowered amp limit from 12.60A to 12.0A, the car dropped to 6A use again. So apparently it's not just caused by raising amp limit but can be caused by lowering between certain non-whole values. However, as long as I stick to whole amps, I've not seen the drop to 6A problem as the solar system bounced randomly between 6 and 19A due to clouds (this is with my fix of jumping to 21A for 10s whenever amps need to raise).

I've now begun tests on values above 21A and it seems there's another problem. I have the amp limit going up 1A each minute and the car will not rise above using 21A even up to a 45A setting. I tried spiking to 80A for 10s, then 81A for 10s and it won't go above 21A. Tried 6A 10s then 23A, no good.

Left TWC at 40A and unlocked the car and used the UI to raise 21A to 40A and that worked. Note that the car UI usually changes to match the value TWC is sending it, but in this case it did not.

It still requires spiking to 21A or higher when increasing amp limit from lower to higher values between 6A and 20A, but every value 22A and up is working fine.

Now I can't get 22A+ values to break again. I've tried:
  • Hold 6A 10s, 23A. Also tried starting at 7A, 10A, 15A.
  • Stop charging 10s, resume 23A or resume 6A then 23A.
  • Stop charging. Unplug. Start at 23A and go up 1A per 30s.
  • Stop charging. Unplug. Start at 6A for a minute, then 23A and go up 1A per 30s.
  • Go from 10A to 15A which makes the car fall back to 6A. Then 23A and up still works.
  • Go from 24A to 12.60A to 12A. Car drops to using 6A. Back to 24A, car uses 24A.
  • 5A or 4A limit for a minute, then 24A. Car uses 24A.
So, I've run out of ideas for now (other than leave the car not charging overnight and see if it happens the next day). I'm sure the last time I touched the UI I set it to 40A and never lowered it.
 
Last edited:
  • Like
Reactions: spottyq
I checked out the J1772 protocol. It allows 6A to 51A in 0.6A increments and 55A to 80A in 2.5A increments.
It actually allows any amps from 6 to 80. It doesn't have to be in 0.6 or 2.5A increments.

At one time there was a bug in the Model S that wouldn't allow you raise the amps after you lowered them but it was fixed long ago. The problem now could be in the TWC or the car, we don't really know without measuring the pilot signal at the same time you transmit messages to the TWC.
 
  • Informative
Reactions: MP3Mike
It actually allows any amps from 6 to 80. It doesn't have to be in 0.6 or 2.5A increments.

The problem now could be in the TWC or the car, we don't really know without measuring the pilot signal at the same time you transmit messages to the TWC.

Well, the pilot signal is a 1kHz PWM signal where the width of the pulse determines charge rate. Each 1% change in width specifies a 0.6A change in charge rate up to 85% width, then after 86% width, each 1% specifies a 2.5A change in charge rate. It's not clear to me what happens between 85% and 86% if the standard allows interpreting partial percentages. It's also not clear how much of a partial percent a car should respond to. Maybe that's all in the true spec but I don't feel like digging into that right now. If you can quote from the original spec that would be helpful.

EDIT: I see PWM is a way to digitally encode an analog signal. I just wonder if cars are really intended to support any incremental amp value or maybe that's left up to the car. From what the TWC reports the Tesla is actually using, it's rounding whatever value the TWC is sending it to the nearest 0.6A (or maybe the nearest 0.5A) and drawing that much power. In one experiment, I set the TWC to 6.99A and then to 6.5A and the car draws the same amount of power in both cases. At 7.1A the car jumps up by ~0.5A in use.

This thing with the car dropping to 6A is almost certainly a problem with the car, not the TWC. People in this thread report the problem suddenly appearing in mid Oct and the only change would be in the car's firmware. There are rumors the car can update the TWC's firmware through the charging cable but since I seem to be missing some signals likely sent in newer firmware, I don't think my TWC has newer firmware and it's manifesting the problem with my car. Nothing's 100% sure in life, but logical deduction strongly suggests this was broken by a car firmware update.
 
Last edited:
  • Like
Reactions: spottyq