carcharger

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 1 Imported by: 0

README

carcharger

Model 12 V automotive charging: what a cigarette-lighter socket can actually deliver, how engine state changes it, and why a 65 W car charger may never reach 65 W in a given vehicle.

Install

go get github.com/taysirco/carcharger

Usage

import "github.com/taysirco/carcharger"

// A 10A-fused socket, engine off, 90% conversion efficiency
carcharger.AvailableWatts(carcharger.Fuse10A, carcharger.Off, 0.9)      // ~90W

// What limits the setup?
carcharger.LimitedBy(65,  carcharger.Fuse10A, carcharger.Off, 0.9)      // "charger"
carcharger.LimitedBy(150, carcharger.Fuse10A, carcharger.Off, 0.9)      // "socket"

// How long can a 60W load run before draining 20Ah of usable reserve?
carcharger.EngineOffDrainHours(60, 20)                                  // ~4.2h

The socket is the constraint nobody checks

A 12 V outlet is protected by a fuse — usually 10 A, sometimes 15 A. That fuse, not the charger, sets the hard ceiling. At a resting 12.6 V and a sane 80% continuous-duty margin, a 10 A circuit supplies roughly 90 W before conversion losses. A charger rated above that simply cannot reach its number in that vehicle.

Engine state matters too. With the engine off the rail sits near 12.6 V; once the alternator is running it rises toward 13.8–14.2 V, which raises available power by more than 10% for the same fuse.

Engine-off draw is a starter-battery problem

A car battery is a starter battery, not deep-cycle. Sustained draw with the engine off risks a no-start long before the battery is "empty", which is why EngineOffDrainHours should be given a conservative reserve figure rather than the battery's nameplate capacity.

Sources

Fuse ratings come from vehicle service manuals. Charger wattage and port data was sampled from retail listings — this car charger range publishes per-port splits, which most listings omit.

License

MIT

Documentation

Overview

Package carcharger models 12 V automotive charging: what a cigarette-lighter socket can actually deliver, how engine state changes the supply voltage, and why a car charger rated for 65 W may never reach it in a given vehicle.

The socket is the constraint most people never check. A typical 12 V outlet is protected by a 10 A or 15 A fuse, and that fuse — not the charger — sets the hard ceiling on everything downstream.

Reference charger specifications used to validate this package are published at https://cairovolt.com/en/anker/car-chargers

Index

Constants

View Source
const SafetyMargin = 0.8

SafetyMargin is the fraction of the fuse rating a charger should stay under for continuous draw. Fuses are not rated for sustained operation at 100%.

Variables

This section is empty.

Functions

func AvailableWatts

func AvailableWatts(fuse SocketFuse, engine EngineState, efficiency float64) float64

AvailableWatts returns the continuous power a socket can safely supply, accounting for the fuse rating, engine state and a conversion efficiency.

func Deliverable

func Deliverable(chargerWatts float64, fuse SocketFuse, engine EngineState, efficiency float64) float64

Deliverable reports the wattage a charger of the given rating can actually provide in this vehicle, capped by the socket.

func EngineOffDrainHours

func EngineOffDrainHours(loadWatts, reserveAh float64) float64

EngineOffDrainHours estimates how long a charger can run with the engine off before draining the given reserve capacity of a starter battery.

Starter batteries are not deep-cycle: drawing them below roughly half their capacity risks a no-start, so reserveAh should be a conservative figure.

func LimitedBy

func LimitedBy(chargerWatts float64, fuse SocketFuse, engine EngineState, efficiency float64) string

LimitedBy names what constrains the setup: "socket" or "charger".

Types

type EngineState

type EngineState int

EngineState affects the voltage present at the socket.

const (
	// Off means the battery alone supplies the socket, resting near 12.6 V.
	Off EngineState = iota
	// Idling means the alternator is charging, raising the rail toward 13.8 V.
	Idling
	// Driving is a loaded alternator, typically the highest and most stable.
	Driving
)

func (EngineState) RailVolts

func (e EngineState) RailVolts() float64

RailVolts returns the nominal supply voltage for an engine state.

type SocketFuse

type SocketFuse int

SocketFuse is the fuse rating protecting a 12 V outlet, in amps.

const (
	// Fuse10A is the most common rating in passenger cars.
	Fuse10A SocketFuse = 10
	// Fuse15A is found on higher-current accessory outlets.
	Fuse15A SocketFuse = 15
	// Fuse20A appears on some trucks and dedicated power outlets.
	Fuse20A SocketFuse = 20
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL