Skip to content

feat(nissanleaf): add v.b.12v.current metric (from polling VCM)#1152

Draft
zhongfu wants to merge 2 commits intoopenvehicles:masterfrom
zhongfu:feat/nissanleaf-12v-current
Draft

feat(nissanleaf): add v.b.12v.current metric (from polling VCM)#1152
zhongfu wants to merge 2 commits intoopenvehicles:masterfrom
zhongfu:feat/nissanleaf-12v-current

Conversation

@zhongfu
Copy link
Copy Markdown
Contributor

@zhongfu zhongfu commented May 17, 2025

as the title says, this PR adds a v.b.12v.current metric for measuring 12V battery current.

it doesn't seem like anyone has figured out if the VCM (which is connected directly to the 12V lead-acid battery current sensor) reports this periodically, so for now, we can only poll

potential improvements/issues:

  • poll whenever car is awake or HV relay is closed, instead of polling only while in on/running/charging states

    • this includes when remote climate control and the daily 12V battery top up is happening
    • but it seems like we might only support 4 poll states max (VEHICLE_POLL_NSTATES in vehicle_poller.h is set to 4, not sure about the implications of increasing this)
  • figure out if if it's safe to poll while running

    • I haven't had any issues so far on my ZE1, but Nissan LEAF P312A DTC & dashboard warning light  #409 seems to imply this might be an issue on ZE0/AZE0 (which is probably why we also have a separate "running" poll state)
    • VCM is also connected on EV-CAN, perhaps it'd be safer to poll there (if even possible)?
  • figure out if VCM (or e.g. DC-DC converter) is reporting this information on the CAN bus

    • would avoid most of the mess above, since we can simply passively listen and avoid polling

for now, this is a draft because i'll still have to test this (to make sure the resulting values seem reasonable), plus this isn't a great solution IMO

@dexterbg
Copy link
Copy Markdown
Member

While it's of course possible to increase the number of poll states supported, it seems a bit odd needing to do so, as all other vehicles do just fine with 4 states.

From a look into the source, it seems you currently waste one state. A comment in the module reads…

// Leaf does not respond to polls when car is off
// So there is no point polling when car is off

Yet you still have state slot 0 assigned to the "off" state, with all poll entry times being zero. If you can detect the vehicle "on" states without polling, you don't need an "off" polling state, but can instead stop the poller.

Regards,
Michael

@zhongfu
Copy link
Copy Markdown
Contributor Author

zhongfu commented May 18, 2025

If you can detect the vehicle "on" states without polling, you don't need an "off" polling state, but can instead stop the poller.

Ah yeah, that makes sense. I'll go check it out, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants