Open kOld opened 1 year ago
Wow didn't know this existed! Share your progress pls, I'm curious if it'll work out fine. You could roughly estimate remaining time by measuring the time between 2 LED state changes and interpolating to zero.That would be really rough but better then nothing I guess :)
Definitely is better to have some estimate that nothing, I was thinking in using something like the INA226 sensor, should be pretty simple to setup up inline with the load.
There is a couple of interesting features that we can implement with a simple voltage and current sensor:
#define HID_PD_IPRODUCT 0x01 // FEATURE ONLY
#define HID_PD_SERIAL 0x02 // FEATURE ONLY
#define HID_PD_MANUFACTURER 0x03 // FEATURE ONLY
#define IDEVICECHEMISTRY 0x04
#define IOEMVENDOR 0x05
#define HID_PD_RECHARGEABLE 0x06 // FEATURE ONLY
#define HID_PD_PRESENTSTATUS 0x07 // INPUT OR FEATURE(required by Windows)
#define HID_PD_REMAINTIMELIMIT 0x08
#define HID_PD_MANUFACTUREDATE 0x09
#define HID_PD_CONFIGVOLTAGE 0x0A // 10 FEATURE ONLY
#define HID_PD_VOLTAGE 0x0B // 11 INPUT (NA) OR FEATURE(implemented)
#define HID_PD_REMAININGCAPACITY 0x0C // 12 INPUT OR FEATURE(required by Windows)
#define HID_PD_RUNTIMETOEMPTY 0x0D
#define HID_PD_FULLCHRGECAPACITY 0x0E // 14 INPUT OR FEATURE. Last Full Charge Capacity
#define HID_PD_WARNCAPACITYLIMIT 0x0F
#define HID_PD_CPCTYGRANULARITY1 0x10
#define HID_PD_REMNCAPACITYLIMIT 0x11
#define HID_PD_DELAYBE4SHUTDOWN 0x12 // 18 FEATURE ONLY
#define HID_PD_DELAYBE4REBOOT 0x13
#define HID_PD_AUDIBLEALARMCTRL 0x14 // 20 FEATURE ONLY
#define HID_PD_CURRENT 0x15 // 21 FEATURE ONLY
#define HID_PD_CAPACITYMODE 0x16
#define HID_PD_DESIGNCAPACITY 0x17
#define HID_PD_CPCTYGRANULARITY2 0x18
#define HID_PD_AVERAGETIME2FULL 0x1A
#define HID_PD_AVERAGECURRENT 0x1B
#define HID_PD_AVERAGETIME2EMPTY 0x1C
#define HID_PD_IDEVICECHEMISTRY 0x1F // Feature
#define HID_PD_IOEMINFORMATION 0x20 // Feature
// PresenStatus dynamic flags
#define PRESENTSTATUS_CHARGING 0x00
#define PRESENTSTATUS_DISCHARGING 0x01
#define PRESENTSTATUS_ACPRESENT 0x02
#define PRESENTSTATUS_BATTPRESENT 0x03
#define PRESENTSTATUS_BELOWRCL 0x04
#define PRESENTSTATUS_RTLEXPIRED 0x05
#define PRESENTSTATUS_NEEDREPLACE 0x06
#define PRESENTSTATUS_VOLTAGENR 0x07
#define PRESENTSTATUS_FULLCHARGE 0x08
#define PRESENTSTATUS_FULLDISCHARGE 0x09
#define PRESENTSTATUS_SHUTDOWNREQ 0x0A
#define PRESENTSTATUS_SHUTDOWNIMNT 0x0B
#define PRESENTSTATUS_COMMLOST 0x0C
#define PRESENTSTATUS_OVERLOAD 0x0D
Anyway, I was looking into your pictures and I'm wondering if we have an UART interface available right here:
Did you try to use some logic analyser with this pins?
Just a quick update, I've tested the library on a Arduino Pro Micro 16Mhz and it works brilliantly, at least under Mac OS X:
Edit: I've created very quick version of your code with the UPS HID library: https://gist.github.com/kOld/5d2c7f3ae3c810de0f3b00ebc06c6180
Not sure if it's working perfecty but give it a try in case you have an Arduino Pro Micro or Leonardo laying around
Just discovered your project, great documentation 👍
Right away I remembered the HIDPowerDevice for Arduino Leonardo: https://github.com/abratchik/HIDPowerDevice
This way should be possible to use all the common tools that will shutdown the system when the charge state gets low, also it will gets a nice battery icon for the compatible OSes
I’m planning on buying a unit and trying to merge your code with the HID UPS example for state and percent reporting, but probably we won’t get any insights about remaining time without analyzing the power consumption in realtime with some current sensor
Thanks, Élio