meshtastic / firmware

Meshtastic device firmware
https://meshtastic.org
GNU General Public License v3.0
3.3k stars 800 forks source link

tbeam draws too much power from USB port #601

Closed mc-hamster closed 3 years ago

mc-hamster commented 3 years ago

I had my tbeam connected via USB to my bench power supply with the battery at 95% and noticed that it draws nearly 1A from the port. This is outside the USB spec. If we stuck to the spec, we shouldn't draw more than 100ma without negotiation and up to 500ma with negotiation. Since we're not negotiating and 100ma isn't great, we should consider 500ma as the upper end.

Pg 22 of the axp192 data sheet says it draws as much power as it can from the supply for the battery charger only limited by register REG33H.

The default is either a 450ma or 780ma charge rate. This does not account for the nearly 1A draw at 95%.

I need to dig into this.

mc-hamster commented 3 years ago

Ah ha!

In power.cpp:

axp.setChargeControlCur(AXP1XX_CHARGE_CUR_1320MA); // actual limit (in HW) on the tbeam is 450mA

There's no HW limit on the tbeam. Maybe the only limit is the high resistance of the wires in a cheap usb cable.

mc-hamster commented 3 years ago

Switching the charge current to AXP1XX_CHARGE_CUR_450MA. That will make us a more friendly neighbor on the USB bus.

mc-hamster commented 3 years ago

Maybe the default can be set to be something we know is safe and then if someone needs it to charge faster, we can expose this over the device settings.

mc-hamster commented 3 years ago

Fixed with #601

mc-hamster commented 3 years ago

For future reference, valid values are:

AXP1XX_CHARGE_CUR_100MA,
AXP1XX_CHARGE_CUR_190MA,
AXP1XX_CHARGE_CUR_280MA,
AXP1XX_CHARGE_CUR_360MA,
AXP1XX_CHARGE_CUR_450MA,
AXP1XX_CHARGE_CUR_550MA,
AXP1XX_CHARGE_CUR_630MA,
AXP1XX_CHARGE_CUR_700MA,
AXP1XX_CHARGE_CUR_780MA,
AXP1XX_CHARGE_CUR_880MA,
AXP1XX_CHARGE_CUR_960MA,
AXP1XX_CHARGE_CUR_1000MA,
AXP1XX_CHARGE_CUR_1080MA,
AXP1XX_CHARGE_CUR_1160MA,
AXP1XX_CHARGE_CUR_1240MA,
AXP1XX_CHARGE_CUR_1320MA,